10

I'm unable to get the correct localized german strings from the Localizable.strings file. My app setup looks like this

  • Main.storyboard

    • Main.storyboard (Base)
    • Main.strings (German) -> these strings are translated correctly
  • Localizable.strings

    • Localizable.strings (English)
    • Localizable.strings (German) -> can't get these strings

Inside the app I'm trying to get the string like this

NSString *item = NSLocalizedString(@"Group expenses", @"Menu item");

The Localizable.strings (German) file looks like this

/* Menu item */
"Group expenses" = "Gruppenausgaben";

When I set a breakpoint after item I always get the English string back, however the path for the resource seems correct NSString *path = [[NSBundle mainBundle] pathForResource:[[NSLocale preferredLanguages] objectAtIndex:0] ofType:@"lproj"]; gives me: /data/Containers/Bundle/Application/5E3ED6BF-71E1-4C60-9EDA-610C9A32B8EF/MyApp.app/de.lproj

I also have localized the string file

enter image description here

enter image description here

It's also included in Copy Bundle Resources

enter image description here

I tried several answers from different questions here on stackoverflow, like deleting app and do a clean (shift+cmd+k), setting application language under Edit Scheme, ...

gpichler
  • 2,181
  • 2
  • 27
  • 52
  • can you please share the source code? If you cannot share the original one, can you try to create a new dummy app which will contain identical localisation setup and which will also fail to work properly? The benefit of doing this (in addition to other users being able to test your code) is that you might be able to identify the reason why it doesn't work on your own – Andriy Gordiychuk Aug 19 '15 at 19:30
  • check out my answer. You had a wrong name for the Localisable.strings file – Andriy Gordiychuk Aug 19 '15 at 19:50

3 Answers3

11

Ok, I think I know the reason for your bug. Parse had an issue with adding Localizable.strings as documented here. This was fixed in 1.8.1 version of their framework:

V1.8.1 — AUGUST 19, 2015

...

Fixed: Overwritten localizations when used via CocoaPods and integrating as static library.

...

You can also check this question.

So, just make sure you use the latest version of the framework and all should work :)

Community
  • 1
  • 1
Andriy Gordiychuk
  • 6,163
  • 1
  • 24
  • 59
  • @user1463853 Yep, I thought it was a possibility. However, you should change the example project so it simulates the same conditions as your original one AND still produces an error. When you do so, you either find the mistake yourself or others will be able to assist you. At the moment it sounds like everything SHOULD be working, so it is extremely difficult to suggest a solution. – Andriy Gordiychuk Aug 19 '15 at 19:59
  • @user1463853 I have updated my answer with another suggestion. And that is that Localisable.string might not be included in your build phases – Andriy Gordiychuk Aug 19 '15 at 20:18
  • @user1463853 it becomes more and more interesting. What if you change the localisation for English? For example "Group expenses" = "Group expenses2". Does it work this way? Also, why you have 3 files localized to English and only 2 to German (thats from your screenshot)? – Andriy Gordiychuk Aug 19 '15 at 20:25
  • @user1463853 Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/87417/discussion-between-andriy-gordiychuk-and-user1463853). – Andriy Gordiychuk Aug 19 '15 at 20:26
0

I encountered a same problem before, some approach you can try:

  • Make sure you set German as your iOS device system language.

  • Run this app in Xcode, then stop. Launch the app from the iOS device manually. (First launch with Xcode will use base language, I don't know why)

  • See if it works

zy.liu
  • 346
  • 4
  • 15
0

Just had a similar issue was cracking my head, do a search of the xx.strings file I had an old copy of the bloody file messing me up.

find ./ -name "xx.strings" -print

double check your string file is proper

plutil -lint  xx.strings
becker
  • 351
  • 4
  • 8