【发布时间】:2014-09-08 17:58:00
【问题描述】:
我正在处理我的应用程序的本地化,如果将我的应用程序中的所有可本地化字符串“集中化”以通过某个静态方法提供是一个好主意:[AppStrings stringWithType:type],我很感兴趣。
一方面,中心化的方法似乎会让将来编辑可本地化的字符串更容易,但另一方面,字符串本身不再可读,我将不得不定义很多枚举类型。
在大型项目中进行字符串本地化的正确方法是什么(要本地化 100 多个字符串)?我应该在代码中嵌入 NSLocalizedString(),还是应该尝试以某种方式集中提供这些字符串?
typedef enum : NSUInteger {
ksCheckingCredentials,
ksError
} kStringType;
+(NSString*)stringWithType:(int)type
{
switch (type) {
case ksCheckingCredentials:
return NSLocalizedString(@"Checking Credentials",
@"Inform the user that credentials check is being performed");
break;
case ksError:
return NSLocalizedString(@"Error",
@"Generic error message to display to the user");
break;
default:
break;
}
}
-- 或者-- 我是否只在我的应用中的 100 个不同位置使用下面的代码?
self.errorLabel.text = NSLocalizedString(@"Error",@"Generic error message to display to the user");
【问题讨论】:
标签: ios objective-c localization translation localizable.strings