IOS 应用程序多语言支持与数据库

发布于 2024-12-29 18:27:17 字数 276 浏览 7 评论 0原文

我正在使用核心数据作为数据存储为 ios5.im 开发应用程序。我必须显示一些信息,这些信息以 4 种语言保存在数据库中,用户可以选择语言。选择语言时,整个应用程序应通过获取翻译为所选语言来自数据库的字符串。当应用程序启动时,数据库与远程数据库同步。数据库与远程数据库同步(数据库是动态的,因此无法使用字符串文件来翻译我的应用程序)。(除了翻译之外,所有其他内容均已实现,我一直坚持使用数据库进行翻译,当用户选择语言时我有一个小想法整套字符串加载到用户默认值,但我认为这是不正确的)关于使用数据库中的字符串翻译ios应用程序有什么想法吗?

im developing application for ios5.im using core data as data storage.i have to display some information and those informations are saved in 4 languages in database, user can select language.when selects a language whole application should translated in to selected language by fetching strings from database.the database sync with remote database when application starts database sync with remote database(db is dynamic therefore can't use string file to translate my app).(except translation thing all other things are implemented im stuck with translation with db,i have small idea when user select language whole set of string loaded to user-default but i think it is not correct)any idea about translation ios app with strings in database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不喜欢何必死缠烂打 2025-01-05 18:27:17

Localized.strings 使用键/值对方法。在你的数据库中做类似的事情。将标记(键)分配给您的字符串(值)以及该语言的标志。 “标志”可以是整数、字符串或您最喜欢的任何内容。

然后您的 FetchRequest 可以查询令牌和语言标志,并将返回与令牌和标志匹配的字符串。当用户更改语言时,标志也会更改,并且对于与之前相同的标记,但现在使用新标志,获取请求将返回所选语言的字符串。

Localizable.strings uses a key/value pair approach. Do something similar inside your db. Assign a token (key) to your string (value) plus an flag for the language. The "flag" can be a integer, string, what-ever-you-like-most

Then your FetchRequest can query for the token and for the language flag and will return the string that is matching token and flag. When the user changes language the flag is changed, too, And for the same token as previously but now with the new flag a fetch request will return the string for the selected language.

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