diff --git a/rpmlint/__isocodes__.py b/rpmlint/__isocodes__.py index 6f6406866..111bd5c8f 100644 --- a/rpmlint/__isocodes__.py +++ b/rpmlint/__isocodes__.py @@ -7996,6 +7996,15 @@ 'AW', 'AX', 'AZ', + 'Adlm', + 'Afak', + 'Aghb', + 'Ahom', + 'Arab', + 'Aran', + 'Armi', + 'Armn', + 'Avst', 'BA', 'BB', 'BD', @@ -8017,6 +8026,18 @@ 'BW', 'BY', 'BZ', + 'Bali', + 'Bamu', + 'Bass', + 'Batk', + 'Beng', + 'Bhks', + 'Blis', + 'Bopo', + 'Brah', + 'Brai', + 'Bugi', + 'Buhd', 'CA', 'CC', 'CD', @@ -8036,12 +8057,25 @@ 'CX', 'CY', 'CZ', + 'Cakm', + 'Cans', + 'Cari', + 'Cham', + 'Cher', + 'Cirt', + 'Copt', + 'Cprt', + 'Cyrl', + 'Cyrs', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', + 'Deva', + 'Dsrt', + 'Dupl', 'EC', 'EE', 'EG', @@ -8049,6 +8083,11 @@ 'ER', 'ES', 'ET', + 'Egyd', + 'Egyh', + 'Egyp', + 'Elba', + 'Ethi', 'FI', 'FJ', 'FK', @@ -8074,12 +8113,33 @@ 'GU', 'GW', 'GY', + 'Geok', + 'Geor', + 'Glag', + 'Goth', + 'Gran', + 'Grek', + 'Gujr', + 'Guru', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', + 'Hanb', + 'Hang', + 'Hani', + 'Hano', + 'Hans', + 'Hant', + 'Hatr', + 'Hebr', + 'Hira', + 'Hluw', + 'Hmng', + 'Hrkt', + 'Hung', 'ID', 'IE', 'IL', @@ -8090,10 +8150,16 @@ 'IR', 'IS', 'IT', + 'Inds', + 'Ital', 'JE', 'JM', 'JO', 'JP', + 'Jamo', + 'Java', + 'Jpan', + 'Jurc', 'KE', 'KG', 'KH', @@ -8105,6 +8171,17 @@ 'KW', 'KY', 'KZ', + 'Kali', + 'Kana', + 'Khar', + 'Khmr', + 'Khoj', + 'Kitl', + 'Kits', + 'Knda', + 'Kore', + 'Kpel', + 'Kthi', 'LA', 'LB', 'LC', @@ -8116,6 +8193,20 @@ 'LU', 'LV', 'LY', + 'Lana', + 'Laoo', + 'Latf', + 'Latg', + 'Latn', + 'Leke', + 'Lepc', + 'Limb', + 'Lina', + 'Linb', + 'Lisu', + 'Loma', + 'Lyci', + 'Lydi', 'MA', 'MC', 'MD', @@ -8139,6 +8230,22 @@ 'MX', 'MY', 'MZ', + 'Mahj', + 'Mand', + 'Mani', + 'Marc', + 'Maya', + 'Mend', + 'Merc', + 'Mero', + 'Mlym', + 'Modi', + 'Mong', + 'Moon', + 'Mroo', + 'Mtei', + 'Mult', + 'Mymr', 'NA', 'NC', 'NE', @@ -8151,7 +8258,19 @@ 'NR', 'NU', 'NZ', + 'Narb', + 'Nbat', + 'Newa', + 'Nkgb', + 'Nkoo', + 'Nshu', 'OM', + 'Ogam', + 'Olck', + 'Orkh', + 'Orya', + 'Osge', + 'Osma', 'PA', 'PE', 'PF', @@ -8166,12 +8285,28 @@ 'PT', 'PW', 'PY', + 'Palm', + 'Pauc', + 'Perm', + 'Phag', + 'Phli', + 'Phlp', + 'Phlv', + 'Phnx', + 'Piqd', + 'Plrd', + 'Prti', 'QA', + 'Qaaa', + 'Qabx', 'RE', 'RO', 'RS', 'RU', 'RW', + 'Rjng', + 'Roro', + 'Runr', 'SA', 'SB', 'SC', @@ -8193,6 +8328,23 @@ 'SX', 'SY', 'SZ', + 'Samr', + 'Sara', + 'Sarb', + 'Saur', + 'Sgnw', + 'Shaw', + 'Shrd', + 'Sidd', + 'Sind', + 'Sinh', + 'Sora', + 'Sund', + 'Sylo', + 'Syrc', + 'Syre', + 'Syrj', + 'Syrn', 'TC', 'TD', 'TF', @@ -8209,12 +8361,28 @@ 'TV', 'TW', 'TZ', + 'Tagb', + 'Takr', + 'Tale', + 'Talu', + 'Taml', + 'Tang', + 'Tavt', + 'Telu', + 'Teng', + 'Tfng', + 'Tglg', + 'Thaa', + 'Thai', + 'Tibt', + 'Tirh', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', + 'Ugar', 'VA', 'VC', 'VE', @@ -8222,10 +8390,24 @@ 'VI', 'VN', 'VU', + 'Vaii', + 'Visp', 'WF', 'WS', + 'Wara', + 'Wole', + 'Xpeo', + 'Xsux', 'YE', 'YT', + 'Yiii', 'ZA', 'ZM', - 'ZW'} + 'ZW', + 'Zinh', + 'Zmth', + 'Zsye', + 'Zsym', + 'Zxxx', + 'Zyyy', + 'Zzzz'} diff --git a/test/test_i18n.py b/test/test_i18n.py new file mode 100644 index 000000000..016cf9faf --- /dev/null +++ b/test/test_i18n.py @@ -0,0 +1,49 @@ +import pytest +from rpmlint.checks.I18NCheck import I18NCheck +from rpmlint.filter import Filter + +from Testing import CONFIG, get_tested_mock_package + + +@pytest.fixture(scope='function', autouse=True) +def i18ncheck(): + CONFIG.info = True + output = Filter(CONFIG) + test = I18NCheck(CONFIG, output) + yield output, test + + +@pytest.fixture +def output(i18ncheck): + output, _test = i18ncheck + yield output + + +@pytest.fixture +def test(i18ncheck): + _output, test = i18ncheck + yield test + + +@pytest.mark.parametrize('package', [ + get_tested_mock_package(files=['/usr/share/locale/xx_ES/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/es_XX/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/xx/LC_MESSAGES/goodvibes.mo']), +]) +def test_i18n_invalid_lang(package, output, test): + test.check(package) + out = output.print_results(output.results) + assert 'E: invalid-lc-messages-dir' in out + + +@pytest.mark.parametrize('package', [ + get_tested_mock_package(files=['/usr/share/locale/zh/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/zh_Hant/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/es_ES/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/zh_TW/LC_MESSAGES/goodvibes.mo']), + get_tested_mock_package(files=['/usr/share/locale/pt_BR/LC_MESSAGES/goodvibes.mo']), +]) +def test_i18n_valid_lang(package, output, test): + test.check(package) + out = output.print_results(output.results) + assert 'E: invalid-lc-messages-dir' not in out diff --git a/tools/generate-isocodes.py b/tools/generate-isocodes.py index 4d84bd764..3ccc9aea3 100755 --- a/tools/generate-isocodes.py +++ b/tools/generate-isocodes.py @@ -14,6 +14,7 @@ iso_3166_1_url = os.environ.get('ISO_3166_1_URL', 'https://salsa.debian.org/iso-codes-team/iso-codes/raw/main/data/iso_3166-1.json') iso_639_3_url = os.environ.get('ISO_639_3_URL', 'https://salsa.debian.org/iso-codes-team/iso-codes/raw/main/data/iso_639-3.json') iso_639_2_url = os.environ.get('ISO_639_2_URL', 'https://salsa.debian.org/iso-codes-team/iso-codes/raw/main/data/iso_639-2.json') +iso_15924_url = os.environ.get('ISO_15924_URL', 'https://salsa.debian.org/iso-codes-team/iso-codes/raw/main/data/iso_15924.json') langs = set() countries = set() @@ -36,6 +37,11 @@ entry_code = entry.get('alpha_2') or entry['alpha_3'] if entry_code not in langs: langs.add(entry_code) +# ISO 15924, Codes for the representation of names of scripts +with urlopen(iso_15924_url) as f: + data = json.load(codecs.getreader('utf-8')(f)) + for entry in data['15924']: + countries.add(entry['alpha_4']) print(f'# Generated with {sys.argv[0]}') print('')