Multiple Localizable.strings files in one iOS app

前端 未结 4 1502
余生分开走
余生分开走 2020-12-24 05:17

Is it possible to have multiple components that have their separate localizations in an app?

For example I want to localize strings in my app but also use ShareKit w

4条回答
  •  被撕碎了的回忆
    2020-12-24 06:19

    oh ok, I don't know ShareKit, but i guess you cannot edit its text files and just add your new words to that files, isn't it?

    then you may consider to create your own "dictionary" file and try to localize it, then read it and put it in a NSDictionary where you can read the single words/value... you can insert a record in your file "myDict.plist" with key "greeting" of type String with value "ciao" for the italian one and "hallo" in the english one

    NSString *bundle = [[ NSBundle mainBundle] pathForResource:@"myDict" ofType:@"plist"];
    NSMutableDictionary *savedStock = [[NSMutableDictionary alloc] initWithContentsOfFile:bundle];
    NSString *greetingsTranslatedInTheGoodLanguage = [savedStock objectForKey:@"greeting"];
    // just to try what you have read:
    NSLog (@"translated by your own dictionary: %@", greetingsTranslatedInTheGoodLanguage);
    [savedStock release];
    

    luca

    ps read the comments too...

提交回复
热议问题