Skip to content

Commit 517be95

Browse files
committed
feat: allow to export english only strings for QA
1 parent 075cea5 commit 517be95

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

.github/workflows/check_for_crowdin_updates.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,30 @@ jobs:
133133
overwrite: true
134134
if-no-files-found: warn
135135
retention-days: 7
136-
# It's easier to find what went wrong with some strings if we can get the files from the artefact upload step above.
137-
# The job will still be marked as failed and no Pull Requests will be made.
138-
- name: Prepare QA strings
136+
137+
build_qa:
138+
name: Build QA strings
139+
needs: [fetch_translations]
140+
runs-on: ubuntu-latest
141+
steps:
142+
- name: Checkout Repo Content
143+
uses: actions/checkout@v4
144+
with:
145+
path: 'scripts'
146+
# don't provide a branch (ref) so it uses the default for that event
147+
- name: Setup shared
148+
uses: ./scripts/actions/setup_shared
149+
150+
- name: Checkout Desktop
151+
uses: ./scripts/actions/checkout_desktop
152+
153+
- name: Export QA Strings (json)
154+
run: |
155+
python "${{ github.workspace }}/scripts/crowdin/generate_desktop_strings.py" --qa_build \
156+
"${{ github.workspace }}/raw_translations" \
157+
"${{ github.workspace }}/desktop/_locales" \
158+
"${{ github.workspace }}/desktop/ts/localization/constants.ts"
159+
- name: Prepare QA strings (ts)
139160
run: |
140161
cd ${{ github.workspace }}/desktop/
141162
python ./tools/localization/generateLocales.py --generate-types --print-problems --print-problem-strings --print-problem-formatting-tag-strings --error-on-problems

crowdin/generate_desktop_strings.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
# Parse command-line arguments
3131
parser = argparse.ArgumentParser(description='Convert a XLIFF translation files to JSON.')
32+
parser.add_argument('--qa_build', help='Set to true to output only English strings (only used for QA)', action=argparse.BooleanOptionalAction)
3233
parser.add_argument('raw_translations_directory', help='Directory which contains the raw translation files')
3334
parser.add_argument('translations_output_directory', help='Directory to save the converted translation files')
3435
parser.add_argument('non_translatable_strings_output_path', help='Path to save the non-translatable strings to')
@@ -37,6 +38,7 @@
3738
INPUT_DIRECTORY = args.raw_translations_directory
3839
TRANSLATIONS_OUTPUT_DIRECTORY = args.translations_output_directory
3940
NON_TRANSLATABLE_STRINGS_OUTPUT_PATH = args.non_translatable_strings_output_path
41+
IS_QA_BUILD = args.qa_build
4042

4143

4244
def parse_xliff(file_path):
@@ -140,7 +142,7 @@ def convert_non_translatable_strings_to_type_script(input_file: str, output_path
140142
file.write('\n')
141143

142144

143-
def convert_all_files(input_directory: str):
145+
def convert_all_files(input_directory: str, is_qa_build: bool):
144146
setup_values = setup_generation(input_directory)
145147
source_language, rtl_languages, non_translatable_strings_file, target_languages = setup_values.values()
146148

@@ -149,7 +151,7 @@ def convert_all_files(input_directory: str):
149151
exported_locales = []
150152
glossary_dict = load_glossary_dict(non_translatable_strings_file)
151153

152-
for language in [source_language] + target_languages:
154+
for language in [source_language] + [] if is_qa_build else target_languages:
153155
lang_locale = language['locale']
154156
lang_two_letter_code = language['twoLettersCode']
155157
print(f"\033[2K{Fore.WHITE}⏳ Converting translations for {lang_locale} to target format...{Style.RESET_ALL}", end='\r')
@@ -166,7 +168,7 @@ def convert_all_files(input_directory: str):
166168

167169
if __name__ == "__main__":
168170
try:
169-
convert_all_files(INPUT_DIRECTORY)
171+
convert_all_files(INPUT_DIRECTORY, IS_QA_BUILD)
170172
except KeyboardInterrupt:
171173
print("\nProcess interrupted by user")
172174
sys.exit(0)

0 commit comments

Comments
 (0)