How to get the Current Locale in GWT using LocaleInfo

后端 未结 3 787
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 15:14

I have tried to get the current locale on the client using the LocaleInfo class and the method getCurrentLocale(). However it always returns the value default locale no matt

3条回答
  •  抹茶落季
    2020-12-19 15:34

    It's almost impossible to accurately get the locale of the user in JavaScript so GWT doesn't even try [1].
    LocaleInfo returns information about the locale selected among the ones you compiled in your app; that is, one of the locales you added using in your *.gwt.xml.

    See https://developers.google.com/web-toolkit/doc/latest/DevGuideI18nLocale

    [1] well, in recent versions it does try (using the browser's compile-time locale), but only to select one of the compiled-in locales, so that doesn't change anything to the behavior of LocaleInfo.

提交回复
热议问题