问题描述
我有一个应用程序,我正在翻译成一堆不同的语言。问题是,澳大利亚的应用程序在新西兰会有一些不同的值,这两个都是英语国家。
I have an app that I am translating to a bunch of different languages. The problem is that the app will have a few different values in Australia than will in New Zealand, which are both English speaking countries.
我创建了一个en_AU和一个en_NZ语言文件,但他们都使用标准的英文文件。我删除了英语文件,但它仍然会发生......
I have created an en_AU and an en_NZ language file, but they're both using the standard English file. I deleted the English language file, but it continues to happen...
关于如何让它工作的任何想法?
Any ideas on how I can get this to work?
谢谢,
- d
推荐答案
iPhone本地化(或本地化?)不会注意到用户设置的区域(即英国,澳大利亚,新西兰)。默认情况下,只有一种英语语言翻译可用。但是,你可以通过黑客攻击来强制它使用不同的翻译设置 - 我刚刚在英语(美国)和en_GB(英国英语)之间进行选择。
iPhone localisations (or is that localizations?) do not take any notice of the Region the user sets (ie, UK, Aus, NZ). There is only one "English" language translation available by default. However, you can hack around with things to force it to use a different translation setting - I've just done this for choosing between "English" (US) and "en_GB" (British english).
在你的main.m文件中,改变它,使它看起来如下所示(放入你自己的新西兰或澳大利亚测试中)
In your main.m file, alter it so it looks something like below (put in your own tests for NZ or AU)
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// Set up the locale jiggery pokery
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
NSString *locale = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
if ([language isEqualToString:@"en"] && [locale isEqualToString:@"GB"]) {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en_GB", @"en", nil] forKey:@"AppleLanguages"];
}
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
这会弹出用户语言(例如en)进入语言NSString,并将用户区域设置(例如,NZ,GB,AU)放入语言环境NSString中。如果他们(在我的情况下)匹配en和GB,那么我将用户默认语言首选项设置设置为en_GB,然后设置为en。
This pops the users language (eg "en") into the language NSString, and the users locale (eg, NZ, GB, AU) into the locale NSString. If they (in my case) match en and GB, then I set the users default language preference settings to be "en_GB", then "en".
然后,在你的应用程序委托应用程序:didFinishLaunchingWithOptions方法你要删除你刚用代码设置的NSUserDefaults设置
Then, in your application delegates application:didFinishLaunchingWithOptions method you want to remove that NSUserDefaults setting you just set with the code
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"AppleLanguages"];
此时可以安全删除,因为所有捆绑包初始化都已完成。您的应用现在应该使用en_GB.lproj目录中的Localization.strings文件。
It's safe to remove at this point because all the bundle initialisation has been completed. Your app should now be using a Localization.strings file within the en_GB.lproj directory.
这是一个可怕的,hacky解决方案,但它适用于我。
It's a bit of a horrible, hacky solution, but it works for me.
这篇关于iPhone App本地化 - 英文问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!