Change default language for UI

Hi!

Can anyone please help me to figure out how I can change the default language for OpenEMS UI? I have tried to change the language of the admin user during local testing on my PC, but it seems to be reset (set back to german) on the next run.

I am running the UI connected to an edge instance.

Hi,

You can change the default language in the Language.ts file( openems/language.ts at develop · OpenEMS/openems · GitHub ).

You can see a static field which is DEFAULT = Language.DE ( openems/language.ts at develop · OpenEMS/openems · GitHub );

You can change it to the language you want to. The same default language is being applied in app.module.ts ( openems/app.module.ts at develop · OpenEMS/openems · GitHub )

Thanks,
Sagar

Hi to all!

I’m approaching to OpenEMS for personal interest.
It is very usefull and I want to go in deep with this platform.
Thanks to this thread I was able to change language from DE to EN.
Now I’m thinking to add italian language module. Is it possible?
Which way to do this? If anyone explain how to, I’m ready to implement it and give my contribute to the community with a new language module.

Thank you all in advance,
Francesco

Hi,
i guess it is all loaded from the json file

so if you add there it.json it should work (as far as i know)

best regards

Paul

Hello thank you @p.wimmer for support. I’m contributing with a new language (italian) to the platform thanks to your advice.
I followed the steps above of @venu-sagar but I was unable to change the language.
I set as DEFAULT Language.EN but web I connect to localhost it show me german language again…is there a step by step guide to do that? and also to cusomize the graphic and logo of the appliance for my coop?

Thank you in advance,
Francesco

Hello,

the user has also a language and by default this language will be used.

localStorage.LANGUAGE = language.key;

so you should deactivate this.

No there are no stepbystep guides, because this project is tooo huge for so many stepToStep guides.

I don’t know what you mean by customize “graphicc”?! you mean the circle? sure. feel free if you can do this. the logo is quite easy. just exchange it in themes folder, or use the “theming” itself.
best regards
Paul

Hi Francesco,

to add a new language, you would have to do the following:

  • Add the language to language.ts openems/language.ts at develop · OpenEMS/openems · GitHub

    • Imports on top:
      import de from 'src/assets/i18n/it.json';
    • Add language tag:
      public static readonly IT: Language = new Language("Italian", "it", it);
    • List of ALL language tags:
      public static readonly ALL = [Language.DE, Language.EN, Language.CZ, Language.NL, Language.ES, Language.FR, Language.IT];
    • Add to getByBrowserLang():
      case "it": return Language.IT;
  • Add your translation file in src/assets/i18n/it.json; start by copying one of the existing files

Internally we currently use the i18n-ally extension for visual studio code to keep our translations in sync: GitHub - lokalise/i18n-ally: 🌍 All in one i18n extension for VS Code

Regards,
Stefan

Please explain what it means ‘deactivate this’.
Do I comment it out? What?

Thanks
James

localStorage.LANGUAGE = language.key;

so you should deactivate this.

Thank you Paul. I think we are having a language barrier. Please try a different way of explaining. Do you mean comment it out? Set it to 0 or maybe false? Delete it?
I’m sure it’s obvious but we are missing the point :see_no_evil:

I changed default to Language.EN in langauge.ts

I commented out this line in websocket.ts (above).

Now when I go to localhost:4200 and login as admin, the language is German but when I go to change it, it says it’s English.

What have I missed, please?

Hi @JimsterCoder,

I tested this myself locally and yes - there is unfortunately a mixture of “trying to be smart” and different places with currently hard-coded “default to German” language/locale settings.

In UI there is a default setting for the language:

In Edge there is a default, hard-coded language per User, which is applied here:

In Backend there is a default, hard-coded language in the DummyMetadata provider here:

Regards,
Stefan

I followed the above suggestions.

  1. I changed in https://github.com/OpenEMS/openems/blob/develop/ui/src/app/shared/type/language.ts#L36
    pic1
  2. https://github.com/OpenEMS/openems/blob/develop/io.openems.common/src/io/openems/common/session/Language.java#L19
    pic2

The language has been changed in UI now.

Thank you very much Mr@stefan.feilmeier.

2 Likes