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.
Related
I have an app that I want to translate to Spanish. The app is very simple and uses a basic UINavigation Controller. The title is set in the main story board:
To add Spanish I did the followings:
Added Spanish in the project Localizations
My first question to you all is why is showing 4 files in English and 3 Files in Spanish, when I actually have 2 files for English and 2 Files for Spanish
I enabled location to the view controller
I added string file to the project as well. This is for labels and dynamic text within the views, and this is working as expected.
Edited the Main.strings (Spanish)
When running the app, I edited the scheme, and set the application Language to Spanish.
When the app launched and got to the main screen, I still see Welcome instead of "Bienvenidos" What am I missing?
Other things you should know, when adding localization I enabled and disabled this feature a few times for the storyboard trying different options. Also, when testing the app, I change the settings language to Spanish, I deleted and installed the app multiple times as well.
I'm using Xcode 10.1, Project Format is Xcode 9.3-compatible, iOS deployment target is 12.1
Hope someone can help.
Hope this helps someone else. With Xcode 10 the recommended way to do any localization is by selecting your project and perform an export for localization, just go to Editor > Export For Localization
Once you exported the project, make any changes to the .xliff files, images, etc.
In the .xliff file, each translation should have a <source>, <target> and <note> tag. In my case, many tags are missing. I manually added them, did the translation and import the translation into my project.
To import the localization just select your project and go to Editor > Import Localizations. Now everything should work as expected.
This video from WWDC helped me resolve my issue
https://developer.apple.com/videos/play/wwdc2018/404/
Hope this helps
For your first question, you probably have also localized your LaunchScreen.storyboard file. So you should have 3 localized files in total, except that for your Main.storyboard you have checked all three checkboxes (Base, English and Spanish) and since English is your development language, it counts for two.
As for your second question, if you're running in the simulator, just editing the scheme should be fine. Since you told that you enabled and disabled localization for your project something might have broken with Xcode. I've been there as well when I tried to remove a localization. Try to clean you project (Product -> Clean Build Folder) before running the app or even start the project from the scratch (if possible) without this adding/removing flow. Hope this helps.
I've completed translating my app to Turkish using Base Localization. However, I also need to translate NSLocationWhenInUseUsageDescription key in my Info.plist file. I did exactly what I did for everything else:
Went to File inspector and checked Turkish:
Then I went to the new strings resource and completed my translation by adding this key to the localization file:
"NSLocationWhenInUseUsageDescription" = "[my Turkish description of location permissions]";
Saved, compiled, even deleted app from device and rebuilt, but no avail. When my app asks for location permissions, the explanation underneath is still the English one (I've tried including the English translation as well under Base translation file, but it didn't change anything).
Everything else is Turkish, translated just fine. It's just the location permission that doesn't translate. I've also seen How to localise a string inside the iOS info.plist file? and added the "Localized resources can be mixed" = YES key (of course, as CFBundleAllowMixedLocalizations, not literally that sentence) to my original plist but that also didn't change anything.
How can I solve the problem?
Here's what ended up working for me in Xcode 7.1.
First, go to project directory and manually create two InfoPlist.strings files, the first inside the en.lproj folder and the second inside the fr.lproj folder.
Both files should have the following content :
NSLocationWhenInUseUsageDescription = "YOUR TEXT HERE";
Since the files won't show up automatically in Xcode, you have to manually add both to the project bundle, this can be achieve via right-clicking the project name in Xcode and choosing the Add files to X option, then selecting the files you just created.
Also if you want to test the result & make sure things work, changing the Application Language in Edit Scheme > Run > Options isn't enough.
You need to change the simulator or the device language via Settings > General > Language & Region > iPhone Language
I've started over. Removed the translations, cleaned the project, and tried again. It worked. I have no idea why it didn't initially though.
My problem seems to be case sensitive:
My InfoPlist.strings had a lower "i" in finder and Xcode (infoPlist), but needs to be upper.
I changed file name and reference in the source Xcode Project and it works
(or deleted and re-create with the right name).
I am adding multiple languages to an iOS application from .xliff files. On the first import, all works as planned and everything comes is and works great. On the second, however, it will tell me:
Duplicate localized resource "XXX/Localizable.strings" found
It appears that it isn't grouping the files correctly, even though they are in the appropriate locations in finder.
Any ideas?
I couldn't get it to work properly but here is my work around:
I would import language 1, watch the files get added to the project and then remove references in the Xcode project (Note I didn't delete them from the disk). This makes it Xcode doesn't know they exist in the project but they are still there in the project folder in finder.
I did this for every language but the last one. The last language I clicked on the created localizable.strings file and click "Add files to the project" and added back all of the files I had previously removed the references.
I assume this is just some sort of bug but that is the only way I figured around they issue.
I have two questions
Have any tutorial for localizing iOS app to support multiple language with app not using storyboard?
I doing my app without storyboard, I localized it by created Base.lproj folder in my project direction, copy .xib to it, and added language in Project->Info->Localization.(I tested successfully on demo) but with my app when I build and run on simulator my app doesn't update according to setting language on simulator, it only update when I rebuild. Anyone could give me a reason or doubtful questions?
When you localize resources in your Xcode project, you don't need to copy anything: Xcode does everything for you. If you start copying things here and there, you might get lost, and files might not even get copied to your app bundle.
What you need to do is:
1/ Reference all languages in your Xcode project
2/ Create a new "Strings" file in your project using Xcode, call it "Localizable.strings", and create localized versions of it through Xcode, using the "Localization" pane in the File inspector
3/ Once you have created multiple versions of your Strings file, enter a sample string that you will test in your app, like:
"HELLO_STR" = "Hello, world";
in your English version, and
"HELLO_STR" = "Bonjour tout le monde";
in your French version.
Then in your application startup code, add this line:
NSLog(#"%#", NSLocalizedString(#"HELLO_STR", nil));
The message logged in your console should now correspond to your device or simulator language setting.
4/ You now need to add all localized strings to your Localizable.strings files.
5/ As for the XIBs, it works exactly like the Storyboards: you can ask Xcode to create a localizable version of all your XIBs. They are copied and bundled by Xcode in much the same way as the strings file we already built in steps 1-4. It is better to do that once you have "finished" designing your interfaces, because any subsequent modification to one localized XIB version will have to be repeated in all other localized versions.
Good luck.
I am localizing an app and while the process seems straight forward (I followed http://www.raywenderlich.com/2876/localization-tutorial-for-ios with minor adjustments for new Xcode interface), and worked for strings with no issues, I cannot get my localized images to show up.
In Xcode, I already have a set of images in the original language and clicked the "Localize..." button for each of them. Accepted the default selection of "English" and noted that all the images were moved into a new "en.lproj" folder. All these images are used by calling [UIImage imageNamed:#"image1"] within the code.
Then I collected all my localized, French versions of these images and placed them into a folder "fr.lproj" at the same level as the "en.lproj" Xcode created. File -> Add Files to "Project" and point it to that folder. At this point Xcode actually automatically detected that these are French localized files and the right side bar correctly identifies them as such when I select any of those files. Project info tab correctly shows the expected number of localized files for each language. Yet when I run the app with French language selected in the simulator, it shows me localized French text, but English versions of images.
Am I missing any steps that should have been performed, or should something be done differently?
This happens often due to caching. Make sure to
A) delete the app from the simulator. You can also "Reset content and settings" on the simulator, but that shouldn't normally be needed
B) run Project > Clean
Sometimes it is also necessary to
C) run Project > Clean Build Folder (use Ctrl key)
D) delete the Derived Data from your project. To do this, open Organizer and choose your Project. Sometimes you even have to do this manually, i.e. navigate in finder to the folder and delete all files and folders.
Usually, this should do it. Sometimes a little trick works as well to quickly refresh index and cache, especially precompiled headers - open the .pch file in your project, and "break" it (e.g. comment out a line) so that it fails to compile. This will trigger headers to recompile as well.
Hope this helps.
Image localization doesn't worked correctly for me when there are 2(or more) PREFERRED LANGUAGE ORDER in the simulator Settings.
I'm new to iOS localization so.. I don't know why it is working like that.
Anyways try to maintain only 1 PREFERRED LANGUAGE ORDER to resolve the issue.