On 10 Oct 2012, at 11:45, Ken Thomases <k...@codeweavers.com> wrote:

> On Oct 10, 2012, at 4:25 AM, Luc Van Bogaert wrote:
> 
>> I'm in the process of localising my application, and I'm having a problem 
>> getting some of the string resources in my code localised. In several places 
>> in my code, I'm using this kind of structure to implement "dynamic" menu 
>> items:
>> 
>>   if (action == @selector(toggleInspectorPanel:)) {
>>       if ([(NSObject *)item isKindOfClass:[NSMenuItem class]]) {
>>           [(NSMenuItem *)item setTitle:([self isInspectorCollapsed] ? 
>>             NSLocalizedString(@"Show Inspector Panel", @"Menu item to show 
>> the Inspector panel") : 
>>             NSLocalizedString(@"Hide Inspector Panel", @"Menu item to hide 
>> the Inspector panel"))];
>>           return ![self.inspectorSplitter isAnimating];
>>       }
>> 
>> Even though both string resources exist and have been translated in my 
>> Localized.strings files, I'm always seeing the original English text when I 
>> run my localized application.
>> 
>> The exact same problem occurs with string resources that are provided to 
>> some control in my interface (eg. e dropdown menu) through a binding:
>> 
>> - (NSArray *)startupModeNames
>> {
>>   return [NSArray arrayWithObjects:
>>           NSLocalizedString(@"Sketch Mode", @"Title for SketchBook startup 
>> mode"),
>>           NSLocalizedString(@"Design Mode", @"Title for SketchBook startup 
>> mode"),
>>           NSLocalizedString(@"SketchBook Mode", @"Title for SketchBook 
>> startup mode"),
>>           nil];
>> }
>> 
>> Here also, I'm only seeing the original English text instead of the 
>> localized version that's available in the Localized.strings file.
>> 
>> All the other string recources in my code get translated correctly.
>> Could anyone please help me find out what it is I'm missing here?
> 
> There's nothing special about those uses of NSLocalizedString(), nor anything 
> particularly "dynamic".  If most of your localized strings are working but 
> those aren't, you need to verify your assumptions.  Check that your 
> Localized.strings files are well-formed and properly encoded (UTF-8 or 
> UTF-16). You can use the "plutil" program to check them.  Check that the keys 
> in the .strings files match the keys you're passing to NSLocalizedString().  
> Check that your files don't have some invisible characters embedded in the 
> keys, making them not match.  Check that the values (the translated strings) 
> are really translated and not the untranslated English.  Do all of those 
> checks on the .string files in your built app, not just the source files.
> 


OK, thanks for the assistance and confirming there's nothing wrong with my code.
Adding the strings files to my project in XCode (even though they already 
existed in the <lang>.lproj directories) solved the problem.

Thanks again,

-- 
Luc Van Bogaert




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to