Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization of FireCMS #27

Closed
fabarea opened this issue Dec 2, 2020 · 5 comments
Closed

Localization of FireCMS #27

fabarea opened this issue Dec 2, 2020 · 5 comments

Comments

@fabarea
Copy link

fabarea commented Dec 2, 2020

For now the labels are hard-coded in English. It would be nice to make them translatable. I would be happy to contribute for French 馃槃

@fgatti675
Copy link
Member

Hi @fabarea that would be great!
We currently don't have any localization framework in place. Do you have any suggestions?

@fabarea
Copy link
Author

fabarea commented Dec 7, 2020

I have made good experience with i18next and react-i18next. In the main index.ts you would find something like that:

// to be put quite "high" in the import list to have the i18 framework initialize early.
import './i18next-init'

In 18next-init.ts:

import i18next from 'i18next'
import common_en from './translations/en/common.json'
import common_es from './translations/es/common.json'

i18next.init({
  interpolation: { escapeValue: false }, // React already does escaping
  lng: 'fr', // language to use
  resources: {
    en: {
      translation: common_en
    }
    es: {
      translation: common_es
    },
    ...
  }
})

Then, it whatever file you can have something like that:

import i18next from 'i18next'

console.log(i18next.t('hello'))

Example for the productionCollution.ts

...
import i18next from 'i18next'

const productCollection = buildCollection({
  name: i18next.t('products'), // <------ 
  relativePath: 'products',
  schema: productSchema,
  textSearchDelegate: productsSearchDelegate,
  additionalColumns: [productAdditionalColumn],
  subcollections: [localeCollection],
  defaultSize: 'xs'
})

@PupoSDC
Copy link
Contributor

PupoSDC commented May 7, 2021

Hi @fgatti675, If this is low priority for you, I would like to give this a try. react-18next is also my favourite framework for this, so i would use that. I can Provide translation to Portuguese, and eventually, my company would appreciate having in german ;)

@fgatti675
Copy link
Member

That would be awesome @PupoSDC !

@fgatti675
Copy link
Member

Closing this for lack of activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants