lita icon indicating copy to clipboard operation
lita copied to clipboard

Localization not working properly

Open mtylty opened this issue 9 years ago • 6 comments

Localization seems like it doesn't work properly. I'm trying to use Lita as an Italian bot but...

I've found at least two problems:

  • when running on slack I cannot set a locale different from en. I've tried LANG and config.robot.locale and neither work. I keep getting translation missing errors looking for en locale strings (i18n is instead working fine in the shell adapter, set with the config option);
  • locale strings are useless for route help strings. I'm sure this is related to the fact that routes, being a class-level dsl, are evaluated before a proper locale string is set so they always try to use en locale strings.

I'm not sure I'm doing something wrong but this is driving me crazy and it looks like it might be an actual bug. If somebody could please confirm this I could start working on PR to fix this.

Thanks!

mtylty avatar Feb 21 '16 21:02 mtylty

Those sound like bugs to me. Thanks for the report!

jimmycuadra avatar Feb 22 '16 12:02 jimmycuadra

has this ever been fixed? 5 years from the last comment and I am getting DEBUG: translation missing: C.UTF-8.lita.handler.dispatch all over my logs and sending the help message to Lita provides a large dump of such errors.

AHaymond avatar Apr 07 '21 19:04 AHaymond

Running into this as well right now. Interested if anyone has a solution

tim-fitzgerald avatar Apr 22 '21 16:04 tim-fitzgerald

Part of the issue should be fixed by using "default locale" instead of "locale" which you can do as of v4.8: https://github.com/litaio/lita/releases/tag/v4.8.0. The problem of handler help text not translating is indeed because they are a class-level construct, so the translation is getting run when the file is loaded, which is before the Lita configuration is loaded. This will be addressed in Lita 5 by setting the locale (and the default locale) based on the environment variables LC_ALL, LC_MESSAGES, or LANG very early in the program's execution. Setting the locale via Lita configuration will be deprecated in favor of these environment variables.

jimmycuadra avatar Jun 20 '21 04:06 jimmycuadra

@jimmycuadra setting config.robot.default_locale = :en per release instructions did not fix the issue

jrcasso avatar Sep 29 '21 18:09 jrcasso

@jrcasso Try setting LANG=en and see if that helps? That was what helped me.

silvamerica avatar Oct 20 '21 21:10 silvamerica