What does the localize button in Xcode do? - ios

I am working on a Unity3d game for iOS which uses the Helpshift plugin for customer support.
Unity version : 4.6.4p1.
Xcode version : 6.1.1
The problem is that the popup for the plugin appears without any buttons.
But this gets fixed if one selects the .strings file on the plugin and click on the localize button. It then places the files in the lproj folder of that language.
But the localize functionality is surely doing more than just putting it in the correct folder, as even if you put it in the folder before hand the problem persists.
One can also see that after pressing the localize button, the number of files localized in the info panel of the project in Xcode increases by one.
I cannot have this setup as the build is automated, one cannot have any manual steps in the process as it will completely break the work flow.
Do let me know if you have any leads, if not the complete solution.

You are correct, clicking the localize button does do more than just put a strings file in a folder. That is the main part, but it will also wire that folder and file up into the project as a resource that gets included during the build process and will likely add some reference in the storyboard as well.
See Internationalizing the User Interface

Related

Xcode: won't add localization

Usually adding a new language in a project is easy. I'm in the project tab, I press on "+" in the Localizations area, and then I choose the language that I need to add. It asks me which files I want to translate, I choose them, I press finish and then nothing. The new language won't appear. The project that I'm working on is full of frameworks and sub-projects. I didn't create it, so I don't know its full history.
In the end I fixed it by manually creating an "el.lproj" folder (for adding Greek) and copying the Localizable.strings from another language. Then I moved it into my project and it magically appeared in the localizations tab. I think it's kinda of a bug.

Is there any better way to rename an XCode project than the given one?

The given version is described here: How do I rename a project in Xcode 5?
But, as you can see from the following screenshot^, not everything gets renamed, and if one opens package contents, directory names etc. to try to manually change all the references, the project is broken afterwards, so you have to keep the old project name for sub directories etc., which granted is not a massive problem, but is intensely irritating, and I'm not enjoying being intensely irritated at work.
^ apologies for a screenshot, but there's too much information in it to transcribe to written text. Top two-thirds of screenshot is XCode project, bottom third a Finder window.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Notes :
If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS git or some other SVN in your projects. This will come in handy in this kind of situations

Cannot localize my app (adding a localization language shows no files and adds nothing)

Basically I can't add Localizations from the project > info > Localizations section.
When i try to do so, i can see the languages and select the one I want. But when the "Choose files and reference language..." screen appears it is completely empty. When i press finish nothing happens as well.
My goal is to localize the app name, so i have to add the InfoPlist.strings files to the languages I need.
If i try just selecting the file and pressing the localize button i get a prompt asking me to select the language, if i try any of the languages shown there i get this message error:
“Info.plist” couldn’t be moved to “ja.lproj” because either the former
doesn't exist, or the folder containing the latter doesn't exist.
I even tried manually adding the .lproj folders and adding the files there but the app name doesn't change. I suspect that it is because the project is configured to look for those in a different place.
This project was originally created with cocos2dx so it came with many things preconfigured, that was a long time ago with an old version of cocos2dx, so i suppose the folder structure has something to do. Still i don't know where to fix to at least be able to add more localizations.
The solution I found was to first create the "InfoPlist.strings" manually as a file inside the project directory. Then add the file from xcode. Then clicked on localization and select at least 1 language. Then i could add/remove localizations from my project settings.

The file “Main.strings” couldn’t be opened because there is no such file.

After attempting to localize a project (originally created in Xcode 6) I am seeing an obscure error in the debug navigator.
Steps performed
Enable Base Localization
Add strings file for an additional language (Portuguese)
Edit the scheme to changing the Application Language and Application Region to Portuguese (Brazil) and Brazil respectively.
Result
"The file “Main.strings” couldn’t be opened because there is no such file."
When attempting to select the file I am presented an alert.
"The document "Main.storyboardc" could not be opened. Interface Builder cannot open compiled nibs."
As a sanity check I created a new project with the same setup (using NSLocalizedString) and ran through the same steps listed above. I provided alternate translations for the additional language, then built and ran the project which worked as expected presenting the alternate translation of strings.
Environment
Xcode 7.1.1 (7B1005)
OS X 10.11.1 (15B42)
I have already attempted following this answer but the question and answer don't quite apply to the issue I'm seeing.
I'm at a loss here. Any advice?
What do the error and alert indicate?
Why does one project (created with Xcode 6) fail when attempting to localize and yet a brand new project (created with Xcode 6) succeed?
I faced the same issue while on a project that was also created on Xcode 6. I resolved the issue in following way without compromising on localization of storyboard file:
Import the XLIFF for localized language (in my case, it was French)
Try to run the app, it will show the mentioned error
Now, right-click on storybook file and click on “Show in Finder”
From the directory location, move out the .storyboard file from Base.lproj folder
Now go back to Xcode, and remove the storyboard file (only reference)
Now, drag the .storyboard file from its new location into the project
Now, add localization from ‘File Inspector’ for .storyboard file. You can use existing .strings file for localization
Everything should work fine now.
I never found a solution to this problem by using Main.strings. Instead I kept all translatable content in classes allowing me to rely solely on Localizable.strings.
Remove app from device, clean & build your project.

iOS localized images not showing up

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.

Resources