summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2023-07-08 18:35:19 -0300
committerJesusaves <cpntb1@ymail.com>2023-07-08 18:35:19 -0300
commitd3e9eda493341c6a7816c5f9c3cf96e086c4a292 (patch)
treef756a658ddfeba0f89435ba06bf8d21e52995ff2
parent69e64f9c925dd68a0016f1a54d6500ffb3886f69 (diff)
downloadrenpy-d3e9eda493341c6a7816c5f9c3cf96e086c4a292.tar.gz
renpy-d3e9eda493341c6a7816c5f9c3cf96e086c4a292.tar.bz2
renpy-d3e9eda493341c6a7816c5f9c3cf96e086c4a292.tar.xz
renpy-d3e9eda493341c6a7816c5f9c3cf96e086c4a292.zip
Update translation script
-rw-r--r--.gitignore1
-rwxr-xr-xgame/tl/fetch.py59
2 files changed, 34 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 46b5d9e..80b8a6b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,7 @@ Mana-Launcher.exe
steam_appid.txt
**/login.txt
**/password.txt
+**/token.txt
# Logs
log.txt
diff --git a/game/tl/fetch.py b/game/tl/fetch.py
index ad1a6ae..46d17d8 100755
--- a/game/tl/fetch.py
+++ b/game/tl/fetch.py
@@ -1,42 +1,49 @@
-#! /usr/bin/env python2.7
+#! /usr/bin/env python3
# -*- coding: utf8 -*-
#
# Copyright (C) 2018 TMW-2
-# Author: Jesusalva
+# Author: Jesusalva, ntsneto
-from transifex.api import TransifexAPI
+from transifex.api import transifex_api
+import requests
-project='moubootaur-legends'
+TTL={"English": "en", "Portuguese (Brazil)": "pt_BR", "French": "fr", "German": "de", "Spanish": "es", "Russian": "ru", "Italian": "it"}
-# Load credentials from login.txt and password.txt
-login=open('login.txt', 'r')
-for i in login:
- username=i.replace('\n', '').replace('\r', '')
+# Load API Token from apy_token_transifex.txt. You can generate one at https://www.transifex.com/user/settings/api/.
-login.close()
+with open("token.txt", "r") as f:
+ token = f.read()
+ token = str(token).replace('\n','')
-passw=open('password.txt', 'r')
-for i in passw:
- password=i.replace('\n', '').replace('\r', '')
+transifex_api.setup(auth=token)
-passw.close()
+organization_name = "arctic-games"
+project_name = "moubootaur-legends"
+resource_name = "mana-launcher"
-t=TransifexAPI(username, password, 'https://www.transifex.com')
+organization = transifex_api.Organization.get(slug=organization_name)
-if (not t.ping):
- print("ERROR: Ping failed, this may be due incorrect username/password in login.txt and password.txt. Ensure there is NO newline at the end of file.")
- exit(1)
+print(f"Getting project details from organization {organization_name}")
+project = organization.fetch("projects").get(slug=project_name)
-if (not t.project_exists(project)):
- print("ERROR: Invalid project name")
- exit(1)
-
-# Load languages
-langs=["pt_BR", "de", "fr", "es", "it"]
+print(f"Getting resource {resource_name} from project {project_name}")
+resource = project.fetch("resources").get(slug=resource_name)
# Fetch all translations and record them at in/
-for i in langs:
- print("Fetching %s..." %(i))
- t.get_translation(project, 'mana-launcher', i, '../../../Translation Toolkit/out/'+str(i)+'.po')
+
+print(f"Getting languages from project {project_name}")
+languages = project.fetch("languages")
+for lang in languages:
+ url = transifex_api.ResourceTranslationsAsyncDownload.download(resource=resource, language=lang)
+ translated_content = requests.get(url).text
+ print(f"Fetching {lang.name}")
+ try:
+ code = TTL[lang.name]
+ except:
+ print(f"{lang.name} is unsupported, SKIPPED")
+ continue
+ with open(f"../../../Translation Toolkit/out/{code}.po", "w", encoding="UTF-8") as f:
+ print(translated_content, file=f)
+