zoul
zoul

Reputation: 104065

One application window not loading localized strings

I have an OS X application that uses the Base Internationalization feature (one XIB + many strings files). I’m launching the app using the -AppleLanguages '(cs)' command-line argument to test the Czech localization. It works, but there’s one particular window that doesn’t load the localized strings, it appears in English (the base development language).

The window is a plain XIB with a localized strings file. I have checked the built product, the strings file is there. The XIB is loaded simply like this:

[[NSWindowController alloc] initWithWindowNibName:@"NibName"]

When I turn on the Show non-localized strings debug switch in the build scheme editor, I get a bunch of these warnings in the console:

Localizable string "B1p-qW-vKP.title" not found in strings table "NibName" of bundle CFBundle 0x100305400 </System/Library/Frameworks/AppKit.framework> (not loaded).

I have tried a clean build and also deleted the Derived Data folder to start afresh. Also tried deleting the XIB and replacing it with a simple testing window with just one localizable string. Nothing helps. What could I be doing wrong?


Update: When I remove a localized string from one of the working strings files, the error message at runtime is a bit different:

Localizable string "90.title" not found in strings table "AppMenu" of bundle CFBundle 0x100202460 </long/path/to/My.app> (executable, loaded).

Note that the bundle is different. It looks like in the case of the spurious window the localization system is trying to load the strings from a wrong bundle (AppKit.framework). Why?

Upvotes: 1

Views: 306

Answers (1)

zoul
zoul

Reputation: 104065

I see. Since I needed no custom behaviour in the window, I was using a plain NSWindowController with a custom XIB interface. But at runtime, the localization system was loading the strings from the bundle associated with this class: the AppKit. I created an empty NSWindowController subclass and now the strings are loaded correctly from my app’s bundle.

Upvotes: 1

Related Questions