Browse Source

transifex -> fastlane converter

tobiaskaminsky 7 years ago
parent
commit
98876c6b05

+ 1 - 0
fastlane/metadata/android/en-US/title.txt

@@ -0,0 +1 @@
+Nextcloud

+ 4 - 0
lint.xml

@@ -4,4 +4,8 @@
         <ignore path="**/freemarker-2.3.23.jar"/>
         <ignore path="**/nnio-0.2.jar"/>
     </issue>
+    
+    <issue id="UnusedResources">
+        <ignore regexp="store_short_desc|store_full_desc" />
+    </issue>
 </lint>

+ 122 - 0
scripts/metadata/generate_metadata.py

@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+
+# Author: Torsten Grote
+# License: GPLv3 or later
+# copied on 2017/11/06 from https://github.com/grote/Transportr/blob/master/fastlane/generate_metadata.py
+# adapted by Tobias Kaminsky
+
+import os
+import shutil
+import codecs
+from xml.etree import ElementTree
+
+
+XML_PATH = '../../src/main/res'
+METADATA_PATH = '../../fastlane/metadata/android'
+DEFAULT_LANG = 'en-US'
+LANG_MAP = {
+    'values': 'en-US',
+    'values-en-rGB': 'en-GB',
+    'values-ca': 'ca',
+    'values-cs': 'cs-CZ',
+    'values-de': 'de-DE',
+    'values-es': 'es-ES',
+    'values-fr': 'fr-FR',
+    'values-hu': 'hu-HU',
+    'values-it': 'it-IT',
+    'values-pt-rBR': 'pt-BR',
+    'values-pt-rPT': 'pt-PT',
+    'values-ta': 'ta-IN',
+    'values-sv': 'sv-SE',
+    'values-sq-rAL': 'sq-AL',
+    'values-sq-rMK': 'sq-MK', 
+    'values-iw-rIL': 'iw-IL', 
+    'values-ar': 'ar-AR', 
+    'values-bg-rBG': 'bg-BG', 
+    'values-da': 'da-DK', 
+    'values-fi-rFI': 'fi-FI', 
+    'values-gl-rES': 'gl-ES', 
+    'values-tr': 'tr-TR', 
+    'values-uk': 'uk-UK', 
+    'values-vi': 'vi-VI', 
+    'values-ro': 'ro-RO', 
+    'values-ou': 'ru-RU', 
+    'values-sr': 'sr-SR', 
+    'values-pl': 'pl-PL', 
+    'values-el': 'el-GR', 
+    'values-ko': 'ko-KR', 
+    'values-nl': 'nl-NL', 
+    'values-ja': 'ja-JP', 
+    'values-no-rNO': 'no-NO', 
+    'values-eu': 'eu-ES', 
+    'values-lt-rLT': 'lt-LT', 
+    'values-zh-rKN': 'zh-HK', 
+    'values-zk': 'zk-CN', 
+    'values-is': 'is-IS', 
+    'values-id': 'id-ID', 
+    'values-cs-rCZ': 'cs-CZ', 
+    'values-sl': 'sl-SL', 
+    'values-fa': 'fa-FA'
+}
+
+PATH = os.path.dirname(os.path.realpath(__file__))
+
+
+def main():
+    path = os.path.join(PATH, XML_PATH)
+    for entry in os.listdir(path):
+        directory = os.path.join(path, entry)
+        if not os.path.isdir(directory) or entry not in LANG_MAP.keys():
+            continue
+        strings_file = os.path.join(directory, 'strings.xml')
+        if not os.path.isfile(strings_file):
+            print("Error: %s does not exist" % strings_file)
+            continue
+
+        print()
+        print(LANG_MAP[entry])
+        print("Parsing %s..." % strings_file)
+        e = ElementTree.parse(strings_file).getroot()
+        short_desc = e.find('.//string[@name="store_short_desc"]')
+        full_desc = e.find('.//string[@name="store_full_desc"]')
+        if short_desc is None or full_desc is None:
+            print("Warning: Skipping %s because of incomplete translation" % entry)
+            continue
+        save_file(short_desc.text, LANG_MAP[entry], 'short_description.txt')
+        save_file(full_desc.text, LANG_MAP[entry], 'full_description.txt')
+
+
+def save_file(text, directory, filename):
+    directory_path = os.path.join(PATH, METADATA_PATH, directory)
+    if not os.path.exists(directory_path):
+        os.makedirs(directory_path)
+    if filename == 'short_description.txt':
+        limit = 80
+    else:
+        limit = 0
+    text = clean_text(text, limit)
+    check_title(directory_path)
+    file_path = os.path.join(directory_path, filename)
+    print("Writing %s..." % file_path)
+    with codecs.open(file_path, 'w', 'utf-8') as f:
+        f.write(text)
+
+
+def clean_text(text, limit=0):
+    text = text.replace('\\\'', '\'')
+    if limit != 0 and len(text) > limit:
+        print("Warning: Short Description longer than 80 characters, truncating...")
+        text = text[:limit]
+    return text
+
+
+def check_title(directory):
+    title_path = os.path.join(directory, 'title.txt')
+    if os.path.exists(title_path):
+        return
+    default_title_path = os.path.join(directory, '..', DEFAULT_LANG, 'title.txt')
+    shutil.copy(default_title_path, title_path)
+
+
+if __name__ == "__main__":
+    main()

+ 2 - 0
src/main/res/values/strings.xml

@@ -709,4 +709,6 @@
     <string name="push_notifications_old_login">No push notifications due to outdated login session. Please consider re-adding your account.</string>
     <string name="push_notifications_temp_error">Push notifications currently not available.</string>
     <string name="date_unknown">Unknown</string>
+    <string name="store_short_desc">The Nextcloud Android app allows you to access all your files on your Nextcloud</string>
+    <string name="store_full_desc">The Open Source Nextcloud Android app allows you to access all your files on your Nextcloud.\n\nFeatures:\n* Easy, modern interface, fully themed in alignment with your server\'s theming\n* Upload your files to your Nextcloud server\n* Share your files with others\n* Keep your favorite files and folders synced\n* Search across all folders on your server\n* Auto Upload for photos and videos taken by your device\n* Keep up to date with notifications\n* Multi-account support\n* Secure access to your data with fingerprint or pin\n* Integration with DAVdroid for easy setup of Calendar &amp; Contacts synchronization\n\nPlease report all issues at https://github.com/nextcloud/android/issues and discuss this app at https://help.nextcloud.com/c/clients/android\n\nNew to Nextcloud? Nextcloud is a private file sync &amp; share and communication server. It is fully open source and you can host it yourself or pay a company to do it for you. That way, you are in control of your photos, your calendar and contact data, your documents and everything else.\n\nCheck out Nextcloud at https://nextcloud.com</string>
 </resources>