Ios4 NSLocalizedString问题-保存字符串的变量的本地化

Ios4 NSLocalizedString问题-保存字符串的变量的本地化,ios4,localization,nslocalizedstring,Ios4,Localization,Nslocalizedstring,这种方法对于@“属性”的本地化非常有效 现在,如果我想使用一个变量,代码应该是什么 我正在使用 //Viewcontroller.m code NSLocalizedString(@"attributes",@"Attribute Name") //Localizable.string code "attributes"="attributes-french"; 这是行不通的。有人能告诉我使用NSLocalizdString对变量(包含字符串)进行本地化的正确方法吗?您不能对变量名进行本地

这种方法对于@“属性”的本地化非常有效

现在,如果我想使用一个变量,代码应该是什么

我正在使用

//Viewcontroller.m code
NSLocalizedString(@"attributes",@"Attribute Name")

//Localizable.string code
"attributes"="attributes-french"; 

这是行不通的。有人能告诉我使用NSLocalizdString对变量(包含字符串)进行本地化的正确方法吗?

您不能对变量名进行本地化。您仅对变量所持有的值进行本地化。因此您的
可本地化.strings
应该包含

//Viewcontroller.m code
NSString *Value=@"attributes"
NSLocalizedString(Value,@"Attribute Name"); 

//Localizable.string code
"Value"="Value-french"; 

如果有的话,您可以使用所述的
%@
改变字符串的部分。

您不能在变量名上进行本地化。您仅对变量所持有的值进行本地化。因此您的
可本地化.strings
应该包含

//Viewcontroller.m code
NSString *Value=@"attributes"
NSLocalizedString(Value,@"Attribute Name"); 

//Localizable.string code
"Value"="Value-french"; 

如果有任何问题,可以使用所述的
%@
改变字符串的部分。

调用
NSLocalizedString
没有问题,而是使用Localizable.strings文件中的定义

由于将变量
定义为“attributes”,因此函数将使用它作为键来查找正确的本地化字符串

这应该能正常工作:

"attributes"="attributes-french"
我在Swift中测试了类似的代码,结果如下:

//Viewcontroller.m code
NSString *Value=@"attributes"
NSLocalizedString(Value,@"Attribute Name"); 

//Localizable.string code
"attributes"="Value-french"; 
//Viewcontroller.swift代码
让Value=“属性”
NSLocalizedString(值,注释:“属性名称”)
//可本地化的.string代码

“属性”=“值法语”;//
NSLocalizedString
调用没有问题,而是Localizable.strings文件中的定义有问题

由于将变量
定义为“attributes”,因此函数将使用它作为键来查找正确的本地化字符串

这应该能正常工作:

"attributes"="attributes-french"
我在Swift中测试了类似的代码,结果如下:

//Viewcontroller.m code
NSString *Value=@"attributes"
NSLocalizedString(Value,@"Attribute Name"); 

//Localizable.string code
"attributes"="Value-french"; 
//Viewcontroller.swift代码
让Value=“属性”
NSLocalizedString(值,注释:“属性名称”)
//可本地化的.string代码
“属性”=“值法语”//