File tree Expand file tree Collapse file tree 3 files changed +34
-3
lines changed
Expand file tree Collapse file tree 3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -482,6 +482,8 @@ el_RO,4174
482482el_TR , 4037
483483el_UA , 7132
484484en , 1728473503
485+ en_150 , 279594417
486+ en_419 , 49092422
485487en_AC , 930
486488en_AE , 5016100
487489en_AG , 88265
@@ -639,6 +641,8 @@ en_ZW,7203168
639641eo , 298
640642eo_SM , 298
641643es , 507599381
644+ es_150 , 69107258
645+ es_419 , 363966079
642646es_AD , 36709
643647es_AR , 46994400
644648es_BO , 7510320
Original file line number Diff line number Diff line change 66
77import json
88from collections import defaultdict
9+ from collections .abc import Generator
910
1011MAPPING = {
1112 "zh" : "zh_Hans" ,
1213 "pa_Arab" : "pa" ,
1314}
15+ REGIONS : list [str ] = [
16+ "150" ,
17+ "419" ,
18+ ]
19+ REGION_LANGUAGES : set [str ] = {"en" , "es" }
20+
21+ with open (
22+ "modules/cldr-json/cldr-json/cldr-core/supplemental/territoryContainment.json" ,
23+ ) as handle :
24+ CONTAINMENT = json .load (handle )["supplemental" ]["territoryContainment" ]
25+
26+
27+ def get_region_countries (text : str ) -> Generator [str ]:
28+ for code in CONTAINMENT [text ]["_contains" ]:
29+ if code .isdigit ():
30+ yield from get_region_countries (code )
31+ else :
32+ yield code
33+
34+
35+ REGION_COUNTRIES : dict [str , str ] = {}
36+ for code in REGIONS :
37+ for country in get_region_countries (code ):
38+ REGION_COUNTRIES [country ] = code
1439
1540with open (
1641 "modules/cldr-json/cldr-json/cldr-core/supplemental/territoryInfo.json" ,
2651 factor = float (data ["_populationPercent" ]) / 100
2752 languages [language ] += population * factor
2853 languages [f"{ language } _{ code } " ] += population * factor
54+ if code in REGION_COUNTRIES and language in REGION_LANGUAGES :
55+ languages [f"{ language } _{ REGION_COUNTRIES [code ]} " ] += population * factor
2956
3057with open ("population.csv" , "w" ) as handle :
3158 handle .write ("code,population\n " )
Original file line number Diff line number Diff line change 195195 "elx" : 0 ,
196196 "en" : 1728473503 ,
197197 "en@pirate" : 1728473503 ,
198- "en_150" : 0 ,
198+ "en_150" : 279594417 ,
199199 "en_AU" : 25697856 ,
200200 "en_CA" : 33751476 ,
201201 "en_GB" : 67089918 ,
215215 "es" : 507599381 ,
216216 "es@formal" : 507599381 ,
217217 "es@informal" : 507599381 ,
218- "es_150" : 0 ,
219- "es_419" : 0 ,
218+ "es_150" : 69107258 ,
219+ "es_419" : 363966079 ,
220220 "es_AR" : 46994400 ,
221221 "es_BO" : 7510320 ,
222222 "es_CL" : 18291406 ,
You can’t perform that action at this time.
0 commit comments