Skip to content

Commit

Permalink
Squashed 'app/src/main/assets/i18n/' changes from 700a3ce..1e07813
Browse files Browse the repository at this point in the history
1e07813 Merge pull request scribe-org#42 from angrezichatterbox/XML-TO-JSON-FIX
2a8fe2a fix:Added escape characters for \n
924f00c scribe-org#37 minor edits to conversion scripts and try new command path
aafa0f6 scribe-org#37 update Scribe-i18n structure and fix conversion workflow
6a8faaa Merge pull request scribe-org#39 from Jag-Marcel/i18n-refactor
2b9caff Added newline at end of all JSON files
e775e46 Updated jsons and xcstrings file using new iOS scripts
dd018c1 Refactored iOS conversion scripts to use python json package
7f8c273 Updated conversion workflow to use paths filter instead of conditional check
ff21cdb Refactored scripts into new iOS and Android folders

git-subtree-dir: app/src/main/assets/i18n
git-subtree-split: 1e07813b694edc57934b46ec76943cc1e974d4fb
  • Loading branch information
andrewtavis committed Aug 27, 2024
1 parent f5714f3 commit 5d5b9b5
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 396 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/json_conversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: json_conversion.yml

on:
push:
branches:
- main
paths:
- "Scribe-i18n/jsons/**.json"

jobs:
# Run JSON to app strings conversion scripts if needed.
convert_json:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Execute script to convert JSON to string files
run: |
python Scribe-i18n/scripts/android/convert_jsons_to_strings.py
python Scribe-i18n/scripts/ios/convert_jsons_to_xcstrings.py
41 changes: 0 additions & 41 deletions .github/workflows/xcstrings_conversion.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ If all looks good, then you're ready to start adding localizable key-string pair
### File Conversion
The files in the [Scribe-i18n/Scripts](https://github.com/scribe-org/Scribe-i18n/tree/main/Scribe-i18n/Scripts) directory can be used to convert base localization JSON files into the filetypes that are needed for an application as well as the same in reverse. JSON files are automatically converted to their target files for Scribe applications after commits to the main branch, and their opposites can be used to update the JSON files when strings are first changed in the applications.
The files in the [Scribe-i18n/scripts](https://github.com/scribe-org/Scribe-i18n/tree/main/Scribe-i18n/scripts) directory can be used to convert base localization JSON files into the filetypes that are needed for an application as well as the same in reverse. JSON files are automatically converted to their target files for Scribe applications after commits to the main branch, and their opposites can be used to update the JSON files when strings are first changed in the applications.
### Adding Scribe-i18n to Projects [`⇧`](#contents)
Expand Down
3 changes: 2 additions & 1 deletion Scribe-i18n/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,8 @@
"state" : "",
"value" : "Du kan skapa ett konto på wikidata.org för att gå med i communityn som stöder Scribe och så många andra projekt. Hjälp oss att ge gratis information till världen!"
}
} }
}
}
}
},
"version" : "1.0"
Expand Down
57 changes: 0 additions & 57 deletions Scribe-i18n/Scripts/convert_jsons_to_xcstrings.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions Scribe-i18n/fr.json → Scribe-i18n/jsons/fr.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"_global.english": "",
"_global.french": "",
"_global.german": "",
"_global.italian": "",
"_global.portuguese": "",
"_global.russian": "",
"_global.spanish": "",
"_global.swedish": "",
"app.about.appHint": "",
"app.about.appHints": "",
"app.about.bugReport": "",
"app.about.community": "",
"app.about.email": "",
"app.about.feedback": "",
"app.about.github": "",
"app.about.legal": "",
"app.about.mastodon": "",
"app.about.matrix": "",
"app.about.privacyPolicy": "",
"app.about.privacyPolicy.body": "",
Expand All @@ -33,12 +36,14 @@
"app.about.wikimedia.text2": "",
"app.about.wikimedia.text3": "",
"app.install": "",
"app.installation.appHint": "",
"app.installation.settingsLink": "",
"app.installation.text1": "",
"app.installation.text2": "",
"app.installation.text3": "",
"app.installation.title": "",
"app.keyboards": "",
"app.settings.appHint": "",
"app.settings.appSettings": "",
"app.settings.appSettings.appLanguage": "",
"app.settings.functionality": "",
Expand All @@ -50,7 +55,12 @@
"app.settings.layout.disableAccentCharacters.description": "",
"app.settings.layout.periodAndComma": "",
"app.settings.layout.periodAndComma.description": "",
"app.settings.oneDeviceLanguage.message": "",
"app.settings.oneDeviceLanguage.title": "",
"app.settings.title": "",
"app.settings.translation": "",
"app.settings.translation.translateLang": "",
"app.settings.translation.translateLang.caption": "",
"app.wikidataExplanation1": "",
"app.wikidataExplanation2": "",
"app.wikidataExplanation3": ""
Expand Down
10 changes: 10 additions & 0 deletions Scribe-i18n/pt.json → Scribe-i18n/jsons/pt.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"_global.english": "",
"_global.french": "",
"_global.german": "",
"_global.italian": "",
"_global.portuguese": "",
"_global.russian": "",
"_global.spanish": "",
"_global.swedish": "",
"app.about.appHint": "",
"app.about.appHints": "",
"app.about.bugReport": "",
"app.about.community": "",
"app.about.email": "",
"app.about.feedback": "",
"app.about.github": "",
"app.about.legal": "",
"app.about.mastodon": "",
"app.about.matrix": "",
"app.about.privacyPolicy": "",
"app.about.privacyPolicy.body": "",
Expand All @@ -33,12 +36,14 @@
"app.about.wikimedia.text2": "",
"app.about.wikimedia.text3": "",
"app.install": "",
"app.installation.appHint": "",
"app.installation.settingsLink": "",
"app.installation.text1": "",
"app.installation.text2": "",
"app.installation.text3": "",
"app.installation.title": "",
"app.keyboards": "",
"app.settings.appHint": "",
"app.settings.appSettings": "",
"app.settings.appSettings.appLanguage": "",
"app.settings.functionality": "",
Expand All @@ -50,7 +55,12 @@
"app.settings.layout.disableAccentCharacters.description": "",
"app.settings.layout.periodAndComma": "",
"app.settings.layout.periodAndComma.description": "",
"app.settings.oneDeviceLanguage.message": "",
"app.settings.oneDeviceLanguage.title": "",
"app.settings.title": "",
"app.settings.translation": "",
"app.settings.translation.translateLang": "",
"app.settings.translation.translateLang.caption": "",
"app.wikidataExplanation1": "",
"app.wikidataExplanation2": "",
"app.wikidataExplanation3": ""
Expand Down
10 changes: 10 additions & 0 deletions Scribe-i18n/ru.json → Scribe-i18n/jsons/ru.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"_global.english": "",
"_global.french": "",
"_global.german": "",
"_global.italian": "",
"_global.portuguese": "",
"_global.russian": "",
"_global.spanish": "",
"_global.swedish": "",
"app.about.appHint": "",
"app.about.appHints": "",
"app.about.bugReport": "",
"app.about.community": "",
"app.about.email": "",
"app.about.feedback": "",
"app.about.github": "",
"app.about.legal": "",
"app.about.mastodon": "",
"app.about.matrix": "",
"app.about.privacyPolicy": "",
"app.about.privacyPolicy.body": "",
Expand All @@ -33,12 +36,14 @@
"app.about.wikimedia.text2": "",
"app.about.wikimedia.text3": "",
"app.install": "",
"app.installation.appHint": "",
"app.installation.settingsLink": "",
"app.installation.text1": "",
"app.installation.text2": "",
"app.installation.text3": "",
"app.installation.title": "",
"app.keyboards": "",
"app.settings.appHint": "",
"app.settings.appSettings": "",
"app.settings.appSettings.appLanguage": "",
"app.settings.functionality": "",
Expand All @@ -50,7 +55,12 @@
"app.settings.layout.disableAccentCharacters.description": "",
"app.settings.layout.periodAndComma": "",
"app.settings.layout.periodAndComma.description": "",
"app.settings.oneDeviceLanguage.message": "",
"app.settings.oneDeviceLanguage.title": "",
"app.settings.title": "",
"app.settings.translation": "",
"app.settings.translation.translateLang": "",
"app.settings.translation.translateLang.caption": "",
"app.wikidataExplanation1": "",
"app.wikidataExplanation2": "",
"app.wikidataExplanation3": ""
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
Converts from Scribe-i18n localization JSON files to the Strings files.
Converts from Scribe-i18n localization JSON files to string.xml files.
Usage:
python3 Scribe-i18n/Scripts/convert_jsons_to_strings.py
python3 Scribe-i18n/scripts/android/convert_jsons_to_strings.py
"""

import os
import json

Expand All @@ -13,26 +14,28 @@ def replace_special_characters(string):
string = string.replace("&", "&")
string = string.replace("<", "&lt;")
string = string.replace(">", "&gt;")
string = string.replace("\n", "\\n")
return string

directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dir_list = os.listdir(directory)

directory = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
json_dir_list = os.listdir(os.path.join(directory, "jsons"))
languages = sorted(
[file.replace(".json", "") for file in dir_list if file.endswith(".json")]
[file.replace(".json", "") for file in json_dir_list if file.endswith(".json")]
)
values_directory = os.path.join(directory, 'values')
values_directory = os.path.join(directory, "values")
os.makedirs(values_directory, exist_ok=True)

for lang in languages:
lang_dir = os.path.join(values_directory, lang)
os.makedirs(lang_dir, exist_ok=True)

xml_path = os.path.join(lang_dir,"string.xml")
xml_path = os.path.join(lang_dir, "string.xml")
with open(xml_path, "w") as xml_file:
xml_file.write('<?xml version="1.0" encoding="utf-8"?>\n')
xml_file.write('<resources>\n')
xml_file.write("<resources>\n")

json_path = os.path.join(directory, f"{lang}.json")
json_path = os.path.join(os.path.join(directory, "jsons"), f"{lang}.json")
with open(json_path, "r") as json_file:
json_data = json_file.read()
json_data = json.loads(json_data)
Expand All @@ -41,8 +44,6 @@ def replace_special_characters(string):
value = replace_special_characters(value)
xml_file.write(f' <string name="{key}">{value}</string>\n')

xml_file.write('</resources>\n')
xml_file.write("</resources>\n")

print(
"Scribe-i18n localization JSON files successfully converted to the strings file."
)
print("Scribe-i18n localization JSON files successfully converted to the strings file.")
Loading

0 comments on commit 5d5b9b5

Please sign in to comment.