Resource files are not displaying in Localization - ios

Only one Resource file is displaying When i'm adding Localizable.strings file for any language. My steps are,
Selected My main app's project file in xcode and found info option is there
in info - Localization - + option
Note: there is only one resource file (InfoPlist.strings) is available to add Language.
3- then Finish, but there is no Localizable.strings file is displaying in xcode but there is InfoPlist.strings file displaying.
But if i do these same steps in sample app which is working fine , I can able to select Multiple resource files And also I can see many Localizable.strings & InfoPlist.strings
in xcode.
Like:
Localizable.strings (English)
Localizable.strings (Spanish)
InfoPlist.Strings (English)
InfoPlist.Strings (Spanish)
Can anyone please tell me the solution to add multiple resource files when localizing any language?

If you want to make your app to support multiple languages, then you'll need to add .strings files to your project, make sure that you should name it "Localizable.strings" only, and need to put in particular language folder,
See this question and my answer there,
Localized filename should always be named Localizable.strings, and that file is within the particular language folder, for English, en.lproj and for French fr.lproj like wise.

Localizable.strings file should be inside the Base.lproj folder.

Related

Xcode localization: Base concept without redundancy

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

How to localize Info.plist content in Visual Studio

I have a Xamarin iOS application that supports 4 different languages ​​at the moment. However
I would now like to be able to translate the contents of my info.plist file and its keys like NSCameraUsageDescription so that its
values ​​can be translated as well.
I have done quite a lot of research so far and by searching through the documentation it is advisable to create an InfoPlist.strings file which would contain
my key NSCameraUsageDescription = "the content here".
There would be an InfoPlist.strings file for each language and this would be contained in a folder fr.lproj, es.lproj etc following the language.
I think that it is relatively well explained to exploit this option in Xcode with the possibility to create .strings files and to localize them directly.
However, on Visual Studio I have some difficulties to introduce and adapt my files. The equivalent of a .strings file on Xcode is a .resx file on VS ?
How can the relationship between my InfoPlist.strings and my main Info.plist file be in order to tell my application to tap in the folder fr.lproj / InfoPlist.strings when I switch to french for instance.
Am I supposed to create one folder for each language named fr.lproj where I put a single file InfoPlist.strings or InfoPlist.resx with my keys ?
However, on Visual Studio I have some difficulties to introduce and
adapt my files. The equivalent of a .strings file on Xcode is a .resx
file on VS ?
No, to create a .strings file in visual studio, you should choose add -> new item -> Text File, then change the file name With xxx.strings.
How can the relationship between my InfoPlist.strings and my main
Info.plist file be in order to tell my application to tap in the
folder fr.lproj / InfoPlist.strings when I switch to french for
instance.
If you created the InfoPlist.strings for each language, it will automatically read the configuration in the file of the Corresponding language, and then show the right language. If the key was not find on the InfoPlist.strings, it will use the default value in main Info.plist.
Am I supposed to create one folder for each language named fr.lproj
where I put a single file InfoPlist.strings or InfoPlist.resx with my
keys ?
Yes, if you have four language to support, you should create 3 xx.lporj folders(another is Base.lporj) and each contains an InfoPlist.strings and Localizable.strings.
In your InfoPlist.strings file, set the key NSCameraUsageDescription = "the content here" and ect....
Read the document may help.
Here is what I just created in my project:

iOS How to localize for both Spain and international?

I want to have a specific version of Localizable.strings file to serve for people in Spain. However, in the case of general Spanish, i want to serve a different file.
Where is the documentation on how this is done?
or is it just that i need two Localizable.strings files in both es.lproj and es-ES.lproj ?
Also, is it as easy as just creating the folder es.lproj with Localizable.strings file, and then in xCode do "Add files to project" ?
What you should do is to localize your xcode project. The document for xcode project localization is here(https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html)
There are different Spanish language, such as Spanish-Mexico(es-mx) and Spanish-Peru(ex-pe). Please refer to here for more details(http://www.science.co.il/Language/Locale-codes.asp).
And if you just need to support Spanish - Spain (Traditional) language, either es or es-ES is Okay.
Creating the folder es.lproj with Localizable.strings file is not work for localization. You should localize the project. Please refer to 1 or here(How to localize my app with Xcode 4?) for project localization.

When is Base.lproj used?

I am trying to understand Base.lproj but I am not still understanding it. If I create a new simple project with a view controller and Swift+Storyboard in XCode 6 beta 4 I get a Base.lproj folder out of the box containing the storyboard file.
I then add a simpel NSLocalizedString(...) in my view controller for testing purposes. This requires a Localizable.strings file. When I create one should I add it in the Base.lproj or should I add it in a specific language folder?
If I change the Localization native development region key in Info.plist to de for german and I no Localizable.strings file for de in the de.lproj folder it seems to fallback on Base.lproj if Localizable.strings file is found there. However, if I add a Localizable.strings file in the de.lproj folder but don't add the property (key + value) the app fails during runtime. It seems like Base.lproj isn't searched.
I don't understand which language Base is and when it is used? Is it only for Storyboard files?
I was under the impression that base.lproj is used in cases where the current language/ localisation file does not have a property key. For instance if I do have Main_Title = "Title Text"; in base.lproj and absent in en.lproj while the current language is English, I assumed iOS will find it in base.lproj but that is not the case.
Your initial conclusion is correct:
Base is only used when you did not support that language in localizable.strings
The specific language localizable.strings folder is used when device/ app is using that language
If you do not provide support for a specific file/ string key in a language and you have a folder for that language, it will throw run-time warning
In case of storyboard files and xibs if you only have base.lproj folder which contains your views, notwithstanding how many languages you support, it will not fail (this is what I am doing as well).

Localization for new Files in older Project breaks App

Good evening
I want to add a new year, a new volume as plist-file to my existing app. The app is localized for 4 languages, so the new file has to be localized also. The languages were "English", "German", "French" and "Italian".
But when I do this, Xcode creates a directory "de.lproj" next to the existing "German.lproj", same behaviour for French and Italian, but not English. The older localized files are now in a directory "German.lproj", the newly generated plist in a folder called "de.lproj".
Then the app will no longer recognize the localized strings, exept the english version.
How can I add a new localized file to this project without breaking the rest?
Regards
You should use Localization Suite to manage your translations. This way, you can let loc-suite to scan changes in your original .plist file and tell you which ones are translated and which ones are not. Loc-suite can also update your localized .plist file and remove dead entries.
This question is slightly off topic at stackoverflow though.
Finally I solved the problem like this:
Make a backup of each localized file (plist and strings files) in the Finder and collect them in a folder for each language.
In Xcode, remove every localization for these files so that the only remaining language is English.
In Finder, delete the old lproj directories in the project folder except English.lproj.
In Xcode, add the formerly deleted localizations for each file. Copy the contents of the files into the newly generated localized files.
Maybe this can help somebody.

Resources