Browse Source

.po files translated for languages : ar , az , bn , de , es , fa , fr , ha , id , ky , ru , sw , tg , tr , ur , uz and zh_HAns

master
Mohsen Taba 2 months ago
parent
commit
d84f98b037
  1. 12
      config/settings/base.py
  2. 2075
      locale/ar/LC_MESSAGES/django.po
  3. 2046
      locale/az/LC_MESSAGES/django.po
  4. 2050
      locale/bn/LC_MESSAGES/django.po
  5. 2113
      locale/de/LC_MESSAGES/django.po
  6. 1026
      locale/de/LC_MESSAGES/django_de.json
  7. 2115
      locale/es/LC_MESSAGES/django.po
  8. 1
      locale/es/LC_MESSAGES/django_es.json
  9. 2084
      locale/fa/LC_MESSAGES/django.po
  10. 1
      locale/fa/LC_MESSAGES/django_fa.json
  11. 2112
      locale/fr/LC_MESSAGES/django.po
  12. 1
      locale/fr/LC_MESSAGES/django_fr.json
  13. 2115
      locale/ha/LC_MESSAGES/django.po
  14. 1026
      locale/ha/LC_MESSAGES/django_ha.json
  15. 2116
      locale/id/LC_MESSAGES/django.po
  16. 1026
      locale/id/LC_MESSAGES/django_id.json
  17. 2048
      locale/ky/LC_MESSAGES/django.po
  18. 2051
      locale/sw/LC_MESSAGES/django.po
  19. 2051
      locale/tg/LC_MESSAGES/django.po
  20. 2053
      locale/tr/LC_MESSAGES/django.po
  21. 2051
      locale/ur/LC_MESSAGES/django.po
  22. 2048
      locale/uz/LC_MESSAGES/django.po
  23. 2046
      locale/zh_HAns/LC_MESSAGES/django.po
  24. 72
      scripts/apply_translations.py
  25. 49
      scripts/extract_untranslated.py
  26. 1042
      scripts/translate_es.py

12
config/settings/base.py

@ -205,6 +205,18 @@ THUMBNAIL_ALIASES = {
} }
import django.conf.locale
from django.conf.locale import LANG_INFO
# Register Hausa (ha) in Django's LANG_INFO since it's not natively supported
LANG_INFO.update({
'ha': {
'bidi': False,
'code': 'ha',
'name': 'Hausa',
'name_local': 'Hausa',
}
})
LANGUAGES = [ LANGUAGES = [
('ar', _('Arabic')), ('ar', _('Arabic')),

2075
locale/ar/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2046
locale/az/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2050
locale/bn/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2113
locale/de/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1026
locale/de/LC_MESSAGES/django_de.json
File diff suppressed because it is too large
View File

2115
locale/es/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1
locale/es/LC_MESSAGES/django_es.json
File diff suppressed because it is too large
View File

2084
locale/fa/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1
locale/fa/LC_MESSAGES/django_fa.json
File diff suppressed because it is too large
View File

2112
locale/fr/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1
locale/fr/LC_MESSAGES/django_fr.json
File diff suppressed because it is too large
View File

2115
locale/ha/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1026
locale/ha/LC_MESSAGES/django_ha.json
File diff suppressed because it is too large
View File

2116
locale/id/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

1026
locale/id/LC_MESSAGES/django_id.json
File diff suppressed because it is too large
View File

2048
locale/ky/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2051
locale/sw/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2051
locale/tg/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2053
locale/tr/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2051
locale/ur/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2048
locale/uz/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

2046
locale/zh_HAns/LC_MESSAGES/django.po
File diff suppressed because it is too large
View File

72
scripts/apply_translations.py

@ -0,0 +1,72 @@
import os
import sys
import json
import polib
def apply_translations(po_path, json_path):
if not os.path.exists(po_path):
print(f"Error: PO file not found: {po_path}")
return False
if not os.path.exists(json_path):
print(f"Error: JSON translation file not found: {json_path}")
return False
print(f"Loading PO file: {po_path}")
po = polib.pofile(po_path)
print(f"Loading JSON translations: {json_path}")
with open(json_path, 'r', encoding='utf-8') as f:
translations = json.load(f)
applied_count = 0
for entry in po:
if not entry.translated() or entry.fuzzy:
updated = False
# Handle plural entries
if entry.msgid_plural:
# Singular part (index 0)
if entry.msgid in translations:
val = translations[entry.msgid]
if val and val.strip():
entry.msgstr_plural[0] = val
updated = True
# Plural part (index 1, and higher indices if present)
if entry.msgid_plural in translations:
val = translations[entry.msgid_plural]
if val and val.strip():
for plural_index in entry.msgstr_plural.keys():
if plural_index > 0:
entry.msgstr_plural[plural_index] = val
updated = True
else:
# Simple entry
if entry.msgid in translations:
val = translations[entry.msgid]
if val and val.strip():
entry.msgstr = val
updated = True
# Clean fuzzy flag if successfully updated
if updated:
if 'fuzzy' in entry.flags:
entry.flags.remove('fuzzy')
applied_count += 1
print(f"Applied {applied_count} translations to PO entry items.")
# Save the updated PO file
po.save()
print(f"Saved updated PO file to {po_path}")
return True
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: python apply_translations.py <po_path> <input_json_path>")
sys.exit(1)
po_file = sys.argv[1]
json_file = sys.argv[2]
apply_translations(po_file, json_file)

49
scripts/extract_untranslated.py

@ -0,0 +1,49 @@
import os
import sys
import json
import polib
def extract_untranslated(po_path, json_path):
if not os.path.exists(po_path):
print(f"Error: File not found: {po_path}")
return False
print(f"Loading PO file: {po_path}")
po = polib.pofile(po_path)
untranslated_data = {}
for entry in po:
if not entry.translated() or entry.fuzzy:
# If it has a plural, extract both msgid and msgid_plural
if entry.msgid_plural:
if entry.msgid not in untranslated_data:
untranslated_data[entry.msgid] = ""
if entry.msgid_plural not in untranslated_data:
untranslated_data[entry.msgid_plural] = ""
else:
if entry.msgid not in untranslated_data:
untranslated_data[entry.msgid] = ""
total_keys = len(untranslated_data)
print(f"Extracted {total_keys} unique untranslated/fuzzy keys.")
# Ensure output directory exists
out_dir = os.path.dirname(json_path)
if out_dir and not os.path.exists(out_dir):
os.makedirs(out_dir)
with open(json_path, 'w', encoding='utf-8') as f:
json.dump(untranslated_data, f, ensure_ascii=False)
print(f"Saved JSON template to {json_path}")
return True
if __name__ == "__main__":
if len(sys.argv) < 3:
print("Usage: python extract_untranslated.py <po_path> <output_json_path>")
sys.exit(1)
po_file = sys.argv[1]
json_file = sys.argv[2]
extract_untranslated(po_file, json_file)

1042
scripts/translate_es.py
File diff suppressed because it is too large
View File

Loading…
Cancel
Save