核心数据的多语言方法

发布于 2025-01-01 00:13:42 字数 100 浏览 2 评论 0原文

我想实现一个支持多种语言的应用程序。 我想使用核心数据,但我不知道如何使用不同的语言。

我必须创建两个单独的数据库吗?最好的方法是什么?!

谢谢大家,亚萨

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

因为看清所以看轻 2025-01-08 00:13:42

我终于找到了一个可行的解决方案,但我不知道这是否是最好的方法。

我只有一个数据库,但在其架构中,对于每个主要实体,我创建了另一个实体来存储多种不同语言的翻译:

实体(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

給妳壹絲溫柔 2025-01-08 00:13:42

您到底想本地化什么?这取决于您的数据,尽管我认为没有理由拥有多个数据库。

如果您想本地化核心数据中的字符串,并且它们是有限的,您可以通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文