one Xcode with two targets - but different selection of Localizable.string files - iphone

Is it possible to somehow associate different localizable.strings files to different targets of the same project.
For example:
target1 has English and French while target 2 has English and German ?
For "normal" files like the *.m or *.h one can set the Target Membership - but I did not find something for the different language specific Localizable.strings files.
I guess if this is not possible I really have to manually configure the Localizable.strings files before I create the ipa for submission - which is surely not the best thinkable approach.
Many thanks!

Please check the section es expanded, you should see the Target Membership section like you used to for other files:

Related

Is there any way that automate the localizations translations of my app's .arb file

I have an app_en.arb file which contains my localization translation for the English language.
I want to generate other languages's localization files based on this one, and I want to know if there are some software/services that might accelerate this process such as auto-translation, listing those translations for editing them...
Thanks.

where in an XCode project does it set "InfoPlist.strings" as the filename to use for locationalization?

where in an XCode project does it set "InfoPlist.strings" as the filename to use for locationalization?
Just trying to understand how XCode pulls things together here. For example to set the app name specifically I can change this in "AppName_plist-Info.plist", however if I go localization it seems it then has to be set via the "InfoPlist.strings" files.
I can see in XCode where it specifies the "AppName_plist-Info.plist" file name, in the Target/BuildSettings/Packaging information area, but I don't see mention of "InfoPlist.strings", so how does Xcode/IOS know to override what is in "AppName_plist-Info.plist" based on what's in "InfoPlist.strings"?
Xcode doesn't really override the name, it creates localizations in your apps bundle. iOS will look for the name of the app in de localization folder to which the language of the system is set.
These files have pre-determent names, thus you can not set them.
All the localized files will be for example in bundle.app\en.lproj for english or bundle.app\nl.lprojfor dutch.

iPhone wrong Localizable.strings used

I have a project with different Localizable.string files:
../en-GB.lproj
/Localizable.strings
../en-US.lproj
/Localizable.strings
../fr-FR.lproj
/Localizable.strings
../fr-CH.lproj
/Localizable.strings
etc... with about 10 different languages. All are UTF16 encoded. I use XCode4. When I configure my test iPod in fr-FR and launch my app the line:
NSLog(#"Current Locale: %#", [[NSLocale currentLocale] localeIdentifier]);
returns: Current Locale: fr_FR
But all my NSLocalizedString(#"my_string",nil) always return the values located in my Portugese localizable. Any clue for that problem?
Not sure if this applies to you, but i have noticed similar problems using ShareKit. It wasn't ShareKit's problem per se, but the problem involved localizable.strings files inside the library that overlapped mine (for example, I had 2 localizable.strings for the english language. One was mine, the other one was for sharekit).
The app was running, and was finding it difficult to decide which of the two localizable.strings file should it choose to draw strings from.
The solution was transferring all strings in one file end deleting the duplicate files, of course.
I hope I helped.
Firstly check your Scheme Options. You might have changed the "Application Region" which in above case maybe set to "Portugal". This should be set to "System Region" and "Application Language" to "System Language"
Make sure that you're dragging the localized files to their right folder. It's pretty easy to put in the wrong place.
Have a look here for the complete list of what you should do, including screenshots of where you should drag the translations in the project tree:
http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/
Try doing a clean and remove the app off the device/simulator and rebuild/deploy.
I have run into issues when adding new localisations and the device caching the app resources.
Also when I localise I tend to use the country code as the name for the .lproj folder eg.:
en.lproj
fr.lproj

Xcode - Importing different header file with same name based on Target

I have a project with multiple targets each of which builds a pretty similar versions of the app but with different images assets and plists. For plists/images that's fine but I use the ShareKit and Appirater frameworks which have header files with #defines for their config. For each version I believe need to import a different version of this header file, as the config is different for each app built by each target.
So target A has SHConfig.h
and target B has a DIFFERENT SHConfig.h
I could edit the source for these frameworks to import different headers based on the target but that'd be messy when I come to upgrade the frameworks.
Is there a better way to import different header files (with the same name) based on the target?
Assuming they're in different directories, set the Header Search Paths in each target to put the correct directory first.
You may want to set it to something like $(SRCROOT)/foo:$(HEADER_SEARCH_PATHS), though I'm not sure whether that's necessary.
What I found useful was to put the Common directory name in the header search path, and then to use a different #import. My directory structure was Common/Views/v1 and Common/Views/v2. I wanted the v1 for one target and the v2 for another.
In my case, the search path I used in Header Search Paths was:
$(SRCROOT)/../Common/
Then, I used:
#import <Views/v2/ActivityIndicator.h>
In the target that needed the second version (this finds $(SRCROOT)/../Common/Views/v2/ActivityIndicator.h).
Oddly, the other target (the first one I created) is fine without specifying the full path. I.e.,
#import "ActivityIndicator.h"
works to find $(SRCROOT)/../Common/Views/v1/ActivityIndicator.h
Following process solved the issue for me
Select specific target
Under "Build Phases" --> add "New Headers Phase" --> Expand "Headers" --> click on add(plus symbol) and --> browse to the file to be added specific for the target. (It will add file under 'project' section).
Repeat the process for other targets.
Tested on Xcode 10.2

Change a localized InfoPlist.strings using an Xcode target

Here's an obscure problem. I'm using an InfoPlist.strings to localize my app name. It's only got one value: CFBundleDisplayName = "Mon App". The strings file is localized (putting it in a directory for that localization).
I've just made an extra target, where I change things like the non-localized app name (different Info.plists), and the icon. I'm also changing the Default.png using a run script build phase (copying different files depending on the app type I'm building).
I've tried using the script to copy different versions of my InfoPlist.strings, but I couldn't make it work. Here's what I used:
if($TARGET_NAME == "MonApp")then
cp fr.lproj/MonApp_InfoPlist.strings fr.lproj/InfoPlist.strings
endif
I've seen a post suggesting wincent strings util for processing strings, but wanted to see if there's an easy way to do this. Any help greatly appreciated.
You don't need to do this.
If you have fr.lprog/InfoPlist.strings and en.lproj/InfoPlist.strings in your project, you should see just one InfoPlist.strings entry, with two subitems fr and en. If you drag and drop the InfoPlist.strings file into a Copy Bundle Resources build phase, all localized versions will be copied into the appropriate .lproj files at build time. You don't need to create a separate target or write a script to do this; the right thing happens.