字符串常量作为本地化字符串 [英] String Constant as a Localized String

查看:108
本文介绍了字符串常量作为本地化字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想本地化我的常量。常量是以通常的方式定义和声明的:

I would like to localize my constants. Constants are defined and declared the usual way:

extern NSString * const kStringName;

NSString * const kStringName = @"Whatever...";

如何使其可本地化?这是行不通的......

How to make it localizable? This just can not work...

NString * const kStringName = NSLocalizedString(@"Whatever...", @"Whatever...");

谢谢!

推荐答案

const变量可能已在编译时进行了优化,因此您无法在运行时更改它。你根本就不能拥有const本地化的字符串。

A const variable may already optimized at compile time so you can't change it at runtime. You simply can't have const localized strings.

这篇关于字符串常量作为本地化字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆