gpt4 book ai didi

android - 如何国际化来自 Firebase 的错误消息?

转载 作者:行者123 更新时间:2023-11-29 14:13:31 27 4
gpt4 key购买 nike

我正在使用适用于 Android 的 Firebase-Authentication 并且从服务器调用返回的所有错误消息仅以英文显示。

当我从异常中使用 ex.getLocalizedMessage() 时,它不应用用户的语言。

我现在打算做的是检查异常实例并加载我自己的消息,但我非常抗拒这样做。

最佳答案

getLocalizedMessage() 来自 Throwable类(class)。根据documentation :

Creates a localized description of this throwable. Subclasses may override this method in order to produce a locale-specific message. For subclasses that do not override this method, the default implementation returns the same result as getMessage().

现在,如果你想这样做,你已经创建了 Throwable 的子类并覆盖了它的 getLocalizedMessage() 方法。

最后一件事,在该方法实现中,使用 Localization 返回默认 Locale 的字符串.

关于android - 如何国际化来自 Firebase 的错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38259184/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com