The basics

Lokalise

The catalog of localized strings is located in the Banno Production project in Lokalise. Strings are typically added to the catalog by the design team as features are being designed. There are a few exceptions and each of the teams has a member with a licensed account to make those changes.

TextCatalog

The strings are published for each team to the TextCatalog repository. This repository has the strings files for each team in a preferred file format, and the git actions to retrieve additions, updates and deletions from the Lokalise catalog.

banno-ios

Within the banno-ios repository clone there is a package at: Local Packages/Localization. This contains the english and spanish localized strings, plurals, Localized+ToDo and swiftgen files used to deliver translated strings.

SwiftGen is a code generator for string and image resources in iOS projects. The Swiftgen repository and documentation can be found at Swiftgen repository. Swiftgen generates our Strings+Generated.swift file from the raw text and dictionary files. Swiftgen converts the string keys from snake case to camel case, identifies any duplicate keys, and generates the static variables and parametrized functions used to access the localized strings in application code.

Basic usage

Using the strings

  • Adding localized strings starts with adding import Localization to the source file.
  • Then the localized strings are referenced via static properties on the Localized type. Example: Localized.rapidTransfer
import Localization

title = Localized.rapidTransfer

NOTE: The names used for our keynames are inconsistent and often poor. This can make finding the string needed tedious. As the strings are a shared resource accross the mobile teams it’s difficult to change them. Recently the pattern is to use the full text of the string as the key. Searching the english Localizable.strings for the string needed is often the quicker way to find the keyname.

Adding a missing string

If the string is not found after searching the local strings files, it can be added to the Localized+ToDo.swift file in the Localization package.

The new string will be available as a static property on the Localized.ToDo type.

import Localization

title = Localized.ToDo.needToMoveMoneyGetStartedNow

Updating localization strings from the lokalise catalog

TextCatalog

SHORTCUT Use the Direct link and skip to step 3.

  1. To update strings from the lokalise catalog the first step is to open the TextCatalog repository on GitHub. There is no need to clone the repository locally.
  2. Navigate to the workflows: .github/workflows and select update-ios-from-lokalise.yml
  3. Choose View Runs and select the Run workflow item, then press Run workflow button (the main branch should be selected already).
  4. The action will run and will return successful if there were new strings available to pull from Lokalise. This will also create a PR in TextCatalog to update the iOS Strings file.
  5. Navigate to the new PR. It will have a name like Update text assets<Date-Time> and the files changed will be iOS strings files. Validate and approve the PR, these are the strings files that will now be used to update the banno-ios strings.

banno-ios

  1. Create a new feature branch based off of the develop branch in the banno-ios repository.
  2. The contents of the English and/or Spanish files from TextCatalog are added to the localization package by copying the changed strings or the entire contents to Localizable.strings.
  3. Generate the swiftgen strings to add the strings to Strings+Generated.swift. Again, this can be done by running the RunSwiftGen script from the Localization directory in Local Packages.
./RunSwiftGen.sh
  1. Stage and add the files to a PR.

For local testing

  • It is a good practice to run the app in both English and Spanish, and click around any areas that have string updates for this run.
  • Update the swiftgen.yml file to use Spanish. This can be done as follows.
 inputs:
    Resources/es.lproj
  • Generate the swiftgen files again and verify it generated the strings and in spanish.
  • Discard the changes to swiftgen.yml and Strings+Generated.swift

Bulk load localization strings to the iOS text files and the Lokalise catalog

For some large projects and for iOS specific strings (accessibility) a new process will be used.

The process

  1. Each platform will bulk upload their strings via Lokalise from a file using their default file name.
  2. Strings will be assigned to iOS, do not assign (tag) the strings to the other platforms.
  3. Do not assign the strings to other platform specific files.
  4. Make sure you have not checked Replace modified values.
  5. iOS can update Key names/values if the key is exclusively iOS.

The strings for the project/feature will be bulk uploaded to Lokalise, tagged as iOS only. From this point, the process will run the standard way through TextCatalog and then to banno-ios