gawati / gawati-portal-ui

Version 2 of the gawati portal
GNU Affero General Public License v3.0
0 stars 0 forks source link

Override default strings via custom strings loaded from the active theme folder #90

Open kohsah opened 6 years ago

kohsah commented 6 years ago

Currently language strings are installed by the gawati-lang-packs application, the startup scripts copy all the lang strings into public/locales and the application picks it up from there.

The problem with this approach is, if we need to customize a string in a particular installation there is no way to do it other than change the string for the key in public/locales for one or more languages. While this may work - it is not very practical because the strings will get overwritten the next time we build or start the application, and secondly it will get overwritten if gawati-lang-packs gets updated.

A more practical approach is to have a way to override some strings using a 2nd translations file. i18next allows having multiple namespaces for language strings. So the idea is to have this custom namespace in the themes folder with the same folder structure locales/<lang(s)> and merge this into public/locales during startup .. so effectively public/locales will have translations.json and custom.json ... with the custom.json having higher priority ... so effectively any strings in custom.json override the ones in translation.json.

kohsah commented 6 years ago

@ccsmart This has been implemented. There is a custom.json provided by the theme which can override strings in the main translations.json