FIX: Normalize languages within Discourse AI translator #194
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If the user's locale is different from the post's detected locale, a post can be translated, and the 🌐 icon will appear.
For each translator (e.g. Google, Amazon, Azure), we maintain a list of mappings
SUPPORTED_LANG_MAPPINGfor each locale. On top of that, the mapping is also used to define what language the post should be translated to. When using most translators, "en_GB" forums will translate text to "en" due to these mappings. However, this is not a problem for Discourse AI provider -- since there are no restrictions on language, every post is translatable to any (regionalised) locale.This PR introduces a site settingnormalize_language_variantsso that admins can properly indicate if (example locale)They want"ar" == "ar_SA" == "ar_MA"or;They would prefer that"ar_SA"is not the same as"ar".This PR normalizes locales within Discourse AI translator, so that it sees "ar" to be the same as "ar_SA".