ios - 如何在 iOS 本地化文件中添加上标字符串

标签 ios swift localization ios11.4

我有可本地化的英语和法语。我想将注册符号显示为单词的一部分,即“MyApp®”。本地化文件的英文部分在 iOS 应用程序 UI 中显示此符号正确。法语版本也需要显示相同的内容,即“MyAppᴹᴰ”,但“M”和“D”之间有空格。

我还尝试使用 unicode,例如 MyApp\u{1D39}\u{1D30}。这在 Swift Playground 中可以工作,但如果我通过本地化文件尝试它,它就不起作用。

iOS 版本:11.4 我只需要在本地化文件中进行更改,而不是在代码中的每个位置都使用 NSAttributed 字符串。 如果有人遇到同样的问题并找到解决方案,请发布。

"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file

print(String(describing: "MyApp\u{1D39}\u{1D30}" // swift playground
print(String(describing: "ᴹᴰ")) // swift playground

"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file
"MyApp®" = "MyAppᴹᴰ" // Localization file- on UI space comes b/w ᴹ and ᴰ

print(String(describing: "MyApp\u{1D39}\u{1D30}")) // swift playground
print(String(describing: "ᴹᴰ")) // swift playground

"MyApp®" = "MyApp\u{1D39}\u{1D30}" // Localization file

在 iOS 应用程序 UI 组件上,应将 MyApp® 呈现为 MyAppᴹᴰ,并且 ᴹ 和 ᴰ 之间没有空格。

最佳答案

为什么不使用实际的 🅫 (U+1F16B) 字符,而不是使用单独的上标 ᴰ<​​ 字符?

在您的本地化文件中,输入:

"MyApp®" = "MyApp🅫"

关于ios - 如何在 iOS 本地化文件中添加上标字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54339047/

相关文章:

ios - 为iOS项目中的每个目标选择不同的语言

ios - 使用 swift 在 webview 页面中查找文本?

ios - Reactivecocoa绑定(bind)UIButton的标题

swift - Cocoapods 0.35 构建失败

ios - UILabel - 在展开可选值时意外发现 nil

iphone - 如何知道 iOS 设备何时插入?

c# - 编程字符串的表单资源使用情况?

未调用 iOS 10 UNUserNotificationCenterDelegate。推送通知不起作用

ios - TableView 数组部分自行重新排序? (程序化修复?)

ios - SWIFT 报告 "Extra argument in call"- 在 Playground 中工作