0

This has been bothering for days now.

I've set up Arabic localisation in my project and I've set my device Language to Arabic.

When I run my app from Xcode with the run scheme option set to use Arabic Localization, localisation works fine.

When I run the app without Xcode, the app uses English.

I've read the answers to similar questions but none of them have worked for me thus far.

  • I am using NSLocalizableString(@"login",@""); to load the strings from the Localizable.strings file. This works fine as long as I set the Run scheme localization option to Arabic.

  • I've tried uninstalling the app, cleaning the project and then re-installing. Now the app uses the Localizabe.strings key names instead of their arabic values.

  • The Localizable.strings file is named correctly, and is listed under "Copy Bundle Resources".

  • The Localizable.strings is perfectly formatter. I've verified this using plutil.

What else could I be missing?

Example:

-(void) viewDidLoad
{
    [super viewDidLoad];

    // ...

    [self setupLocalization];
}

-(void) setupLocalization
{
    self.mailAddress.placeholder = NSLocalizedString(@"email_address", @"");
    self.password.placeholder = NSLocalizedString(@"password", @"");
}
W.K.S
  • 9,787
  • 15
  • 75
  • 122
  • Can you please show us the code which you are using to gather Localizable strings from the file? – MrAsterisco Jan 02 '17 at 14:43
  • Check `[NSLocale currentLocale]` in logs when you're running the app on the real device. Locale can be defined with country and there are a lot of combination `Language - Country` for Arabic language (check [this](https://gist.github.com/jacobbubu/1836273)). – dive Jan 02 '17 at 15:26

2 Answers2

0

Are you calling NSLocalizedString(_:,comment:) to convert your strings to localized strings?

If you are not doing that, that is the reason it is not working.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/14762496) – Draken Jan 02 '17 at 15:21
  • 1
    @Draken, if the OP was not calling NSLocalizedString then this would be the cause of the problem. I did not phrase my answer in those terms, but it was a possible cause and solution to the problem, so I posted it as an answer. – Duncan C Jan 02 '17 at 15:51
  • It did pop up in the review queue and the wording of the answer was quite poor to look like something that was a comment rather than an answer. Just something to bear in mind for the future – Draken Jan 02 '17 at 15:55
0

I found out what the issue is:

AppDelegate's application:didFinishLoadingWithOptions: contained this snippet of code

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@[@"en"] forKey:@"AppleLanguages"];
[defaults synchronize];

which forces NSLocalizedString() to return English values.

The project was outsourced and I had no idea that the snippet was there.

Community
  • 1
  • 1
W.K.S
  • 9,787
  • 15
  • 75
  • 122