34

我在本地化我制作的丹麦应用程序时遇到了一些问题。(语言,不是糕点)

我在 info.plist 中将 CFBundleDevelopmentRegion 设置为丹麦语的 da_DK,但出现文本输入的弹出窗口仍然是英语,即使在运行丹麦语操作系统的手机上也是如此。

在此处输入图像描述

我如何在工作名称中更改此内容?

测试设备是运行 iOS 5.1 的未越狱 iPhone 4S,iOS 设置为丹麦语,并关联了一个丹麦语 iTunes 帐户。

我不使用 .xibs 进行设计。所有接口都被编程为视图控制器。

4

6 回答 6

40

在 Xcode 的文件树 (Project Navigator) 中选择您的项目。在右侧窗格中再次选择您的项目。选择信息并添加您的语言。

配置 i18n


我创建了一个示例项目,结果如下:

在此处输入图像描述

于 2012-07-01T13:02:18.203 回答
7

You can do this directly in the info.plist. Something like this:

<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleLocalizations</key>
<array>
  <string>en</string>
  <string>de</string>
  <string>es</string>
  <string>ja</string>
</array>    
于 2016-03-30T14:28:29.003 回答
3

Try adding/setting the "Localized resources can be mixed" flag in Info.plist to YES.

于 2013-12-16T21:20:30.900 回答
2
于 2012-07-01T14:25:30.640 回答
1

If you can't get it working the official way, as provided by @vikingosegundo, you can do this with some creative engineering (Creative as in, oh my god that is dangerous). I discovered this method when I accidentally overrode [NSBundle localizedStringForKey:value:tableName:].

1) Add a category to NSBundle with the following methods:

#import <objc/runtime.h>

+ (void) load  {
    Method original, swizzled;

    original = class_getInstanceMethod(self, @selector(localizedStringForKey:value:table:));
    swizzled = class_getInstanceMethod(self, @selector(swizzled_localizedStringForKey:value:table:));
    method_exchangeImplementations(original, swizzled);
}

- (NSString*) swizzled_localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName {

    NSLog(@"Key: %@. Value: %@", key, value);

    return [self swizzled_localizedStringForKey: key value:value table:tableName];
}

2) Where I simply log the key/value, you want to put an if ([key isEqualToString: xxx] ) block. In there, you want to catch (at least some of) the following key values: Cut, Copy[Menu], Select, Select All, Paste, Delete[Menu], Replace..., Define, Speak, Pause. These are the default values that can appear there.

3) When you have caught the value you can look up in a custom table or use hardcoded values. If you look up in a custom table make sure you have a catch in your swizzled method to avoid infinite looping in your custom table.

NB: Why do you need to swizzle? Because this over-rides all Apple text for you app. You will still want the defaults for all the other strings, so you need to swizzle to get the defaults for the strings you aren't interested in.

Good luck. Paul

于 2012-07-02T08:28:49.090 回答
-1

搜索您的 .xib 是否已本地化(您将在右侧面板的检查器中找到它)如果是,请转到您的项目/目标设置按 + 号并选择“将英语复制到丹麦语”或其他含义相同的内容(我目前无法检查正确的项目)

顺便说一句,它被称为 iPhone 4S。

于 2012-06-27T12:13:54.527 回答