gotext icon indicating copy to clipboard operation
gotext copied to clipboard

Add support for multiple languages

Open m-horky opened this issue 10 months ago • 6 comments

Is this a fix, improvement or something else?

This is an improvement, an updated version of #73.

This patch adds support for fallback translations. pt_BR:pt:es makes it possible to use Brazilian Portuguese, fallback to default Portuguese and to Spanish when the translation is not available.

What does this change implement/fix?

  • This patch changes the config struct, and internal implementation of functions that work with it.
  • It changes Get*() functions to iterate over loaded languages, instead of using the only one.
  • It changes IsTranslated*() functions to include new required argument of the language to be checked.
  • See more detailed changes in the respective commits.

The original PR failed because PR #80 was merged first. Since my PR changes the naming from storage to locales, I'd like to have opinion of @didrocks as well. For this version I have opted to keep their function names GetStorage and SetStorage for complete backwards compatibility. This is a bit unfortunate because the functions are called differently from the rest of the code, but we cannot change that without making a breaking change. (I am not blaming you, the change does make sense. The naming just is not the best, as it is a bit cryptic without knowing the internals.) I can revert it all to 'storage' if consistency is preferred, that's up to @leonelquinteros to tell :)

I have ...

  • [x] answered the 2 questions above,
  • [x] discussed this change in an issue,
  • [x] included tests to cover this changes.

m-horky avatar Aug 30 '23 08:08 m-horky