首页 > 解决方案 > Swift本地化StringWithFormat数字输出而不是Text

问题描述

目前我正在为我的应用程序进行本地化。当我想注销用户时,我想在警报中告诉他的名字。所以我使用了以下代码:

let name = "Matthias Kremer"
let formatedString =  NSLocalizedString("logoutTitleWithName", comment: " abmelden?")
print( String.localizedStringWithFormat(formatedString, name))

Localizable.string 文件如下所示:

"logoutTitleWithName" = "%d abmelden";

我应该得到以下出口:

马蒂亚斯·克雷默·阿梅尔登

但相反它是

281,600 阿梅尔登

它看起来像是字符串以某种方式转换为数字。有谁知道如何处理这个?

标签: iosswiftlocalization

解决方案


改变

"logoutTitleWithName" = "%@ abmelden";

%d是十进制值的替换,而%@是字符串


推荐阅读