- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to do i18n translation JS after jquery update?
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
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
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 🙂
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
