For NSLocalizedString, can the "key" be shortened to point to full size translation?

StackOverflow https://stackoverflow.com/questions/17503604

  •  02-06-2022
  •  | 
  •  

Вопрос

I have attempted to localize my iPad app (XCode 4.6.3, ARC, Storyboards, iOS 6.2). I have some very long "keys" (over 200 characters long) used for HTML in a UIWebView popover... when running the app, none of the HTML translations are displayed, but rather the actual HTML "key" in the app is used (not the one from the Localized.strings file; I modified both the "key" in the app and in the Localized.strings file and the app's "key" is what get's displayed).

I'm beginning to believe that the length of the "key" is the problem. Is there a way I can shorten the key and maybe have it point to a different file or something? Or maybe put the translated HTML into a .plist?

Это было полезно?

Решение

I figured it out... in case others have the same/similar problem; I took the html and put it into a file, one for each language... then this is the code I used to load the files:

- (void)viewDidLoad  {

[super viewDidLoad];

//  determine what the language for this locale is...
NSURL *indexURL;
NSString *sysLangCode = [[NSLocale preferredLanguages] objectAtIndex:0];

//  do we support this language?    
if([sysLangCode isEqualToString:@"en"] || [sysLangCode isEqualToString:@"de"] || [sysLangCode isEqualToString:@"it"] ||
   [sysLangCode isEqualToString:@"es"] || [sysLangCode isEqualToString:@"fr"] || [sysLangCode isEqualToString:@"ja"] ||
   [sysLangCode isEqualToString:@"zh-Hant"] )  {

    indexURL = [[NSBundle mainBundle] URLForResource: [NSString stringWithFormat:@"instRST-%@", sysLangCode]
                                       withExtension:@"html"];   //  contatenate the language code to the filename
}
else
    indexURL = [[NSBundle mainBundle] URLForResource: @"instRST-en" withExtension:@"html"];  //  make 'en' the default

[webView loadRequest:[NSURLRequest requestWithURL:indexURL]]; //  load it...

}

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top