NSLocalizedString returns text that is not specified anywhere

Well, I'm officially stunned. Some time ago, I started an iOS project and got a little confused with localization, which became a bit messy because I didn't know how to do it yet.

Now I decided to do localization from scratch and, therefore, threw away all the .strings files and created the correct multilingual structure. I started with empty Localizable.strings files and launched the application to check if I cleaned everything correctly. With empty Localizable.string files, I assumed that my calls to "NSLocalizedString" would simply return the key as text. They do not do this. They still return the old text that I had in the old .strings files.

To be sure, I put the NSLog statement in one of the NSLocalizedString calls, as such:

NSString *text = NSLocalizedString( key, nil ); NSLog(@"key=%@ text=%@", key, text); 

Then I scan my entire hard drive for the returned text. On my hard drive, the file does not contain the string returned by NSLocalizedString. And this is a completely different line than the key, so it cannot be created by NSLocalizedString either.

Does anyone know how this can happen? Is old information cached somewhere in Xcode? How can I convince the tool to use the new Localizable.strings files? Obviously, I already "cleaned and rebuilt the entire project."

+4
source share
3 answers

Try to remove the application from the phone, then clean the project and reinstall the application.

If it still doesn’t work, make sure that you haven’t mixed up the assembly rules in some way (Xcode 4 → select the target tab → “Assembly Rules”). There, check if there are too many "CopyStringsFile" rules that do not use "CopyStringsFile". If so, you can delete them all but one.

+4
source

Have you also cleared the build folder? command + option + shift + k or go to the product, press the parameter, a folder with a clean assembly will be created, usually the resource file is cached, any replacement of the resource file (a file with the same file name but with a different object) may not be detected Xcode

Also, removing application / reset syntax helps. Deleted files are not once deleted during redeployment.

0
source

If you are testing a simulator, try resetting the simulator using the "Reset content and settings ..." option in the "iOS Simulator" application menu.

When you redeploy a new build of an application, even after a clean build, it often does not clear the cached content of a previously built version.

0
source

Source: https://habr.com/ru/post/1392722/


All Articles