Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

String Import Export

Stefan Arentz edited this page Feb 1, 2022 · 5 revisions

Focus iOS String Import / Export

This page explains the process of importing and exporting strings.

Introduction

There are two independent processes related to localized strings:

  • String Import - Takes strings from pontoon and imports them into the project. This runs daily as an automated task through a GitHub Action.
  • String Export - To exports new strings from the app to the https://github.com/mozilla-l10n/focusios-l10n repository. This is a manual process that generates a Pull Request.

Two scripts in the repository facilitate these processes:

See below how these are used.

String Import

On a fixed daily schedule, the focus-ios/.github/workflows/import-strings.yml GitHub Workflow runs to import strings.

This script will do the following:

  • Check out the focus-ios project
  • Run the tools/import-strings.sh script
  • If any string files changed (Blockzilla/*/*.lproj/* Blockzilla/*.lproj/*), create a Pull Request with those changes

When the Pull Request is created, CI will build it as usual. If there are no errors, the PR is automatically merged. This is done through a Mergify rule in .mergify.yml.

This process requires very little manual attention. We trust the strings coming from Pontoon, so a review is typically not needed. If the PR fails to build there may be another issue that needs to be looked at. It could be a regular intermittent build failure or in a very rare case possibly a string issue.

Since these PRs are created daily, it is also fine to simply close a problematic one, fix issues in either Pontoon or the project, and then wait for the next string import to run.

String Export

When new strings are introduced in the application, by adding them to Blockzilla/UIConstants.swift, these strings need to be exposed to Pontoon where the localization community can translate them.

Exporting the strings is a manual process that involves running the tools/export-strings.sh script. Simply run this script from the command line and it will do the following things:

  • Check out a copy of the https://github.com/mozilla-l10n/focusios-l10n repository
  • Run xcodebuild -exportLocalizations with the right options to export strings for all locales enabled in the app
  • Move the generated XLIFF files into the focusios-l10n checkout

Once completed, you can create a pull request as follows:

% cd focusios-l10n

# Take a look at what changed with git status / git diff
% git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   af/focus-ios.xliff
	modified:   an/focus-ios.xliff
	modified:   ar/focus-ios.xliff
        ... etc ...

# Create a new branch for this export
% git checkout -b string-export-2022-02-01

# Commit all the changes
% git commit -a -m "String Export 2022-02-01"

# Push the branch to GitHub
% git push --set-upstream origin string-export-2022-02-01

With the final git push you will be presented a URL to create the Pull Request. Or visit github.com/mozilla-l10n/focusios-l10n and create the PR from there from the branch just pushed.

This Pull Request needs a review by the l10n team before it can be merged. This can be coordinated on Slack.

Note that you need to be added as a contributor to the github.com/mozilla-l10n/focusios-l10n repository.