A while ago i decided to make my application multilanguage. I ended up using localizable.strings. So a different file for each language with all the translations in it.
In my main storyboard i just use NSLocalizedString(#"example", nil); on all my elements etc.
The problem i have is that i just found out that i somehow ended up with a storyboard for each language. I can fold out my MainStoryboard_iPhone.storyboard and under this it lists the language specific storyboards (MainStoryboard_iPhone.storyboard (English) and MainStoryboard_iPhone.storyboard (Dutch). Since i do not use this because i do everything with the localizable.strings i do not need this language specific storyboards. Over time they also became inconsistent. The english board has all the current changes and the dutch one does not.
My question is:
How can i safely remove these language specific storyboards and just keep using the localizable.strings. I want to end up with only 1 main storyboard (the top level one in the image above). I do not want to ruin my project and i want to be sure that the solution i use is correct.
Thank you!
I had the same issue.
I solved it by selecting "Base internationalization" in the project settings. Next, click the file inspector icon (right pane) for your storyboard file and make sure only Base is checked. Do not check the other languages.
This will fix the issue.
Don't bother with Base internationalization for your localizable.strings file, you can still use your regular translation setup there (ie, English and Dutch).
To "roll back" a localized File. you have to navigate to the folder where your class should be. You see the folder "en.lporj" (and the other languages) and there is the file you need.
-
Now copy to a save place, remove the multi-language file and in xcode and tell to remove from disk. Copy it again into your folder where you need it and import it in xcode.
Now the settings for the translation are resettet. you should recheck if no links went lost (simple clean build should be enought for this).
I handle only .xib file at the moment, but the procedure should be the same for all files :)
(if not, please let me know :D)
Greets,
geo
Related
I am a little confused about the implementation of localization in Xcode. I know that I can provide as many languages as I want by creating the appropriate XY.Iproj folders and inserting the .strings and Localizable.strings files into them. This all happens automatically with Xcode.
Unfortunately I have problems understanding the Base concept. As I understood it so far, the development language is to be used there. In my case this is English, so should I write in the storyboard and XIB files as text directly in English? For example the headline (a label) of the settings page with the content "Settings"?
But why do I have also the .strings file with the translation into English? That would be redundant, because I have already entered English text directly in the Base file and the .strings file contains the same text again.
Or should the storyboard and XIB files only have identifiers like "settings_page_headline" as content for labels? But that's nonsense, because these labels are good for nothing...
Or can I completely delete the .strings for the English translation if I have already inserted the English content in the storyboard and XIB files?
I hope you can enlighten me a bit. Of course I have read the documentation of Apple, there my problem of understanding is not discussed as much as I need to understand it.
Main.storyboard (Base) and Main.strings (English) contain the same content:
Content of the Main.storyboard (Base):
Content of the Main.strings (English):
"tos-eB-aJc.title" = "Send Feedback";
"S56-oM-eis.title" = "Rate this App";
From Apple documentation:
Xcode creates a Base.lproj folder in your project folder and adds to it the resource files you select. Xcode creates a language folder for the development language but only adds resources that need translation to the folder. For example, if you select English as the development language, Xcode inserts the resource file in the Base.lproj project folder but not the en.lproj folder because the resource is already in English.
link: InternationalizingYourUserInterface
As I understand it, this was done to optimize the import of localization files. Also you can not localize some .xib . If you want to understand how, by what logic and in what order the localization files are loading, read this document from Apple: LocalizingYourApp
I have searched related questions and tried many suggested methods but none seems to work.
I have a japanese-only App that when run on an english device gets UI items such as back buttons translated ("Back").
To achieve this I have:
Deleted the English from "Localizations" from my project and chose to delete localized files (was a single *.strings file).
Changed CFBundleDevelopmentRegion in my Info.plist from jp_JPto jp as I read it should match the name of the *.lproj folder.
Cleaned, deleted, closed Xcode, etc. But default UI items are still getting translated to english.
Also I get some weird behavior in Xcode 5 now:
Checking the "Use Base Internationalization" checkbook presents an empty "Choose files and reference language to create Base localization". Choosing either Cancel or Finish has no effect and nothing happens.
Clicking on the "+" button to add the Other > "Base (Base)" localization does nothing.
I thing that my problem seems to be that my Base localization is still somehow english but I can't find a way to change that. Any ideas?
I found that to truly remove English support I have to properly set the CFBundleDevelopmentRegion into a full valid region (e.g. ja_JP) and not just a language (just ja still resulted in English showing up).
When you have a valid region Xcode will show you the name of your country instead of the raw value in the Plist editor.
Seems like some modules, such as MFMailComposeViewController, get localized to English no matter what (tested on iOS 6 and 7).
I encountered the same issue. Here are the steps I did to get past them.
Localize your storyboard file.
Select your Storyboard file in Xcode.
In the “File Inspector”, under the “Localization” sub header, press the “Localize…” button.
A dialog appears that says “Do you want to localize this file? The file will be moved into the lproj folder for the following language.” It lists a language. For me it was “English” and I chose that. For you, I suspect it will be “Japanese”.
Press the “Localize” button.
If it warns you that your storyboard file has changed outside of the project, choose “Save anyway”. If you don't it deletes the storyboard from your project. This happened to me with a source controlled project, but not with a new empty project.
Go back to your project and check the “Use Base Internationalization” checkbox. Your storyboard should show up in the "Choose files and reference language to create Base localization" sheet.
If you go back to your storyboard, you will see “Base” as the checked localization. I had my language (English) show up as an option. When I checked it, a storyboard.strings file was created. Since my base was already in my preferred language, I didn’t need a strings file so I removed it. I presume that if I had another language, I could select that and get a storyboard.strings file for that language.
I'm starting to get confused..I've wanted to finally add my translation file for all strings to my app according to ray wenderlich's tutorial. But somehow now everything got messed up. I removed now every localization again, which deleted my strings file, the storyboard etc. And now I have no localization language set in the project settings and I've copied all files back from the trash.
But my localized string (NSLocalizedString(..)) somehow don't load..or load something else. I've changed some of them to check if my strings file in the project explorer is actually used but it still uses the old strings and I have no idea from where..I've checked the project folder and there aren't any other files.
How can I set up everything again that it works? How can I set the strings file it should use? And how should I set up then the localization, with or without base language?
Edit: And in the simulator I cannot get my app running..it's showing only a black screen. Whereas on my iphone it still works (if I use my iphone from Xcode).
I guess I've deleted all my languages in project settings and now I cannot add any localization anymore :-(
Here's what I would try:
Check your project folder for any leftover .lproj folders / .strings file and delete
Clean / Build
Start localization from scratch following SmoothLocalize's Tutorial
This should delete all old files and create a new default localizable.strings, and then you can add more languages.
I've looked for similar questions, but this must have been asked before. Either way, please point me in the right direction.
I've localized an app for the first time. It seems to work ok, but I have two sets of .lproj files. One set is in the settings bundle, and the other is in the main project directory.
It also appears that some settings are affected by one .lproj file content and other settings are affected by the other.
Should I leave "well enough" alone? Should I combine somehow? If so, where is the correct place?
If I find this has already been answered, please forgive. I will either delete this question, or point it to the existing response.
Thanks
That is really OK to have lproj's all over the project. What is more important - to keep translated files inside of Xcode file tree. You can easily localize your nibs and any other files just by selecting file you need to localize and by adding File localization in File Inspector.
I have an app that is localized for two languages: English and Danish. If I set the device to any other language (say, French) the app crashes. It seems as if it's not really loading the XIB files, or getting a generic version of them that is not properly initialized.
I guess that I naively assumed that the app would load the English version if it was set for a language other than English or Danish.
What do I do? Is there a way to ensure that behavior?
Cause:
Somehow XCode had created two sets of en.lproj and da.lproj directories. One set was in the project root (oh, an en.lproj was here called English.lproj) and the other was in Classes. The "missing" XIB files were in the directory in Classes.
Solution:
Copy XIB files to the proper folders in the root. Remove original ones from project (go ahead and say move to thrash, you just copied them...). Add copies in proper location to project - all in one drag operation - and do not copy to project (they are already in the proper location).
The app should load the english version if you set the device language to, for example, french.
You should give some details how you are loading the XIB.
It's rather impossible to give an answer to this question without knowledge about your specific implementation.