Anila
Anila

Reputation: 1136

Xcode localization: All strings are not translated

I've an iPhone app that i wanted to localize so i've added chinese localization. To do so I added Localizable.strings(chinese) to my app and i added the strings in it.

But a weird thing happens when I compile, only half or maybe even less of the strings are translated. I've tried everything i could:

even putting working string & keys in not-working string but nothing is working.

All of my elements are UILabels and I've checked every single configuration for each of them. They all have the same configurations. It can be because of the project configuration but then why does some work? I have checked some other answers and tried the solutions (checking my keys, file name etc) but nothing is working. Please help me understand why is it happening.

EDIT: Here's how I print my strings

//this one doesn't work
self.resolution.text = NSLocalizedString(@"RESOLUTION", nil);
//this one works
self.label1.text=NSLocalizedString(@"CAMERAS", nil);

And in my Localizable.strings file i have

"RESOLUTION"="Resolution";
"CAMERAS"="Cameras";

Upvotes: 3

Views: 2232

Answers (5)

tamtoum1987
tamtoum1987

Reputation: 2057

Change your .strings file name to Localizable.strings, it worked for me.

Upvotes: 0

Mukund Agarwal
Mukund Agarwal

Reputation: 585

I had the similar issue. In my case, it was because the speech marks were different character codes in the *.strings file after copying the translation from Google translate. Reentering the speech marks fixed it.

Upvotes: 0

parev
parev

Reputation: 11

Coming back with Xcode 7. With one more trick.

I had the same problem but none of the above solutions did work (I'm not saying that it wouldn't work in other situations).

The solution was that I have a double ; at the end of one definition (probably due to some cut,copy,paste operation). There was no compilation error or warning. I simply removed the redundant ; and that worked again.

Upvotes: 1

Anila
Anila

Reputation: 1136

The soltuion to my problem was to delete app from simulator clean and build again as explained by holographix. Thanks holographix :)

What i still don't understand is that i tried the procedure many times and it didn't work and then just like that it decided to start working. Even though my problem is solved it's still a mystery to me.

Upvotes: 1

holographix
holographix

Reputation: 2557

make another check, like inverting the order of the elements: try putting on the top on of the strings that does not figure out translated. then as a proof of concept try making a third localized file with non utf-8 chars (like in plain text with no frills)

Upvotes: 1

Related Questions