mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/language-data.git
synced 2025-10-04 15:12:29 +08:00
26 lines
622 B
Python
Executable file
26 lines
622 B
Python
Executable file
#! /usr/bin/env python3
|
|
|
|
import json
|
|
|
|
names = {}
|
|
|
|
|
|
def add_name(item):
|
|
if "alpha_2" not in item:
|
|
return
|
|
if "alpha_3" in item:
|
|
names[item["alpha_3"]] = item["alpha_2"]
|
|
if "bibliographic" in item:
|
|
names[item["bibliographic"]] = item["alpha_2"]
|
|
|
|
|
|
with open("/usr/share/iso-codes/json/iso_639-2.json", "r") as handle:
|
|
for item in json.load(handle)["639-2"]:
|
|
add_name(item)
|
|
|
|
with open("/usr/share/iso-codes/json/iso_639-3.json", "r") as handle:
|
|
for item in json.load(handle)["639-3"]:
|
|
add_name(item)
|
|
|
|
for row in sorted(names.items()):
|
|
print("{};{}".format(*row))
|