Skip to content

Commit

Permalink
fix(web): fix capitalization of RFC 5646 language tags
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 12, 2024
1 parent 33309f3 commit c98259a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 69 deletions.
126 changes: 63 additions & 63 deletions web/share/locales.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
{
"af": "za",
"am": "et",
"ar": "eg",
"ast": "es",
"be": "by",
"bg": "bg",
"bn": "in",
"bs": "ba",
"ca": "es",
"cs": "cz",
"cy": "gb",
"da": "dk",
"de": "de",
"en": "us",
"el": "gr",
"es": "es",
"et": "ee",
"eu": "es",
"fa": "ir",
"fi": "fi",
"fr": "fr",
"gl": "es",
"gu": "in",
"he": "il",
"hi": "in",
"hr": "hr",
"hu": "hu",
"id": "id",
"it": "it",
"ja": "jp",
"ka": "kz",
"km": "kh",
"kn": "in",
"ko": "kr",
"lt": "lt",
"lv": "lv",
"mk": "mk",
"mr": "in",
"ms": "my",
"my": "mm",
"nb": "no",
"nds": "de",
"ne": "np",
"nl": "nl",
"nn": "no",
"pa": "in",
"pl": "pl",
"pt": "pt",
"ro": "ro",
"ru": "ru",
"si": "lk",
"sk": "sk",
"sl": "si",
"sq": "al",
"sr": "rs",
"sv": "se",
"ta": "in",
"tg": "tj",
"th": "th",
"tr": "tr",
"uk": "ua",
"vi": "vn",
"zu": "za"
"af": "ZA",
"am": "ET",
"ar": "EG",
"ast": "ES",
"be": "BY",
"bg": "BG",
"bn": "IN",
"bs": "BA",
"ca": "ES",
"cs": "CZ",
"cy": "GB",
"da": "DK",
"de": "DE",
"en": "US",
"el": "GR",
"es": "ES",
"et": "EE",
"eu": "ES",
"fa": "IR",
"fi": "FI",
"fr": "FR",
"gl": "ES",
"gu": "IN",
"he": "IL",
"hi": "IN",
"hr": "HR",
"hu": "HU",
"id": "ID",
"it": "IT",
"ja": "JP",
"ka": "KZ",
"km": "KH",
"kn": "IN",
"ko": "KR",
"lt": "LT",
"lv": "LV",
"mk": "MK",
"mr": "IN",
"ms": "MY",
"my": "MM",
"nb": "NO",
"nds": "DE",
"ne": "NP",
"nl": "NL",
"nn": "NO",
"pa": "IN",
"pl": "PL",
"pt": "PT",
"ro": "RO",
"ru": "RU",
"si": "LK",
"sk": "SK",
"sl": "SI",
"sq": "AL",
"sr": "RS",
"sv": "SE",
"ta": "IN",
"tg": "TJ",
"th": "TH",
"tr": "TR",
"uk": "UA",
"vi": "VN",
"zu": "ZA"
}
13 changes: 7 additions & 6 deletions web/share/update-languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#

from argparse import ArgumentParser
from typing import Optional
from langtable import language_name
from pathlib import Path
import json
Expand All @@ -32,9 +33,9 @@

class Locale:
language: str
territory: str
territory: Optional[str]

def __init__(self, language: str, territory: str = None):
def __init__(self, language: str, territory: Optional[str] = None):
self.language = language
self.territory = territory

Expand All @@ -44,13 +45,13 @@ def code(self):
def name(self, include_territory: bool = False):
if include_territory:
return language_name(languageId=self.language,
territoryId=self.territory.upper())
territoryId=self.territory)
else:
return language_name(languageId=self.language)


class PoFile:
path: str
path: Path
locale: Locale

def __init__(self, path: Path):
Expand Down Expand Up @@ -85,7 +86,7 @@ class Languages:
def __init__(self):
self.content = dict()

def update(self, po_files, lang2territory: str, threshold: int):
def update(self, po_files, lang2territory, threshold: int):
"""
Generate the list of supported locales
Expand All @@ -97,7 +98,7 @@ def update(self, po_files, lang2territory: str, threshold: int):
:param threshold Percentage of the strings that must be covered to
include the locale in the manifest
"""
supported = [Locale("en", "us")]
supported = [Locale("en", "US")]

for path in po_files:
po_file = PoFile(path)
Expand Down

0 comments on commit c98259a

Please sign in to comment.