开发者

Localisation_setting.bundle

开发者 https://www.devze.com 2023-02-14 20:25 出处:网络
Just wanted to ask, how to localize Xibs via settings.bundle? Actually, I need to make my Xib arabic through settings.bundle. I have searched a lot for this. Please give me proper suggestio开发者_如何

Just wanted to ask, how to localize Xibs via settings.bundle? Actually, I need to make my Xib arabic through settings.bundle. I have searched a lot for this. Please give me proper suggestio开发者_如何学JAVAns otherwise i need to recode my application and remove all contents of Xibs and do it via coding which would take a lot of time.

Thanx in advance.


I followed this post to get apps localised.


you can localize you nib file by keeping you xib file in specific language folder, e.g. en.lproj/View1.xb is the english version and ar.lproj/View.xib is the arabic version for more detailed instructions see this

UPDATE: for that you simply create

  • View-en.xib
  • View-ar.xib

and then based on your custom settings

NSString *xibName = [NSString stringWithFormat:@"View-%@", @"en"];    
id localVC = [[LocalViewController alloc] initWithNibName:xibName bundle:nil];


hit 'get info' by right clicking the xib you wish to localize... and within the general screen you can see the 'Make File Localizable' button on there.


@aamritrao if you make two separate XIB files, one for each language, you shouldn't give them different names as that just complicates things unnecessarily. Just name them the same but put them in different localized project folders.

So:

en.lproj/View1.XIB

and

ar.lproj/View1.XIB

Then when your app needs View1.XIB it will always use the appropriate one for the language the user has set in their device settings.

Sorry if this is not what you are looking for. Not sure what you mean by 'Localization via settings bundle'... could you explain more?


Hey just paste this following code in your main.m file

       NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        NSString *strLang=[[NSUserDefaults standardUserDefaults] stringForKey:@"PSMultiValueSpecifier"];
       NSLog(@"Hi%@",strLang);
    //    
        if ([strLang isEqualToString:@"0"]) {
            [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
            [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", @"ar",  nil] forKey:@"AppleLanguages"];
            [[NSUserDefaults standardUserDefaults]synchronize];
        }
        else if([strLang isEqualToString:@"1"])
        {
            [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
            [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"ar", @"en", nil] forKey:@"AppleLanguages"];
            [[NSUserDefaults standardUserDefaults]synchronize];
        }

  int retVal = UIApplicationMain(argc, argv, nil, nil);
    [pool release];
    return retVal;
0

精彩评论

暂无评论...
验证码 换一张
取 消