origo
origo copied to clipboard
feature: localization control suggestion
Aims to resolve #900
This is the result of activity 2.10 in this year's management plan and the discussions we've had in our dev meetings. It introduces a way of localizing visible strings and numbers. As previously agreed the map needs to reload in order to set a new language. (Some day we might have a separate discussion regarding the components ability to refresh the the dom or parts of it.)
It is a draft because the method is a suggestion. I do want feedback still : )
..And the way to configure it is as such, in the map config json:
{
"name": "localization",
"options":{
"localeId": "sv-SE",
"fallbackLocaleId": "en-US",
"showLocMenu": true
}
}
where the fallbackLocaleId
is a potentially more filled out locale.json and what the string lookups will target if there's no match in the localeId
.
The localeId
sets the map locale at start, though if a query param specifies a different locale then the different locale will load. The query param is set by the gui language switcher. It is loc=sv-SE
for instance.
It provides:
- A menu item to select a new locale (or not - is configurable)
- The current locale can be set via a query param
- The string lookup is a function
- The api or a plugin can be utilized to add new locales (for a session)
- 2024-09-27: A plugin can utilize the localization component in order to localize itself by first adding its language file to the corresponding Origo locale
Developer / translator experience:
- The locale definitions are kept as json files, one per locale
- The json structure is partially employed on key lookup - the target key and its parent can be specified
- All controls receive the localization component as an option
- The hardcoded strings in the code can be replaced gradually, perhaps control by control
- Once a single string is converted the localization control needs to be present
animated gifs
-
The measure control (numbers and strings)
-
Adding a locale
Missing:
- Sharemap. Save a new query param (besides "mapStateId")
- Polish on the gui bit. :pill: . Nothing else scrolls when the window gets smaller and this dropdown currently only scrolls if the language list is long enough.
What are your thoughts?