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!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...