0
votes

I'm completely new to i18n. Now starting to structure my React Native app for translation.

Most of the metadata in the app comes from the server on demand as json files describing structure of a certain module. A typical client might have about 5 to 50 such "modules" loaded into it's Redux store.

One module type looks like this (simplified):

{
  id: 5,
  modifiedAt: new Date('2017-02-22T09:50:50.212+0100'),
  name: 'Module name',
  version: '1.0.0',
  definition: {
    preconditions: {},
    actions: {},
    effects: {},
    fieldDefinitions: {
      room: {
        title: 'Field title for "room"',
        warning: 'Room is missing',
        helpText: 'Enter room id/name',
        type: 'string',
        isRequired: true,
      },
    ui: {
      title: 'Module title, i.e. title on input form',
      menuItem: {
        iconName: 'md-settings',
        iconLibrary: 'Ionicons',
        iconColor: null,
        sortOrder: 99,
      },
      sections: [
        {
          id: 'ed472749-ec3d-4b72-9ce9-f88ee703b2cf',
          title: 'Installation',
          isRequired: true,
          formFields: ['room', ...],
        },
        {
          id: 'c070bfdf-88f1-423a-8854-b47b154c2359',
          title: 'Photo before started repair',
          isRequired: true,
          sectionType: 'media',
        }
      ],
    },
  },
  jsonSchema: {
    //schema to validate form output before saving
    //also used by API before saving to database
  },
  i18n: {
    en: {

    },
    de: {

    }
  }
};

I have added 18n at the end of the json, as this is my stab on this for the moment. Modules can be custom made for certain customers. I'm thinking that it would be nice to encapsulate i18n into each module.

I'm thinking of using react-i18next for this as it seems well documented and will also work when I need to translate my Express site.

I'm also thinking of giving each module a unique guid which I could use as namespace-id when the app loads each i18n file.

Is this a reasonable way to modularize i18n files?

I've searched for i18n tutorials, but I only end up in language specific tutorials. Can anyone recommend an i18n primer with good discussions on what structure to choose, how to use namespaces, how to modularize, etc.

1

1 Answers

1
votes

we personally namespaced (split) i18n files around features - might reflect your modules....there is nothing bad about splitting into a file per module - but if getting to small you might merge them into bigger files...really depends on the the size of your project.

We made some documentation/tips for spitting into files on https://docs.locize.com/namespaces.html (locize.com - is the as a service layer of i18next and provided by same people as i18next (me ;)))