transifex_translators.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env python3
  2. import json
  3. import os
  4. # Download Transifex languages dump at: https://www.transifex.com/api/2/project/keepassxc/languages
  5. # Language information from https://www.wikiwand.com/en/List_of_ISO_639-1_codes and http://www.lingoes.net/en/translator/langcode.htm
  6. LANGS = {
  7. "ar" : "العربية (Arabic)",
  8. "bn" : "বাংলা (Bengali)",
  9. "ca" : "català (Catalan)",
  10. "cs" : "čeština (Czech)",
  11. "da" : "dansk (Danish)",
  12. "de" : "Deutsch (German)",
  13. "el" : "ελληνικά (Greek)",
  14. "eo" : "Esperanto (Esperanto)",
  15. "es" : "Español (Spanish)",
  16. "et" : "eesti (Estonian)",
  17. "eu" : "euskara (Basque)",
  18. "fa" : "فارسی (Farsi)",
  19. "fa_IR" : "فارسی (Farsi (Iran))",
  20. "fi" : "suomi (Finnish)",
  21. "fr" : "français (French)",
  22. "gl" : "Galego (Galician)",
  23. "he" : "עברית (Hebrew)",
  24. "hr_HR" : "hrvatski jezik (Croatian)",
  25. "hu" : "magyar (Hungarian)",
  26. "id" : "Bahasa Indonesia (Indonesian)",
  27. "is_IS" : "Íslenska (Icelandic)",
  28. "it" : "Italiano (Italian)",
  29. "ja" : "日本語 (Japanese)",
  30. "kk" : "қазақ тілі (Kazakh)",
  31. "ko" : "한국어 (Korean)",
  32. "la" : "latine (Latin)",
  33. "lt" : "lietuvių kalba (Lithuanian)",
  34. "lv" : "latviešu valoda (Latvian)",
  35. "nb" : "Norsk Bokmål (Norwegian Bokmål)",
  36. "nl_NL" : "Nederlands (Dutch)",
  37. "my" : "ဗမာစာ (Burmese)",
  38. "pa" : "ਪੰਜਾਬੀ (Punjabi)",
  39. "pa_IN" : "ਪੰਜਾਬੀ (Punjabi (India))",
  40. "pl" : "język polski (Polish)",
  41. "pt" : "Português (Portuguese)",
  42. "pt_BR" : "Português (Portuguese (Brazil))",
  43. "pt_PT" : "Português (Portuguese (Portugal))",
  44. "ro" : "Română (Romanian)",
  45. "ru" : "русский (Russian)",
  46. "sk" : "Slovenčina (Slovak)",
  47. "sl_SI" : "Slovenščina (Slovenian)",
  48. "sr" : "српски језик (Serbian)",
  49. "sv" : "Svenska (Swedish)",
  50. "th" : "ไทย (Thai)",
  51. "tr" : "Türkçe (Turkish)",
  52. "uk" : "Українська (Ukrainian)",
  53. "zh_CN" : "中文 (Chinese (Simplified))",
  54. "zh_TW" : "中文 (台灣) (Chinese (Traditional))",
  55. }
  56. TEMPLATE = "<li><strong>{0}</strong>: {1}</li>\n"
  57. if not os.path.exists("languages.json"):
  58. print("Could not find 'languages.json' in current directory!")
  59. print("Save the output from https://www.transifex.com/api/2/project/keepassxc/languages")
  60. exit(0)
  61. with open("languages.json") as json_file:
  62. output = open("translators.html", "w", encoding="utf-8")
  63. languages = json.load(json_file)
  64. for lang in languages:
  65. code = lang["language_code"]
  66. if code not in LANGS:
  67. print("WARNING: Could not find language code:", code)
  68. continue
  69. translators = ", ".join(sorted(lang["reviewers"] + lang["translators"], key=str.casefold))
  70. output.write(TEMPLATE.format(LANGS[code], translators))
  71. output.close()
  72. print("Language translators written to 'translators.html'!")