Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Automatically update the list of supported locales #803

Merged
merged 7 commits into from
Oct 25, 2023
Merged

[RFC] Automatically update the list of supported locales #803

merged 7 commits into from
Oct 25, 2023

Conversation

imobachgs
Copy link
Contributor

@imobachgs imobachgs commented Oct 19, 2023

Problem

#796 uses the list of locales included in the manifest.js file. Maintaining that list by hand is not an option, so we need a mechanism to do it automatically.

Solution

Add a update-manifest.py script that runs every time the PO files are imported from the agama-weblate repository.

  1. The script goes through all PO files, determining the locale for each one. It assumes that the files are named as xx.po or xx_yy.po (where xx is the language and yy the territory). In the case of xx.po files, you cannot infer the territory from the name. For example, es.po corresponds to es_es.po, but uk.po corresponds to uk_ua. That's why we have a map.
  2. It selects those PO files with more than 70% of translated messages.
  3. It updates the manifest.json file, including the locale code (en-us) and the name of the language (English). If there is more than one locale for the same language, it includes the territory in the name (e.g., English (United Kingdom) and English (Great Britain). Otherwise, it just uses the language name (English).

Testing

  • Manually tested.

To do

  • Extend the map, based on the language_map.txt from the Cockpit project.
  • Extend/improve the documentation
  • Better error reporting

web/share/update-manifest.py Outdated Show resolved Hide resolved
@@ -0,0 +1,10 @@
{
"cs": "cz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actaually need this mapping? The langtable provides the most common territory for a language if we do not know it from the PO file name. See https://raw.githubusercontent.com/mike-fabian/langtable/main/langtable/data/languages.xml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are right, the territories are sorted by rank. I will fix that.

Copy link
Contributor

@lslezak lslezak Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record: it turned out that e.g. for "pt" the highest ranked is "pt_BR" which is actually correct from the ranking POV, but usually the "pt_PT" is the default...

@coveralls
Copy link

coveralls commented Oct 22, 2023

Coverage Status

coverage: 75.13%. remained the same when pulling b957a6e on imobachgs:auto-update-locales into 18d7a88 on openSUSE:master.

imobachgs and others added 3 commits October 22, 2023 16:55
Added languages currently supported by YaST (yast2-trans-* packages),
we can expect that Agama will support a similar set.
@imobachgs imobachgs marked this pull request as ready for review October 24, 2023 10:06
@imobachgs imobachgs merged commit 9c26603 into agama-project:master Oct 25, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants