| 1 |
#! /usr/bin/python3 |
| 2 |
|
| 3 |
from typing import Set |
| 4 |
import os |
| 5 |
import sys |
| 6 |
import re |
| 7 |
import glob |
| 8 |
|
| 9 |
# pylint: disable=wrong-import-order |
| 10 |
sys.path.insert(0, "/local/mfabian/src/langtable") |
| 11 |
# pylint: disable=import-error |
| 12 |
import langtable # type: ignore |
| 13 |
# pylint: enable=import-error |
| 14 |
sys.path.pop(0) |
| 15 |
# pylint: enable=wrong-import-order |
| 16 |
|
| 17 |
CLDR_SOURCE_DIR = '/local/mfabian/src/cldr' |
| 18 |
ALL_LANGUAGES = langtable.list_all_languages() |
| 19 |
ALL_SCRIPTS = langtable.list_all_scripts() |
| 20 |
ALL_TERRITORIES = langtable.list_all_territories() |
| 21 |
MISSING_LANGUAGES: Set[str] = set() |
| 22 |
MISSING_SCRIPTS: Set[str] = set() |
| 23 |
MISSING_TERRITORIES: Set[str] = set() |
| 24 |
|
| 25 |
for cldr_file in sorted(glob.glob( |
| 26 |
os.path.join(CLDR_SOURCE_DIR, 'common/main', '*.xml'))): |
| 27 |
cldr_locale_id = cldr_file.split('/')[-1].split('.')[0] |
| 28 |
locale = langtable.parse_locale(cldr_locale_id) |
| 29 |
#print(f'id={cldr_locale_id} language={locale.language} script={locale.script} territory={locale.territory} variant={locale.variant}') |
| 30 |
if locale.language and locale.language not in ALL_LANGUAGES: |
| 31 |
MISSING_LANGUAGES.add(locale.language) |
| 32 |
if locale.script and locale.script not in ALL_SCRIPTS: |
| 33 |
MISSING_SCRIPTS.add(locale.script) |
| 34 |
if locale.territory and locale.territory not in ALL_TERRITORIES: |
| 35 |
MISSING_TERRITORIES.add(locale.territory) |
| 36 |
|
| 37 |
print(f'{langtable.info()}') |
| 38 |
print(f'Missing languages: {sorted(MISSING_LANGUAGES)}') |
| 39 |
print(f'Missing scripts: {sorted(MISSING_SCRIPTS)}') |
| 40 |
print(f'Missing territories: {sorted(MISSING_TERRITORIES)}') |
| 41 |
|
| 42 |
|