3

I want to ask you about a problem I'm having with an iOS application related with the Localization. My application has some targets, we use the same application base personalized for every client, it means that every target has an own design, colors, fonts and desirably a different texts for every target views and labels.

We have a parametrisation to maintain this personalization on the application, but I have a problem with the localization. I would want to have a different bunch of localized strings for every target in the different languages, because maybe in one target a view have to show "Bike stations" but in another one "Car stations" (in the corresponding language).

I could have a unique localized file for every language with the different params adding a prefix for every target string, but that is not so maintainable. I'm trying to find a way to maintain the structure simple having the same literals for every app changing only the texts that every client wants on every label.

I tried to defined two different Localizable files and asign every one of them to a unique target, as you see on the image below

Localization by target

But when I open my second target, any localizable string is recognized

Do you know what could be my problem or how can I do to define different localize files in multiple languages for every target?

Thanks in advance for your help :)

Thais
  • 128
  • 7

1 Answers1

3

I have a Translation class where I have a forKey:NSString method.

NSString *text = NSLocalizedStringFromTable(key, @"Localizable_base", nil);
text = NSLocalizedStringWithDefaultValue(key,
                                         @"Localizable_target",
                                         [NSBundle mainBundle],
                                         text,
                                         nil);
if(!text)
    text = key;

First getting the default value. Then passing it as default value to the target specific. If you have strings that are not listed in base, first get the target-specific, check if there is a value and if not, set text to the default.

you can also take a look to my old question that had to deal with different languages for targets: Allow only specific translations for different schemes/targets

Community
  • 1
  • 1
geo
  • 1,781
  • 1
  • 18
  • 30