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

Make language names unique #149

Merged
merged 8 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/gflanguages/data/languages/bdh_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
id: "bdh_Latn"
language: "bdh"
script: "Latn"
name: "Baka"
name: "Baka (DRC/South Sudan)"
autonym: "Tara Baká"
population: 60000
region: "CD"
region: "SS"
exemplar_chars {
base: "a A b B c C d D e E f F g G h H i I ị Ị ɨ Ɨ k K l L m M n N ṇ Ṇ o O p P r R ṛ Ṛ s S t T u U ụ Ụ v V ṿ Ṿ w W y Y z Z ꞌ Ꞌ"
marks: "◌̣ ◌́"
}
}
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/beh_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
id: "beh_Latn"
language: "beh"
script: "Latn"
name: "Baka"
name: "Biali"
population: 100000
region: "BJ"
exemplar_chars {
base: "a A b B c C d D e E ə Ə f F g G h H i I k K l L m M n N o O p P r R s S t T u U w W y Y"
auxiliary: "j J q Q v V x X z Z"
}
}
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/bgn_Arab.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ id: "bgn_Arab"
language: "bgn"
script: "Arab"
name: "Western Balochi"
preferred_name: "Balochi"
#preferred_name: "Balochi"
population: 2037382
region: "AF"
region: "IR"
Expand Down
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/bkc_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id: "bkc_Latn"
language: "bkc"
script: "Latn"
name: "Baka"
name: "Baka (Cameroon/Gabon)"
population: 71000
region: "CM"
region: "GA"
exemplar_chars {
base: "a A b B ɓ Ɓ d D ɗ Ɗ e E ɛ Ɛ f F g G h H i I j J k K l L m M n N o O ɔ Ɔ s S t T u U w W y Y"
auxiliary: "c C p P q Q r R v V x X z Z"
}
}
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/bsc_Latn_GN.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "bsc_Latn_GN"
language: "bsc"
script: "Latn"
name: "Bassari"
name: "Guinean Bassari"
autonym: "oneyan"
population: 18000
region: "GN"
Expand Down
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/bsq_Bass.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "bsq_Bass"
language: "bsq"
script: "Bass"
name: "Bassa"
name: "Bassa, Vah"
population: 410000
region: "LR"
region: "SL"
Expand Down
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/bsq_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "bsq_Latn"
language: "bsq"
script: "Latn"
name: "Bassa"
name: "Bassa, Latin"
population: 410000
region: "LR"
region: "SL"
Expand All @@ -11,4 +11,4 @@ exemplar_chars {
auxiliary: "l L q Q r R x X y Y z Z"
}
source: "“Bassa dictionary”, Christian Education Foundation in Liberia (CEFL), https://cefliberia.org/bassa/bassa-dictionary/"
source: "Ɓǎsɔ́ɔ̀ Báɓòɔ̀, Bible Society Liberia, 2002"
source: "Ɓǎsɔ́ɔ̀ Báɓòɔ̀, Bible Society Liberia, 2002"
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/crh_Cyrl.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "crh_Cyrl"
language: "crh"
script: "Cyrl"
name: "Crimean Turkish"
name: "Crimean Turkish, Cyrillic"
autonym: "Къырымтатар"
population: 245968
region: "UA"
Expand Down
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/dnj_Latn_LR.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "dnj_Latn_LR"
language: "dnj"
script: "Latn"
name: "Dan"
name: "Liberian Dan"
autonym: "Gio"
population: 1099244
region: "LR"
Expand Down
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/evn_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "evn_Latn"
language: "evn"
script: "Latn"
name: "Evenki"
name: "Evenki, Latin"
population: 16000
region: "RU"
region: "CN"
Expand Down
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/kr_Arab.textproto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id: "kr_Arab"
language: "kr"
script: "Arab"
name: "Kanuri"
name: "Kanuri, Arabic"
11 changes: 0 additions & 11 deletions Lib/gflanguages/data/languages/mlt_Latn.textproto

This file was deleted.

2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/sa_Nand.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: "sa_Nand"
language: "sa"
script: "Nand"
name: "Sanskrit"
name: "Sanskrit, Nandinagari"
autonym: "𑧍𑧞𑧍𑧠𑦮𑧖𑦽𑧆𑧠"
region: "IN"
exemplar_chars {
Expand Down
1 change: 1 addition & 0 deletions Lib/gflanguages/data/languages/uma_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
id: "uma_Latn"
language: "uma"
script: "Latn"
name: "Umatilla"
population: 25
Expand Down
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/wal_Ethi.textproto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id: "wal_Ethi"
language: "wal"
script: "Ethi"
name: "Wolaytta"
name: "Wolaytta, Ethiopic"
population: 1946034
region: "ET"
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/wal_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
id: "wal_Latn"
language: "wal"
script: "Latn"
name: "Wolaytta"
name: "Wolaytta, Latin"
population: 7000000
region: "ET"
exemplar_chars {
base: "a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z"
}
}
2 changes: 1 addition & 1 deletion Lib/gflanguages/data/languages/xsm_Latn_BF.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "xsm_Latn_BF"
language: "xsm"
script: "Latn"
name: "Kasem"
name: "Burkinabè Kasem"
population: 250000
region: "BF"
exemplar_chars {
Expand Down
15 changes: 15 additions & 0 deletions tests/test_data_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,18 @@ def test_exemplar_parser():
"l",
"̍",
}


def test_language_uniqueness():
names = Counter([])
for lang in LANGUAGES.values():
# We check that names are unique *within a script* since
# when we display them in a menu we segment that menu by
# script and then by language
if lang.preferred_name:
names[lang.script + "/" + lang.preferred_name] += 1
else:
names[lang.name + "/" + lang.preferred_name] += 1
if any(count > 1 for count in names.values()):
duplicates = {name: count for name, count in names.items() if count > 1}
pytest.fail(f"Duplicate language names: {duplicates}")

Choose a reason for hiding this comment

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

Nit: much nicer to read sorted

11 changes: 9 additions & 2 deletions tests/test_parsable.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@


languages_dir = os.path.join(DATA_DIR, "languages")
textproto_files = [os.path.basename(x) for x in glob.iglob(os.path.join(languages_dir, "*.textproto"))]
textproto_files = [
os.path.basename(x) for x in glob.iglob(os.path.join(languages_dir, "*.textproto"))
]


@pytest.mark.parametrize("lang_code", textproto_files)
def test_parsable(lang_code):
with open(os.path.join(languages_dir, lang_code), "r", encoding="utf-8") as f:
text_format.Parse(f.read(), languages_public_pb2.LanguageProto())
msg = text_format.Parse(f.read(), languages_public_pb2.LanguageProto())
assert msg.id
assert msg.language
assert msg.script
assert msg.population is not None