本地化应用程序,但不是很多。日期问题
我们的应用之一仅在意大利使用。因此,目前,唯一可用的语言是意大利语。所有字符串都是意大利语,但是对于许多用户来说,用另一种语言设置设备(例如英语)是一种常见的做法。 格式化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 LocalDate
s with a DateTimeFormatter
, or Date
s 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论