iOS App Localisation Best Practices And Placeholders - ios

We're currently at the stage of looking at localising our app in to multiple languages now that the general concepts of the app have been decided. This is something I want to ensure is done correct from the start to lower the risk of headaches in the future.
The app targets iOS 7 and above, uses storyboards, and is written in Swift.
Storyboards
When working with a storyboard (or a xib), what's the best way to mark a UI element as "not to be translated"? For example, I have a placeholder string for a user's display name (Display Name), which will be replaced by a users display name at run time. This display name will not be localised, but neither should the string "Display Name". Is there a method of not having a UI element's value automatically put in to the strings file? If not, is going in to that file and manually removing strings I don't want localising a sustainable option?
Strings In Code
I'm using the Swift function NSLocalizedString with the key and comment parameters. Some places I've seen say to set the key to be a unique id based on the context (e.g., intro.login-button-text), while others seem to just put the full string in the default language (e.g., Login). I like the idea of the unique ids for the key, but would this not go against the idea of the "base" language?
Exporting
Xcode 6's "Export For Localization" option seems very useful for getting the correct format of file to be sent to translators. However, as mentioned previously, placeholder text does not need to be translated. Should these placeholders be removed from the exported xliff or the strings file prior to export?

Looking for the the same questions myself. Hope this will help you and others. Also I would recommend to have some kind of tool to organize the xliff/string files
Storyboards:
I've seen developers putting non translating texts in storyboard with extra parentheses. i.e. {Display name}.
By using this you can see by the translation itself if it needs to be translated or not. We use oneskyapp.com and can select to hide those translations and they will be hidden for each import of that key.
Strings in Code
By following this thread they suggest to use keywords.
Best practice for key values in translation files
Exporting
I cannot find a way to have some translations automatically removed when exporting. Off course you can put the views which has dynamic fields in different XIB/storyboards and decide not to translate those.
Again a tool like onskyapp.com can help you with this.
Formats
As of context with the field is important and a translation can be different when it is followed by i.e. a users name I would go for "%1$# is online!"

Related

iOS - fastlane deliver, localized App Store description from strings file?

I'm getting ready to have my app localized into other languages.
I'm using NSLocalizedStringWithDefaultValue to provide default English text within code, although I guess none of that maybe relevant.
I'm not adding localized text directly to nib or storyboards, everything is in my strings file.
I'll probably end up uploading those to a localization site.
So I'd like to use fastlane deliver to upload screenshots and meta data.
However I'd like to find a method where I can pickup values from my strings files.
So I guess my question is, how can I get my strings value into my deliver text file?
Or is there a better / quicker approach I should use?

Localization not working on Xcode

I can't get my app to work with localization.
I have created a Localizable.strings file and ticked the languages that I am localizing. (For now I have base, english and spanish.)
Localized storyboard with three languages.
In Project settings > Info I checked Use Base internationalization and all languages are correctly added. (Moreover, beside the language it shows 2 Files Localized, which I guess they must be the storyboard and .strings file.
I am using this example for testing:
self.loginLabel.text = NSLocalizedString(#"login", #"Login text info");
This is how the Localizable.strings (Base) file is looking like:
"login" = "Log in";
However, it is not working and instead it is showing login. Have I forgotten a key step?
BTW: I have tried already changing the login text just it case something was overriding the label.
Those are the steps indeed, I don't think you've left anything out. I usually set the comment to nil instead of another NSString though - not sure if that makes a difference.
However, rather than in only base, make sure you're adding the same line also to the English and Spanish files (obviously translated as appropriate).
Next, for the language to show up, set the device to said language. Close your app and start it again. Strings should now show up in the other language.
Note that the Simulator often has trouble with new translations, especially when they've been added to an already deployed app. In that case, remove the app from the Simulator, click on Product - Clean, and re-deploy.
In my case, it didn't work because the UILabel text was set as "Attributed" instead of "Plain" in the Attributes Inspector.
Localization with a .strings file doesn't seem to work on Attributed strings.
I even had a storyboard with mixed Plain and Attributed string labels, and the localization only worked on the Plain ones.
For anyone having a similar issue in the future:
Check if your *.strings file has any non-printed characters.
I used JavaScript for a simple task and didn't realize it included some whitespace characters.
An easy way to check is to put the translation at the top of the file and see if it works. If it does, there might be some whitespace characters. The next steps are... binary search and remove the whitespace characters.

How to localize ActiveReport 7.0 XML PageReports rdlx

We have a huge number of Page Reports created using ActiveReport (*.rdlx files)
We use them from our ASP.NET MVC web appolication.
All captions and other stuff were initially created on English
Now we need to add a multilanguage support there so, somehow we need all existing texts be inserted in resource file and so we can then add translations
Is there a way to achive this task quickly, without going to each report field and manually extracting it into resource file?
Documentation says that once you change Language property, resource files will be created, but seems it is not working for XML reports, or there shouldbe a trick
For the reports designed with Code-behind, resource files are created pretty much the same as if you will create a Windows form... but I fail to find out how to do this for XML reports.
Page Reports support a localization; however it doesn't do so with a resource file.
This is mentioned off-hand in a single sentence on the page about Localization with ActiveReports 7.
Setting up a localized value in a Page Report is done the same was as you do in a Section Report. Simply change the report's Language property and then set new textbox values. At report runtime the appropriate value for the textbox will get used.
As I mentioned above, this doesn't generate a separate .resx file; instead if you inspect the resulting .rdlx you'll find a custom dd:LocalizationResources element is created that specifies the language setting and the new values for report elements.
The Localize property you are referring to in the documentation and in the code-behind reports are for the code-based "Section Layout" Reports but won't work for XML-based "Page Layout" reports (if you look at the generated code for the report, you'll see that the designer is just generating a bunch of code to localize the report).
Since code-behind reports support custom code or you can add references to another DLL you can write a simple function to localize captions. There is a good example of localizing this for .rdl reports here, you can use exactly the same approach with the ActiveReports' .rdlx files.
During that initial configuration of the report to be localizable you'll either have to manually change each static string to a Code.LocalizedValue call or maybe you could write a simple script to find each //Textbox/Value elements and replace it with a similar call. A simple script with a combination of xpath and regex could do help you automate the initial configuration of the report. To localize something other than a Textbox Value in the report (e.g. report parameter, labels/bookmarks), you'll need to replace the text of a different element than the Textbox Value but the concept is the same.
Of course, I am assuming you are localizing the static strings in your report. If you want to localize the values from the database then you'll have to do that differently (comment if you need help and I'll explain).

Localization for a very simple app.. How to connect a button?

I have a very simple app which only contains a PickerView, UILocalNotification, UIAlertview and less than 8 views. What I want is:
I have a main view which contains two buttons one says English and the other says French.
What in my mind is:
When the user hits English it'll take him to the Project I have right now,
However, when the User hits French it'll take him to a duplicated views that I'd simply and manually change and translate it's labels into French.
** Now my question is ** how do I translate the PickerView, LocalNotification and the AlertView? and how to connect the French button to these translations?
From what I've googled and read here in SO is that I can get the strings out and list them into Localizable.strings but I still don't know how to make my french button ask for these strings? Also, is there an easier and simpler way? any idea?
Thanks,
Kindly try this for doing localization
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
For buttons use something like this
[self.yourButton setTitle:NSLocalizedString(#"YOUR_KEY", #"Comment") forState:UIControlStateNormal];
Do not duplicate your views and view controller just for the sake of localization, considering that for both languages have the same layout and everything only thing that would change is the language. So add English strings and French strings to your project and use NSLocalizedString to get these values.
Note:NSLocalizedString works with device language only so if you want to change the app's language manually try this. I have used AMLocalizedString in many of my projects and they work fine.
Hi as you want to make it localized only at App basis not at device basis hence NSLocalisedString will not work you have to manage it so you have to take two different files and you have to fetch the string value on the basis of selected language. In similar manner as LocalisedString works as in localization there are multiple .strings file created for languages and it works in a way to select default language of the device and shows the text from the localised file.

Localizing HTML files / Parallel file editing

Due to timing constrains, I have developed a web application where a lot of language-specific strings have been directly hard-coded to large HTML/Javascript static files. Due to poor coding, code and content have not been properly separated.
To achieve quick and dirty localization, I am looking for some kind of text editor that would allow to "tag" the local elements of a file and turn them into "custom fields". These fields could then be stored in some resource file and translated independently from the shared structure, to generate multiple localized versions of the file.
I realize that I could do this myself through a "simple" templating mechanism, for instance by keeping a shared root file containing fields like {%welcome_message%} and a csv file for field translations, and then generate localized files.
But is there a text editor that could do this in a fast, user-friendly way ? For instance where we could see/modify the custom field values (as well as the root parts) directly when editing a file ?
What would be great for instance, would a a text editor feature/plugin allowing some kind of parallel file editing by distinguishing "root" and "localized" parts in a set of files.
(Note : currently I am using diff/merge tools to achieve this kind of results, but it will become increasingly cumbersome as we add more languages).
I think this could help you in parallel file editing http://www.sublimetext.com/.

Resources