Skip to content

Commit

Permalink
Merge pull request #1125 from rpm-software-management/iso-15924
Browse files Browse the repository at this point in the history
Add iso_15924 to LANGUAGES
  • Loading branch information
danigm authored Oct 16, 2023
2 parents ecdde27 + 847c199 commit 78f5077
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 1 deletion.
184 changes: 183 additions & 1 deletion rpmlint/__isocodes__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7996,6 +7996,15 @@
'AW',
'AX',
'AZ',
'Adlm',
'Afak',
'Aghb',
'Ahom',
'Arab',
'Aran',
'Armi',
'Armn',
'Avst',
'BA',
'BB',
'BD',
Expand All @@ -8017,6 +8026,18 @@
'BW',
'BY',
'BZ',
'Bali',
'Bamu',
'Bass',
'Batk',
'Beng',
'Bhks',
'Blis',
'Bopo',
'Brah',
'Brai',
'Bugi',
'Buhd',
'CA',
'CC',
'CD',
Expand All @@ -8036,19 +8057,37 @@
'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',
'EH',
'ER',
'ES',
'ET',
'Egyd',
'Egyh',
'Egyp',
'Elba',
'Ethi',
'FI',
'FJ',
'FK',
Expand All @@ -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',
Expand All @@ -8090,10 +8150,16 @@
'IR',
'IS',
'IT',
'Inds',
'Ital',
'JE',
'JM',
'JO',
'JP',
'Jamo',
'Java',
'Jpan',
'Jurc',
'KE',
'KG',
'KH',
Expand All @@ -8105,6 +8171,17 @@
'KW',
'KY',
'KZ',
'Kali',
'Kana',
'Khar',
'Khmr',
'Khoj',
'Kitl',
'Kits',
'Knda',
'Kore',
'Kpel',
'Kthi',
'LA',
'LB',
'LC',
Expand All @@ -8116,6 +8193,20 @@
'LU',
'LV',
'LY',
'Lana',
'Laoo',
'Latf',
'Latg',
'Latn',
'Leke',
'Lepc',
'Limb',
'Lina',
'Linb',
'Lisu',
'Loma',
'Lyci',
'Lydi',
'MA',
'MC',
'MD',
Expand All @@ -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',
Expand All @@ -8151,7 +8258,19 @@
'NR',
'NU',
'NZ',
'Narb',
'Nbat',
'Newa',
'Nkgb',
'Nkoo',
'Nshu',
'OM',
'Ogam',
'Olck',
'Orkh',
'Orya',
'Osge',
'Osma',
'PA',
'PE',
'PF',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -8209,23 +8361,53 @@
'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',
'VG',
'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'}
49 changes: 49 additions & 0 deletions test/test_i18n.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tools/generate-isocodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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('')
Expand Down

0 comments on commit 78f5077

Please sign in to comment.