核心数据的多语言方法
我想实现一个支持多种语言的应用程序。 我想使用核心数据,但我不知道如何使用不同的语言。
我必须创建两个单独的数据库吗?最好的方法是什么?!
谢谢大家,亚萨
I would like to implement an app with multiple languages support.
I would like to use core data but I don't know how to feature the different languages.
Do I have to create two separate databases? What is the best approach?!
Thanks you all guys, yassa
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于找到了一个可行的解决方案,但我不知道这是否是最好的方法。
我只有一个数据库,但在其架构中,对于每个主要实体,我创建了另一个实体来存储多种不同语言的翻译:
实体(1:M)entity_translation
在我的翻译表中,我有一种“语言”存储有关行所引用的区域设置的信息的列。
希望有帮助,
亚萨
I have finally found a working solution, but I don't know if this is the best approach.
I've only one database, but in its schema, for each main entity, I've create another entity to store translations in many different languages:
entity (1:M) entity_translation
In my translation tables, I've a "language" column to store information about the locale to with the row is referring to.
Hope it helps,
yassa
您到底想本地化什么?这取决于您的数据,尽管我认为没有理由拥有多个数据库。
如果您想本地化核心数据中的字符串,并且它们是有限的,您可以通过 Localized.strings 存储本地化密钥和翻译。
一般来说,您的数据不是本地化的,而是您的字符串。即,如果有人提供了他们的名字,则不会被翻译。
What exactly are you trying to localize? It depends on your data, though I'd see very little reason to have multiple databases.
If you want to localize the strings in your Core Data, and they're finite, you can store localization keys and translation via Localizable.strings.
Generally your data isn't localized, your strings are. i.e., if someone provides their name, it's not translated.