Translating App plugin and adding other languages to grafana

Hello,

I have an app plugin, and I would like to translate it similarly to how the other menu items are translated. Is there a way to do it, and are there any translation docs/guides?

My second question is tied to my previous one can I add different languages (for my personal use) to grafana and if yes, how?

I’m sorry if there’s a guide somewhere in the docs. I couldn’t find it.

Thanks
Matt

Check this thread out maybe ?

But if you really feeling adventurous, you might as well take the bull by the horn, fork grafana and add internationalization feature using

or maybe not

Please note: We do not currently accept contributions for translations. Please do not submit pull requests for messages.po files - they will be rejected.

1 Like

I’ve read that before, but I don’t really see how that helps me with either of my questions, maybe I’ve formulated it poorly. From looking at the source code, I see that the translation is done through .json files and some hard-coded in list of languages. I wanted to know if there’s a recommended way to add new languages for my personal/local use (not submitting them) and how to do it.
I’ve actually found most of what I was looking for in the contribute/internationalization.md.

I’m still stuck trying to figure out how to add the i18n translation to the app plugin since I can’t find where the processing of it is in the source code. I’m kinda lost in there so any pointers would be appreciated.

1 Like

@mateorid Internationalization is not supported in plugins yet: Epic: Design doc for plugin internationalization · Issue #60847 · grafana/grafana · GitHub

You can get the selected locale using getLocale() and create your own implementation while the Grafana team still works on the official support.

3 Likes

Hi,
thanks for the suggestion I managed to translate my plugin by forking the grafana repo and editing it, but I can’t really find much info on the getLocale() function and it keeps returning en-GB even with other languages selected. I need the info for my backend queries, do you have any idea why that might be happening?

1 Like

@mateorid Locale is set on the Organization and User levels. Maybe you set User and try to update Organization.

We used it in the Dynamic Text panel, and I had no issues with it. You can try the panel to see if it changes.

1 Like

Thanks for the tip. I think it was a bug in the 9.4.0 pre-release, I tried the same changes on the 9.3.6 release and it works as expected now.

I’m trying to figure out if there’s a way to get this info to my backend now. I used to have a language variable and I sent that as a payload but there isn’t a way (?) to get this into the payload, is there?

1 Like

@mateorid I don’t think it’s available as a global variable. It will be nice to add it.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.