How easy is it to localise^ your iOS or macOS apps using Get Local? I'd say it is fairly easy, and in a few steps you'll have as many localisations in your app as you want!
In this tutorial, I've set up a demo app which has a title, a button, and some descriptive text.
Inside the Project Settings > Info
you can see there is only Base and English localisations.
xcloc
localisation fileMenuBar > Product > Export Localizations...
en.xcloc
file in the directoryen.xcloc
file into the window, or select Open file
and navigate to it from the windowen.xcloc
file has target translations, we can press the Clear Text
button to empty the column of the selected items. Confirm the clear on the confirmation boxTranslate
and instantly see all the selected rows translate into your selected languageExport all
to save all the translated text ready to import into XcodeYou will see an exported .xliff
file. It is prefixed with get-local
and the ISO country code
eg. get-local-fr.xliff
xliff
localisation fileMenuBar > Product > Import Localizations...
.xliff
fileProject Settings > Info
you will see your newly localised language.strings
files. These are the key to value representation of your translationsSometimes when we're building our apps we forget about localisation until the end. When this happens, we often forget to look at some of the computed variables or functions that output to String
s.
As a result, when we localise our app, these do not get translated.
In our example app, we had a computed property called timesWordPlural
which would output the word time
or times
depending on the number of button taps.
String
to LocalizedStringKey
String
returnWe'll change that into something better:
// change from this:
var timesWordPlural: String {
numberOfTimesTapped == 1 ? "time" : "times"
}
// to this:
var timesWordPlural: LocalizedStringKey {
numberOfTimesTapped == 1 ? "time" : "times"
}
StringInterpolation
, we need to break our text up into an HStack
time
and times
MenuBar > Product > Export Localizations...
en.xcloc
file in the directorytime
and times
.strings
files have been updated. It now has the extra translationsAs important as it is to localise your apps, so is testing them.
Edit Scheme...
menu. You can do this by:Option + click
on the run button - that is, ⌥ + click
on the ▶︎
button;Product > Scheme > Edit Scheme...
from the MenuBar; orCommand + Shift + ,
- that is ⌘ + ⇧ + ,
System language
to one of the languages you have localised intoRun
and see your app operate in the desired languageI hope this tutorial shows you how easy it is to localise your apps and that Get Local should be an essential part of your development toolkit.
^
Note that I'm from Australia so I use localisation (with an "s" not a "z"). So anytime I may use an "s" instead of a "z" just forgive me 🥺