Skip to content

Translations prefix scripts #807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 68 additions & 68 deletions auth/src/main/res/values-b+es+419/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-bg/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-bn/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ca/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-cs/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-da/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-de-rAT/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-de-rCH/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-de/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-el/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rAU/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rCA/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rGB/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rIE/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rIN/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rSG/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-en-rZA/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rAR/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rBO/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rCL/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rCO/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rCR/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rDO/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rEC/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rGT/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rHN/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rMX/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rNI/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rPA/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rPE/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rPR/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rPY/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rSV/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rUS/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rUY/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es-rVE/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-es/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-fa/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-fi/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-fil/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-fr-rCH/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-fr/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-gsw/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-gu/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-hi/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-hr/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-hu/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-in/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-it/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ja/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-kn/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ko/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ln/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-lt/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-lv/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-mo/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-mr/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ms/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-nb/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-nl/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-no/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-pl/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-pt-rBR/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-pt-rPT/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-pt/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ro/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ru/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-sk/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-sl/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-sr/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-sv/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ta/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-th/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-tl/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-tr/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-uk/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-ur/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-vi/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-zh-rCN/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-zh-rHK/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-zh-rTW/strings.xml

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions auth/src/main/res/values-zh/strings.xml

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions scripts/translations/add_string_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding=UTF-8

import os
import re
import sys

from base_string_script import BaseStringScript

PREFIXED_NAME_START = 'name="fui_'
UNPREFIXED_NAME_START = 'name="'

class AddStringPrefixScript(BaseStringScript):

def ProcessTag(self, line):
joined = '\n'.join(line)

if (UNPREFIXED_NAME_START in joined) and (PREFIXED_NAME_START not in joined):
joined = joined.replace(UNPREFIXED_NAME_START, PREFIXED_NAME_START)
return joined.split('\n')
else:
return line

if __name__ == '__main__':
for file_name in sys.argv[1:]:
asps = AddStringPrefixScript()
asps.ProcessFile(file_name)

25 changes: 24 additions & 1 deletion scripts/translations/base_string_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@
class BaseStringScript:

def ProcessTag(self, line):
"""
Process a single string tag.

:param line: an array of lines making a single string tag.
:return: an array of lines representing the processed tag.
"""
return line

def ProcessFile(self, file_name):
"""
Process and write a file of string resources.

:param file_name: path to the file to process.
:return: None.
"""
lines = []

in_tag = False
Expand All @@ -39,5 +51,16 @@ def ProcessFile(self, file_name):
lines += self.ProcessTag(curr_tag)
curr_tag = []

# Write back to the file
self.WriteFile(file_name, '\n'.join(lines))

def WriteFile(self, file_name, file_contents):
"""
Overwrite the contents of a file.

:param file_name: path to the file to write.
:param file_contents: string containing new file contents.
:return: None
"""
with open(file_name, 'w') as myfile:
myfile.write('\n'.join(lines))
myfile.write(file_contents)
5 changes: 5 additions & 0 deletions scripts/translations/clean_up_translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ do

# Remove non-translatable strings
python $DIR/remove_non_translatable.py $file

# Fix typography
python $DIR/fix_typography.py $file

# Add fui_ prefix
python $DIR/add_string_prefix.py $file
done
29 changes: 29 additions & 0 deletions scripts/translations/export_translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding=UTF-8

import os
import re
import sys

from base_string_script import BaseStringScript

PREFIXED_NAME_START = 'name="fui_'
UNPREFIXED_NAME_START = 'name="'

class ExportTranslationsScript(BaseStringScript):

def ProcessTag(self, line):
joined = '\n'.join(line)

if PREFIXED_NAME_START in joined:
joined = joined.replace(PREFIXED_NAME_START, UNPREFIXED_NAME_START)
return joined.split('\n')
else:
return line

def WriteFile(self, file_name, file_contents):
# Override to just print the contents
print file_contents

if __name__ == '__main__':
ets = ExportTranslationsScript()
ets.ProcessFile('auth/src/main/res/values/strings.xml')