swift - 让 Str = 字符串(格式 : "لديك d٪ ثانية متبقية للاتصال", 秒)

标签 swift localization string-formatting arabic

<分区>

如何在 Swift 的阿拉伯字符串中使用 String(format:)

let seconds = 458569

我的代码是:

let arabicStr = "لديك ٪d ثانية متبقية للاتصال"

let Str = String(format: arabicStr,seconds)

和输出:

لديك d٪ ثانية متبقية للاتصال

最佳答案

试试这段代码。

let seconds = 458569
let Str = "لديك \(seconds) ثانية متبقية للاتصال"
print(Str);

let Str2 = String(format: "لديك %d ثانية متبقية للاتصال",seconds)
print(Str2);

enter image description here

关于swift - 让 Str = 字符串(格式 : "لديك d٪ ثانية متبقية للاتصال", 秒),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49532154/

相关文章:

iOS - 如何使用来自 NIB 的特定框架初始化自定义 UIView

ios - 动态 viewForHeaderInSection 和多个 cellForRowAtIndexPath

facebook - 从 Facebook Graph API 获取语言代码/区域

android - 更改设备语言后,我的应用程序的语言没有改变

python - 类型错误:不支持的操作数类型为 %: 'NoneType' 和 'str'

printing - 打印表格的 Pythonic 方式

macos - Swift 协议(protocol)方法与父类(super class)属性冲突

ios swift CMutableVoidPointer 在 observeValueForKeyPath 中无法识别

ios - 应用程序的本地化不会改变应用程序中使用的 cocoapods 的语言

r - 将包含双引号的文本字符串发送到函数