本地化应用程序,但不是很多。日期问题

发布于 2025-01-31 12:40:50 字数 690 浏览 4 评论 0原文

我们的应用之一仅在意大利使用。因此,目前,唯一可用的语言是意大利语。所有字符串都是意大利语,但是对于许多用户来说,用另一种语言设置设备(例如英语)是一种常见的做法。 格式化localdate s dateTimeFormatter,或date s dateutils,我们默认情况下获得所有字符串在locale.getDefault()的语言环境中翻译。

结果是一个意大利应用程序,其中有其他语言,对于没有意大利语作为默认语言环境的用户。

我们想到了两种不同的解决方案,但我想对其他方法提出意见或建议。

我们想到的第一个解决方案是通过从value/strings.xml文件中获取Locale的标签来为整个应用程序设置为默认场所。由于将来会有其他受支持的语言,因此每种语言都会具有适当的语言环境标签,并且该应用程序将始终为每个字符串使用相同的语言。

另一种方法是定义一个名为customDateFormatter的通用接口,用ItalianCustomDateFormatter,将其注入它,将来,将其替换为International -CustomDateFormatter

您对这个问题有一些建议吗?您如何解决(或解决)?

One of our apps is only available in Italy; so, currently, the only available language is Italian. All strings are Italian, but it is a common practice for many users to set the device in another language (e.g., English).
When formatting LocalDates with a DateTimeFormatter, or Dates with DateUtils, we obtain, by default, all strings translated in the Locale.getDefault()'s locale.

The result is an Italian app with some parts in another language, for users which don't have Italian as the default locale.

We thought of two different solutions but I would like to get an opinion or suggestions for other approaches.

The first solution we thought of has been to set for the whole app a default locale, by taking the locale's tag from the values/strings.xml file. Since in the future there will be other supported languages, each language would have its proper locale tag and the app would always use the same language for each string.

Another approach is to define a generic interface named CustomDateFormatter, implement it with an ItalianCustomDateFormatter, inject it and, in the future, replace it with an InternationalCustomDateFormatter.

Do you have some suggestions on this problem? How you'd solve (or have solved) it?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文