Dashboards & Visualizations

How to do i18n translation JS after jquery update?

mckloss
Engager

Hello all,


I am going to upgrade to Splunk to version 9.1.x.


Inside my app I use JS which does the translation of the page using i18n.
When checking the jquery scan, I get the message:
"This /path/to/js/file.js is importing the following dependencies which are not supported or externally documented by Splunk.
splunk.i18n "

Does anyone have a solution to this problem or if Splunk can't do i18n in JS anymore..., how do you translate your dashboards?

Any hints are appreciated.

 

Kind regards,

Marie

Labels (2)
Tags (2)
0 Karma

Mladjo
Explorer

Hi,

 

We have the same problem and it seems that we found a workaround for our case.

Unrestricting older JQuery libraries did not fix our problem as Splunk suggested: 

https://docs.splunk.com/Documentation/Splunk/9.1.0/Installation/AboutupgradingREADTHISFIRST#Older_jQ...

Internal debugging found a (temporary) solution:

Try using _i18n_catalog object that is globally defined, no need to import it.

Reference your strings with:

_i18n_catalog["+-<string>"]  --> don't forget to add +- prefix.

I am quite sure that this approach is not optimal as it requires code modifications in our end.

Will reply if we found something better.

Take care 🙂

mckloss
Engager

Thank you very much for the solution.


Allowing old jQuery didn't help with us either, but the variant using _i18n_catalog["+-<string>"] works. 🙂 


Should you still find a solution with splunk.i18n, I would also be very interested in it, as we have this built into a lot of dashboards

0 Karma

Mladjo
Explorer

Hi! 

Some good news 😄

We've found a better way to handle this. You can use globally defined function to translate your strings:

i18n._("string_to_translate") can be converted to _("string_to_translate").

What's even better is that this works in both 8.x and 9.x.

Just be careful if you (like us) import underscore as _ in your scripts as well as this can cause name clash. In that case simple renaming of imported library will suffice.

 

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...