diff --git a/intl/.gitignore b/intl/.gitignore index d69d1a4252..1d6146afdd 100644 --- a/intl/.gitignore +++ b/intl/.gitignore @@ -1,2 +1,3 @@ *.json - +crowdin.yaml +crowdin.yml diff --git a/intl/README.md b/intl/README.md index 6398376d25..13721d9ad7 100644 --- a/intl/README.md +++ b/intl/README.md @@ -15,3 +15,9 @@ - No performance impact. - Don't require translators to know how to use Git, how to read C code and how to create Pull Request. - Translators will be informed whenever a source string changes. + +## Cron job setup + +1. [Install crowdin cli tool](https://support.crowdin.com/cli-tool/) +2. Get the `intl/crowdin.yaml` file from someone who have crowdin admin accounts +3. Add cron job `cd path/to/retroarch/intl && ./crowin_sync.sh` diff --git a/intl/crowdin_sync.sh b/intl/crowdin_sync.sh new file mode 100755 index 0000000000..084834bb3a --- /dev/null +++ b/intl/crowdin_sync.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Update source code +git pull + +# Convert source *.h to *.json +./h2json.py msg_hash_us.h + +# Upload source file +crowdin upload sources + +# Crowdin need some time to process data +sleep 1m + +# Download translation files +crowdin download translations + +# Convert translation *.json to *.h +for f in *.json +do + ./json2h.py $f +done + +# Commit new translations +git add . +git commit -m "Synchronize translations" +git push diff --git a/intl/json2h.py b/intl/json2h.py index 511e1c37b0..1b4ea13372 100755 --- a/intl/json2h.py +++ b/intl/json2h.py @@ -14,16 +14,11 @@ except IndexError: print("Usage: ./template.py ") sys.exit(1) -p = re.compile('MSG_HASH\(\s*[A-Z0-9_]+,\s*\".*\"\s*\)') +if json_filename == 'msg_hash_us.json': + print("Skip") + sys.exit(0) -header = """#if defined(_MSC_VER) && !defined(_XBOX) && (_MSC_VER >= 1500 && _MSC_VER < 1900) -#if (_MSC_VER >= 1700) -/* https://support.microsoft.com/en-us/kb/980263 */ -#pragma execution_character_set("utf-8") -#endif -#pragma warning(disable:4566) -#endif -""" +p = re.compile('MSG_HASH\(\s*[A-Z0-9_]+,\s*\".*\"\s*\)') def parse_message(message): @@ -53,7 +48,7 @@ def parse_messages(text): def update(messages, template): - new_translation = header + template + new_translation = template template_messages = parse_messages(template) for tp_msg in template_messages: if tp_msg['key'] in messages: diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 8d3a823808..8587804495 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1,3 +1,11 @@ +#if defined(_MSC_VER) && !defined(_XBOX) && (_MSC_VER >= 1500 && _MSC_VER < 1900) +#if (_MSC_VER >= 1700) +/* https://support.microsoft.com/en-us/kb/980263 */ +#pragma execution_character_set("utf-8") +#endif +#pragma warning(disable:4566) +#endif + #ifdef HAVE_LAKKA_SWITCH MSG_HASH( MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE,