Skip to content

Commit

Permalink
Merge pull request #156 from googlefonts/duplicate-ids
Browse files Browse the repository at this point in the history
Assert uniqueness of all IDs
  • Loading branch information
simoncozens authored Aug 26, 2024
2 parents 136e32b + a0e70c0 commit 62f135e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Lib/gflanguages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def LoadLanguages(base_dir=DATA_DIR):
for textproto_file in glob.iglob(os.path.join(languages_dir, "*.textproto")):
with open(textproto_file, "r", encoding="utf-8") as f:
language = text_format.Parse(f.read(), languages_public_pb2.LanguageProto())
assert language.id not in langs, f"Duplicate language id: {language.id}"
langs[language.id] = language
return langs

Expand All @@ -57,6 +58,7 @@ def LoadScripts(base_dir=DATA_DIR):
for textproto_file in glob.iglob(os.path.join(scripts_dir, "*.textproto")):
with open(textproto_file, "r", encoding="utf-8") as f:
script = text_format.Parse(f.read(), languages_public_pb2.ScriptProto())
assert script.id not in scripts, f"Duplicate script id: {script.id}"
scripts[script.id] = script
return scripts

Expand All @@ -70,6 +72,7 @@ def LoadRegions(base_dir=DATA_DIR):
for textproto_file in glob.iglob(os.path.join(regions_dir, "*.textproto")):
with open(textproto_file, "r", encoding="utf-8") as f:
region = text_format.Parse(f.read(), languages_public_pb2.RegionProto())
assert region.id not in regions, f"Duplicate region id: {region.id}"
regions[region.id] = region
return regions

Expand Down
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/mam_Latn_MX.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "mam_Latn"
id: "mam_Latn_MX"
language: "mam"
script: "Latn"
name: "Mam"
name: "Mexican Mam"
region: "MX"
exemplar_chars {
base: "a A {bꞌ} {BꞋ} {ch} {CH} {chꞌ} {CHꞋ} d D e E g G i I j J k K {kꞌ} {KꞋ} {ky} {KY} {kyꞌ} {KYꞋ} l L m M n N o O p P q Q {qꞌ} {QꞋ} r R s S t T {tꞌ} {TꞋ} {ts} {TS} {tsꞌ} {TSꞋ} {tx} {TX} {txꞌ} {TXꞋ} u U w W x X {xh} {XH} y Y ꞌ Ꞌ"
Expand Down
4 changes: 2 additions & 2 deletions Lib/gflanguages/data/languages/xsl_Latn.textproto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id: "scs_Latn"
language: "scs"
id: "xsl_Latn"
language: "xsl"
script: "Latn"
name: "South Slavey"
population: 950
Expand Down
6 changes: 3 additions & 3 deletions Lib/gflanguages/data/languages/yo_Latn_BJ.textproto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id: "yo_Latn"
id: "yo_Latn_BJ"
language: "yo"
script: "Latn"
name: "Yoruba"
name: "Yoruba, Benin"
autonym: "Èdè Yorùbá"
population: 200000
region: "BJ"
Expand All @@ -27,4 +27,4 @@ sample_text {
specimen_16: "Ɛnì kɔ̀ɔ̀kan ló ní ɛ̀tɔ́ kpé kí a má shàdédé she àyɔjúràn sí ɔ̀rɔ̀ ìgbésí ayé rɛ̀, tàbí sí ɔ̀rɔ̀ɛbí rɛ̀ tàbí sí ɔ̀rɔ̀ ìdílé rɛ̀ tàbí ìwé tí a kɔ sí i; a kò sì gbɔdɔ̀ ba iyì àti orúkɔ rɛ̀ jɛ́. Ɛnì kɔ̀ɔ̀kan ló ní ɛ̀tɔ́ sí ààbò lábɛ́ òfin kúrò lɔ́wɔ́ irú àyɔjúràn tàbí ìbanijɛ́ bɛ́ɛ̀.\nƐnì kɔ̀ɔ̀kan ló ní ɛ̀tɔ́ sí òmìnira èrò, òmìnira ɛ̀rí-ɔkàn àti òmìnira ɛ sìn. Ɛtɔ́ yìí sì gbani láàyè láti kpààrɔ̀ ɛ sìn tàbí ìgbàgbɔ́ ɛni. Ó sì fún ɛyɔ ɛnì kan tàbí àkójɔkpɔ̀ ènìyàn láàyè láti she ɛ̀sìn wɔn àti ìgbàgbɔ́ wɔn bó she jɛ mɔ́ ti ìkɔ́ni, ìshesí, ìjɔ́sìn àti ìmúshe ohun tí wɔ́n gbàgbɔ́ yálà ní ìkɔ̀kɔ̀ tàbí ní gban̄gba.\nƐnì kɔ̀ɔ̀kan ló ní ɛ̀tɔ́ sí ìsinmi àti fàájì kpɛ̀lú àkókò tí kò kpɔ̀ jù lɛ́nu ishɛ́ àti àsìkò ìsinmi lɛ́nu ishɛ́ láti ìgbà dé ìgbà tí a ó sanwó fún."
}
source: "Centre national de linguistique appliquée (CENALA), Alphabet des langues nationales béninoises, Cotonou: CENALA avec le concours de l’Initiative francophone pour la formation à distance des maîtres (IFADEM), 2008, 6th ed."
note: "Yoruba (Benin) uses ɛ ɔ kp sh instead of Yoruba (Nigeria) ẹ ọ p ṣ."
note: "Yoruba (Benin) uses ɛ ɔ kp sh instead of Yoruba (Nigeria) ẹ ọ p ṣ."

0 comments on commit 62f135e

Please sign in to comment.