Dashboards & Visualizations

How to translate things written in JavaScript (buttons, texts)?

SJanasek
Path Finder

hey there!
I need your help.
I want to translate an application. Already followed this guideline http://docs.splunk.com/Documentation/Splunk/6.5.1/AdvancedDev/TranslateSplunk , but this does not help me to translate buttons or texts written in JS.

0 Karma
1 Solution

JMichaelis
Path Finder

Hi SJanasek,

the TranslateSplunk i18n-functionality does indeed not extract/translate site content in JS. I've found a way to use it either way:

You have to add the entries in your messages.mo / po by hand and have to follow the guidelines you've linked regarding file placement.

You then have to add the following to your js:

require([
...
'splunk.i18n',
...
], function(..., i18n) {

Now you are able to use i18n._("variable_name")in your code when naming buttons/labels and so on. The function will return the value defined by the used language and the variable_name in your .po.

Best regards,
Jens

View solution in original post

JMichaelis
Path Finder

Hi SJanasek,

the TranslateSplunk i18n-functionality does indeed not extract/translate site content in JS. I've found a way to use it either way:

You have to add the entries in your messages.mo / po by hand and have to follow the guidelines you've linked regarding file placement.

You then have to add the following to your js:

require([
...
'splunk.i18n',
...
], function(..., i18n) {

Now you are able to use i18n._("variable_name")in your code when naming buttons/labels and so on. The function will return the value defined by the used language and the variable_name in your .po.

Best regards,
Jens

vaneetsin
Engager

@JMichaelis 
just like you mentioned, I have successfully translated things written in javascript to japanese language. But I am stuck where I need to translate token values to japanese. I have a token in the dashboard that has value “validation error” and this token is used to display a warning message on input text.
Below is snippet of token in xml, $vuln_input_error$ is the token that I set elsewhere in same xml.
————
<row id=“row1”>
<html depends=“$vuln_input_error$” id=“vuln_error_msg”>
<div id=“vuln_error_container”><code>$vuln_input_error$</code></div></html>
———-
Using the same approach that you have described, I have tried with i18n in js, but token value does not get translated as expected. Do you have an idea on how to translate token values in splunk?

0 Karma

SJanasek
Path Finder

can you give me a more detailed description please?

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...