Bahmni Config: How to provide multiple locale files per app

Hello!

I am trying to provide translation keys in 2 files in Bahmni Config.

From this other post: “Bahmni: Changes in locale_en.json, should I update Transifex as well?”

But that seems to not work.

Here is the contents of my i18n/registration folder:

└── registration
    ├── bahmniapps_en.json
    ├── bahmniapps_km.json
    ├── locale_en.json
    └── locale_km.json

Keys are present in the bahmniapps_xx.json file: key is present in the file

But not loaded

missing i18n keys

1 Like

Weird! Can you create a ticket for this? I will have to check the code, as I can see part of the labels correctly loaded. Can you attach the files?

On the screenshot above, the labels that appear correctly translated are either:

  • present in locale_km.json file. This is the case for labels: ស្រាវជ្រាវ (e) (Search) and បង្កើតថ្មី (N) (Create New) at the top of the screen. locale_km.json file is loaded and keys are correctly looked up.

  • or labels of OpenMRS metadata already translated by exti18n module. Labels លេខសម្គាល់ OpenMRS and ឈ្មោះ-ខ្មែរ . Those are not related to Bahmni at all, this is all server-side work (as you know)

The keys not processed though are the ones provided in bahmniapps_km.json (same with bahmniapps_en.json or any locale). It seems like the file has to be named locale_xx.json

I will try to provide you with a simpler example of one key per file and attach the files here.

Here is a cleaner example:

# cat openmrs/i18n/registration/locale_en.json

{
  "REGISTRATION_SEARCH_CONFIG_KEY": "S<u>e</u>arch"
}

# cat openmrs/i18n/registration/bahmniapps_en.json

{
  "REGISTRATION_CREATE_NEW_CONFIG_KEY":"Create <u>N</u>ew"
}

Here is the result:

json

Search is correctly translated, Create New is not.

Well, this has been a wild goose chase, and I am kicking myself for reading your note more carefully. When I said you can put as many files suffixed with .json, I didn’t actually mean that the locale file name can be anything. To load the files, we need to know how they are going to be named by a convention. The convention is pretty simple,

<location of bahmni_config>/openmrs/i18n/<app name>/locale_<code>.json

The patterns of the file name is locale_<code>.json. This code can be anything “en”, “es” etc etc. As long as you configured the supported locales by the right codes in openmrs admin.

You can not add a bahmniapps_en.json, because Bahmni doesn’t know what file name is used.

1 Like

Thanks. Sorry for not being clear enough on this one.

Do you think we could improve this by supporting a certain pattern that would allow to load multiple files, for one locale? For instance any files in the folder and named as <any-prefix>_locale_<i18n-code>.json


The use case is as described in this thread Bahmni: Changes in locale_en.json, should I update Transifex as well? where I am trying to find out how Bahmni implementors can really streamline the management of the localization files.

From the thread, I don’t see how one can really provide translation of Bahmni Apps for a given language without forking Bahmni Apps (which I would not advise), so providing the i18n files in the config seems a not so bad idea in the end.

You can just add your locale files, or replace existing ones - don’t you?

The question with the translation packs is also about preference - although angular-translate module (pascalprecht.translate) that we are using does provide merging. The question comes up whats the order of loading!

Check the “mergeLocaleFilesService.js” file.

3 posts were split to a new topic: Work on internationalizing Bahmni for Arabic and other right-to-left languages