gettext icon indicating copy to clipboard operation
gettext copied to clipboard

Support falling back to another language, if a PO for a language is partially translated

Open tusooa opened this issue 3 years ago • 1 comments

Currently the default implementation fallback to msgid if the translation for a language is missing. However, in many cases, we would want the user to choose a fallback language, so that if there is some missing translation, they can still read in what they would prefer.

There is handle_missing_translation, but a big problem is that it does not get msgctxt, so if we would like to try gettext again with some other language, we do not have enough information to do so -- suppose the initial call is dpgettext or so.

A simple solution would be pass msgctxt to handle_missing_translation functions. Or just support fallbacking natively in the module.

Downstream

https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3634#note_89751

tusooa avatar Mar 03 '22 00:03 tusooa

A pull request is welcome. We should define a new version of those callbacks that receive the context. Later I can do a quick pass to make it backwards compatible.

josevalim avatar Mar 03 '22 06:03 josevalim

@tusooa any updates on this?

whatyouhide avatar Dec 17 '22 09:12 whatyouhide

@tusooa any updates on this?

We already implemented support for fallbacks in Pleroma.

tusooa avatar Dec 18 '22 02:12 tusooa

@tusooa fantastic 🙃 Do you think that's something that we should backport back to Gettext, or were you able to do this with the current Gettext API, meaning no changes are needed to Gettext?

whatyouhide avatar Dec 18 '22 07:12 whatyouhide

@tusooa fantastic upside_down_face Do you think that's something that we should backport back to Gettext, or were you able to do this with the current Gettext API, meaning no changes are needed to Gettext?

With https://github.com/elixir-gettext/gettext/pull/304 , we are able to implement fallbacks already. It would be nice to have native fallbacks in the library, just like GNU gettext, but with the bug in the environment, it may be hard to deliver a result that satisfies everyone.

tusooa avatar Dec 19 '22 14:12 tusooa

Okay, so for now I'll close this then. Thanks for reporting back! 💟

whatyouhide avatar Dec 20 '22 10:12 whatyouhide