i18n: add localization support for yes/no prompts and answers#201
i18n: add localization support for yes/no prompts and answers#201marcotuliomatos wants to merge 1 commit intoexequtic:mainfrom
Conversation
|
The standard I’d prefer not to add more translation-related logic. The text in the widget is constantly being added to and changed, while community support for translations is almost nonexistent. For that reason, translations will most likely no longer be included in the widget’s package and will remain optional, or may even be removed entirely, so I don’t want to expand this part any further. |
|
Hi, thanks for the feedback. I understand the preference for keeping the standard That said, I understand your concern about adding more translation-related logic, especially if translations are becoming harder to maintain. I still think localization adds real value for non-English-speaking users, as well as for those like myself who can use English but are not native speakers, so I hope it can remain part of the project in some form. My main goal with this PR was to make the existing localization support more consistent and reliable where translations are already present, while keeping the implementation aligned with well-established locale rules present in glibc. But I understand that this may not fit the project direction you have in mind right now. Thanks again for your time. I’ll keep the pt_BR translation updated as long as localization remains in the project, and I’ll be happy to contribute in other areas as well. |
This change adds localization support for all yes/no prompts presented by the Apdatifier Bash scripts (
printQuestion()in theutilsscript), as well as for the corresponding answer options available to the user.With this change, the appropriate answer options have already been added to all
.potranslation files. Their contents reflect the values ofyesexprandnoexprin the glibcLC_MESSAGESsection for each locale. This not only ensures consistency with the way many applications handle locales through glibc, but also has the benefit of lowering the barrier to adding support for new languages in Apdatifier, since the regex used to handle yes/no variants across a wide range of languages is already available in glibc.To pave the way for this change, the conditional processing of user answers had to be replaced with
if/then/elsestatements, which, unlike thecasestatements previously in use, are able to handle regex matching. The use of regex became necessary due to certain language-specific cases, such as Ukrainian. This situation is well described in glibcLC_MESSAGESforuk_UA:And:
Dealing with та/так/НІ (and their respective uppercase/lowercase variants) using Bash globs, although possible, would be overly hacky and could increase the maintenance burden, whereas regex handles them cleanly with
^([+1Yy]|[Тт][Аа][Кк]?)$and^([-0Nn]|[Нн][Іі])$.Overall, everything seems to work as intended with this approach. Tests were performed manually to verify correct prompt behavior in all languages currently supported by Apdatifier.