![]() ![]() After confirming this Xcode will generate string-files with all the strings per storyboard. In the example, I only want the storyboard-file to be translated. Xcode asks you to select which storyboards and xibs you want to be translated. I will add Dutch as a language, because I am Dutch. In this workflow the first thing you’ll have to do is selecting your project in the Project Navigator and, in the ‘Info’-tab in the project settings that is presented in the middle, add a language in the section Localization. ![]() Trust me, at Noodlewerk we have experience in that field. However, you will run into problems and you’ll end up cursing at everything. I do not recommend going down this path! I do want to cover this workflow, because it is quite understandable that a developer goes down this path and you can get pretty far doing so. Translating your strings in Xcode with generated strings-filesįirst of all, let me be clear about this workflow. Nothing special, but for this example it will demonstrate a very common problem in certain workflows and, at the same time, it will show the power of XLIFF. You can see that the text of the description-text is different in the simulator. In the image below it shows what the app looks like in the storyboard and in the simulator. To enrich the example the ‘description-text’-label has an outlet to the viewcontroller and it’s value will be set by a NSLocalizedString, like this (because this enables you to change this line of text programmatically): class LoginViewController : UIViewController These texts are definitly not the texts I want in the app when it’s done. In this example I gave all the text-values a placeholder text. The view has a couple of typical items with a text-value which every app uses in abundance: labels, textfields and a button. ![]() In this example I combined both ways I mentioned earlier. To explain how localizing strings in your project works I’ve set up a small example. The downside of this way of working is that it is not transparent in how it functions. This requires only a couple of clicks and you’ll have all the strings in your storyboard in one place, ready to be translated. The second way is by letting Xcode generate a string file of all the strings in your storyboard. Besides, you will run into all sorts of problems when using for example tableview views. It does require a lot of manual labor, especially when you are working on a complex application. It is possible to create outlets like this for your entire app. It is best to be as descriptive as possible when entering the comment, because this is what the translator will see when translating your app. You only have to fill in the key and the comment, the rest is optional. When using NSLocalizedString by default the Method will ask for a key, tablename, bundle, value and comment. The first way is by creating an IBOutlet every object to the corresponding view controller and set the value of the text to a NSLocalizedString NSLocalizedString ( key : String, comment : String ) You do not have to choose one of these two methods you will probably combine the two. Xcode provides the developer with (roughly) two ways preparing your strings for localization, both with their own advantages and disadvantages. It is as simple as that! This blogpost mainly focussed on step 2, because that is the tricky part. The second step is then to add a translation to your app. The first step in any Localization-workflow is preparing all the strings that should be translated, in short: all user-facing text. ![]() Localizing your app can be devided into two steps. In this blogpost I will describe a pretty decent workflow within Xcode that makes localizing your app a breeze. But no more of that! Apple introduced a feature at WWDC 2014 (Session 412) using XLIFF file format. This allowed us to succesfully localize our apps, but it was always a pain to do it, even with third-party tools from the developer-community. As every developer probably knows there are three types of problems problems that are easily fixed by making use of the tools that Xcode provides, problems that are solved by the community of developers and problems that are a pain and you just have to deal with.Īt Noodlewerk, we already had a workflow for Localization within Xcode (later on, I will give a more in-depth explanation). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |