mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-02 06:26:10 -04:00
Start making UseBridgeWidget, and add json files that list country names for each enabled locale
This commit is contained in:
parent
f8ef7d3ac2
commit
20dd579e59
21 changed files with 165 additions and 2 deletions
42
desktop/scripts/update-country-list.py
Executable file
42
desktop/scripts/update-country-list.py
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import tempfile
|
||||
import subprocess
|
||||
import json
|
||||
|
||||
import onionshare_cli
|
||||
|
||||
|
||||
def main():
|
||||
# Clone the country-list repo
|
||||
tmp_dir = tempfile.TemporaryDirectory()
|
||||
subprocess.run(
|
||||
["git", "clone", "https://github.com/umpirsky/country-list.git"],
|
||||
cwd=tmp_dir.name,
|
||||
)
|
||||
repo_dir = os.path.join(tmp_dir.name, "country-list")
|
||||
|
||||
# Get the list of enabled languages
|
||||
common = onionshare_cli.common.Common()
|
||||
settings = onionshare_cli.settings.Settings(common)
|
||||
available_locales = list(settings.available_locales)
|
||||
|
||||
# Make a dictionary that makes a language's ISO 3166-1 to its name in all enabled languages
|
||||
os.makedirs(
|
||||
os.path.join("src", "onionshare", "resources", "countries"), exist_ok=True
|
||||
)
|
||||
for locale in available_locales:
|
||||
with open(os.path.join(repo_dir, "data", locale, "country.json")) as f:
|
||||
countries = json.loads(f.read())
|
||||
|
||||
with open(
|
||||
os.path.join(
|
||||
"src", "onionshare", "resources", "countries", f"{locale}.json"
|
||||
),
|
||||
"w",
|
||||
) as f:
|
||||
f.write(json.dumps(countries))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue