summaryrefslogtreecommitdiff
path: root/web/fetch.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-10-23 23:45:19 -0300
committerJesusaves <cpntb1@ymail.com>2022-10-23 23:45:19 -0300
commitc2ccb14ffff0e45398365e19dfd2874307ddb943 (patch)
tree976eaea586fb8f1ee0ab8cae67c69071aed8b952 /web/fetch.py
downloadtools-c2ccb14ffff0e45398365e19dfd2874307ddb943.tar.gz
tools-c2ccb14ffff0e45398365e19dfd2874307ddb943.tar.bz2
tools-c2ccb14ffff0e45398365e19dfd2874307ddb943.tar.xz
tools-c2ccb14ffff0e45398365e19dfd2874307ddb943.zip
Initial commit
Diffstat (limited to 'web/fetch.py')
-rwxr-xr-xweb/fetch.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/web/fetch.py b/web/fetch.py
new file mode 100755
index 0000000..c5fbeea
--- /dev/null
+++ b/web/fetch.py
@@ -0,0 +1,62 @@
+#! /usr/bin/env python2.7
+# -*- coding: utf8 -*-
+#
+# Copyright (C) 2018 TMW-2
+# Author: Jesusalva
+
+from transifex.api import TransifexAPI
+#import sys
+
+#if len(sys.argv) == 2:
+# if sys.argv[1] == "AllFilesVerified":
+# pass
+# else:
+# print("Rejected: Incorrect magic word.")
+# exit(1)
+#else:
+# print("Rejected: As this script is VULNERABLE TO CODE INJECTION, you cannot run this command without verifying all files at Transifex first.")
+# exit(1)
+print("\033[1mThis script is VULNERABLE TO CODE INJECTION. Git diff before deploying!\033[0m")
+
+project='moubootaur-legends'
+
+print("Loading user credentials (login.txt/password.txt) from lang/ folder...")
+
+# Load credentials from login.txt and password.txt
+login=open('../lang/login.txt', 'r')
+for i in login:
+ username=i.replace('\n', '').replace('\r', '')
+
+login.close()
+
+passw=open('../lang/password.txt', 'r')
+for i in passw:
+ password=i.replace('\n', '').replace('\r', '')
+
+passw.close()
+
+t=TransifexAPI(username, password, 'https://www.transifex.com')
+
+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)
+
+if (not t.project_exists(project)):
+ print("ERROR: Invalid project name")
+ exit(1)
+
+# Load languages
+langs=[]
+vcx=open("langs.txt", "r")
+for i in vcx:
+ if i != "en":
+ langs.append(i.replace('\n', ''))
+vcx.close()
+
+# Fetch all translations and record them at in/
+for i in langs:
+ print("Fetching %s..." %(i))
+ t.get_translation(project, 'website', i, 'po/'+str(i)+'.po')
+
+print("All translations were retrieved.")
+print("Please sanitize files removing \"\\n\", or updatelang.py won't parse properly.")