Localization (multiple languages)

Hi There folks!
I’m trying to implement localization into my app
I found this blog post: Localisations and I was able to follow up and make it working for a pair of English and French.

Next I tried adding 3rd language to the mix (German)
And here I am partially successful as it only works when I follow the order English->French or English->German. It doesn’t work while switching between French->German or vice versa.

Did someone already tried this with multiple languages in the dropdown?

Second question I have is for translating text which is not a part of the control property. I have couple alert messages, how can those be localized by using that same localized app from the blog?

You’d use the functions for translating manually, e.g. alert(_('alert message 1')), assuming that you have a key of 'alert message 1' that points to translations of what you want that message to be in all three languages.

I can’t help with that one. Maybe share a clone link demonstrating the issue?

@jshaffstall thx! The trick with _ function works.
Regarding the example here is the link Anvil | Login
What I mean is if you click language Polish it works and translates. If you click back English it works. If you click Ukrainian when your UI was in English it also works. It doesn’t work when you have UI in Polish and try to switch to Ukrainian.
It’s because I declared 2 locale dictionaries one English-Polish and other English-Ukrainian. Do I need to create also Polish-Ukrainian dictionary and do I need to have such pair of languages in dictionary for every possible combination of languages later in the app? Or I’m fundamentally wrong on the approach?

You can do this in the LocaleDropdown form:

  def drop_down_language_change(self, **event_args):
    """This method is called when an item is selected"""
    Translations.set_locale('EN')
    Translations.set_locale(self.item['locale'])
3 Likes

Amazing how simple it was. I’m just feeling embarrassed :slight_smile: