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 Localizationto the source file. - Then the localized strings are referenced via static properties on the
Localizedtype. 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.
- 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.
- Navigate to the workflows:
.github/workflowsand selectupdate-ios-from-lokalise.yml - Choose
View Runsand select theRun workflowitem, then pressRun workflowbutton (themainbranch should be selected already). - 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.
- 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 thebanno-iosstrings.
banno-ios
- Create a new feature branch based off of the
developbranch in thebanno-iosrepository. - The contents of the
Englishand/orSpanishfiles fromTextCatalogare added to the localization package by copying the changed strings or the entire contents toLocalizable.strings. - Generate the swiftgen strings to add the strings to
Strings+Generated.swift. Again, this can be done by running theRunSwiftGenscript from theLocalizationdirectory inLocal Packages.
./RunSwiftGen.sh
- 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.ymlfile to useSpanish. 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.ymlandStrings+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
- Each platform will bulk upload their strings via
Lokalisefrom a file using their default file name. - Strings will be assigned to iOS, do not assign (tag) the strings to the other platforms.
- Do not assign the strings to other platform specific files.
- Make sure you have not checked
Replace modified values. - 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