It’s not there in MainViewController on initial code project.
Maybe the initial code project is different, because that line (below) not exist in the project.
It looks like you may have missed a step earlier in the tutorial. You should have added:
let formatString = NSLocalizedString("You have sold 1000 apps in %d months",
comment: "Time to sell 1000 apps")
salesCountLabel.text = String.localizedStringWithFormat(formatString, period)
As the last step in the section Separating Text From Code, right before the section Adding a Spanish Localization.
Why are you bothering with the NumberFormatter? If you just leave your format string as %d instead of %@ you can directly pass in the value 1000 and the right format will happen.
There is one specific task that I find very confusing tutorials about: update of localized storyboards. Seems like new outlets are not automatically appended to the localized files. Sadly, after following one of such tutorials, I had to erase all localizations from my projects whatsoever to start it again.
There actually is a solution, though it’s not nearly as straight-forward as one might hope.
Make your changes to the base language storyboard as usual.
With the storyboard open in the editor, go to the File inspector, Localization section, and change each localized language from Localizable Strings to Interface Builder Storyboard and click Convert in the resulting dialog box
Now change each of the back to Localizable Strings and click Convert.
All of your new localizable elements will now appear in the resulting .strings files.
As I said, it’s not as easy as one might like but it beats starting over.
Thank you for the tutorial. One thing that I am missing, and am curious about is how to manage content from a backend server, i.e error messages. Do you do the Localisation in the application, or on the service?
There really isn’t one definitive answer. It all depends on how you want to build your client app. If you want to be able to display content directly from your backend server, then you will need to do the localization on that server. This would mean, among other things, that you have to provide a way for the user to set his preferred language. If you’re already requiring that the user create an account that is represented on the server, that’s fairly straightforward to do.
On the other hand, if you want the server to be monolingual, then you have it return localization keys and you call NSLocalizedString(_:tableName:bundle:value:comment:) for each one of those.
Personally, I would probably lean towards the first approach simply because you control it and don’t have to wait for approval from Apple to deploy updates.
No, there is no tutorial specifically dealing with RTL language support. Most everything you need (like 98%) is covered in this tutorial. Three things of note to watch out for:
Make sure all of your Auto Layout constraints refer to leading or trailing anchors and not left or right.
If the app is RTL-only but the device language is LTR, you won’t get RTL support in the app automatically. You’ll have to force it manually in the app by adding the following to your AppDelegate:
If you have custom views, you’ll need to figure out what changes they require to support RTL languages. All of the controls in UIKit/AppKit already have full support so this is just for any custom ones you’ve created.
Great thank you. I do have one more question that isn’t covered here but I can’t find the answer in Apple’s own documentation. If I wanted to add the option in the app for a user to change the language inside the app is this something that Apple would not support and would not accept during the review process? I have a requirement from a client that they want this but I know that the preferred way is to just default to whatever language the iPhone is set to. If you’re able to point me in the right direction to what apple say about this it’d be appreciated
I have no idea on this. I don’t see anything in the App Review guidelines that would prohibit such a thing but that doesn’t mean it would pass either. You might try sending a support email to Apple and asking how such an app would be viewed by the review team.
There are no guidelines against this at all. You can force the language based on some user preference the user chooses, but there is no “proper” API to do this using NSLocalizedString easily.
Thanks for your recommendation. I did see this library in my search actually. So does this not require the app to restart/reload before the change takes place?