Update Strings #1056
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Strings | |
on: | |
schedule: | |
- cron: "0 7 * * 1,4" # Run Mon-Thu at 7AM UTC | |
workflow_dispatch: | |
inputs: | |
type: | |
description: Type of update (standard, nofile, matchid) | |
required: true | |
default: "standard" | |
branch: | |
description: Branch of mozilla-vpn-client | |
required: true | |
default: "main" | |
jobs: | |
extract: | |
name: Extract strings | |
runs-on: ubuntu-latest | |
env: | |
QTVERSION: 6.2.4 | |
steps: | |
- name: Clone l10n repository | |
uses: actions/checkout@v4 | |
with: | |
path: translationFiles | |
- name: Install Qt | |
run: | | |
python3 -m pip install aqtinstall | |
python3 -m aqt list-qt linux desktop | |
python3 -m aqt install-qt -O /opt linux desktop $QTVERSION | |
- name: Clone main code repository | |
uses: actions/checkout@v4 | |
with: | |
repository: mozilla-mobile/mozilla-vpn-client | |
fetch-depth: 0 | |
path: vpn | |
- name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Python dependencies | |
run: | | |
pip install -r translationFiles/.github/scripts/requirements.txt | |
- name: Store ENV variables | |
id: env-variables | |
run: | | |
vpn_branch=${{ github.event.inputs.branch || 'main' }} | |
echo "vpn_branch=${vpn_branch}" >> $GITHUB_OUTPUT | |
if [ "${vpn_branch}" = "main" ]; then | |
echo "automation_branch=l10n_automation" >> $GITHUB_OUTPUT | |
else | |
echo "automation_branch=l10n_automation_${vpn_branch}" >> $GITHUB_OUTPUT | |
fi | |
- name: Extract new strings | |
run: | | |
# Manually add QT executables to path | |
export PATH=/opt/$QTVERSION/gcc_64/bin:$PATH | |
vpn_branch=${{ steps.env-variables.outputs.vpn_branch }} | |
# Check out different branch if specified | |
if [ "${vpn_branch}" != "main" ]; then | |
echo "Checking out branch: ${vpn_branch}" | |
(cd vpn && git checkout ${vpn_branch}) | |
fi | |
# Extract strings for default and release branches | |
(cd vpn && ./scripts/utils/generate_ts.sh) | |
# File is called translations_vpn.ts in 2.15 to 2.16, but translations.ts | |
# in more recent versions. | |
if [ -f "vpn/translations_vpn.ts" ]; then | |
ts_file="translations_vpn.ts" | |
else | |
ts_file="translations.ts" | |
fi | |
mv vpn/${ts_file} ./translations.ts | |
# Convert main strings to XLIFF | |
python translationFiles/.github/scripts/extract_source_strings.py --input translations.ts --output translationFiles/en/mozillavpn.xliff | |
# Convert addon strings to XLIFF | |
addon_files="vpn/addon_ts/*.ts" | |
# Remove the addons folder and recreate it, to remove obsolete addons | |
rm -rf translationFiles/en/addons/ | |
for f in $addon_files | |
do | |
addon_name=$(basename "$f" .ts) | |
echo "Extracting strings for addon: ${addon_name}.ts" | |
mkdir -p "translationFiles/en/addons/${addon_name}" | |
python translationFiles/.github/scripts/extract_source_strings.py --input "vpn/addon_ts/${addon_name}.ts" --output "translationFiles/en/addons/${addon_name}/strings.xliff" | |
done | |
# Update other locales | |
python translationFiles/.github/scripts/update_other_locales.py --reference en --path translationFiles/ --type "${{ github.event.inputs.type }}" | |
# Remove obsolete XLIFF files | |
python translationFiles/.github/scripts/remove_obsolete_files.py --reference en --path translationFiles/ | |
- uses: peter-evans/create-pull-request@v4 | |
with: | |
path: translationFiles | |
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> | |
commit-message: Extract new strings and update all locales | |
branch: ${{ steps.env-variables.outputs.automation_branch }} | |
delete-branch: true | |
title: Extract new strings |