Dashboards & Visualizations

App Translation incomplete for Simple XML views and impossible for Django views

guilmxm
SplunkTrust
SplunkTrust

Hi,

I've developed and released NMON Splunk App:

https://apps.splunk.com/app/1753/

One of my goals in future release was to translate the Application in French (fr_FR) and i am facing some difficulties with Simple XML views being partially translated and Django views not been translated at all.

Based on official documentation:
http://docs.splunk.com/Documentation/Splunk/6.1.1/AdvancedDev/TranslateSplunk#Configuration

I generated the catalog file "messages.pot" for my App, translated it with French patterns, and put it were it should be:

$SPLUNK_HOME/etc/apps/nmon/locale/fr_FR/LC_MESSAGES

which contains both "messages.po" and "messages.mo"

After Splunk restart, the App is partially translated but:

1. Simple XML views partially translated

In every Simple XML view, every pattern in html sections is automatically translated with success.

Thus, every other pattern such as beforeLabel/afterLabel in single, values in fieldset-inputs and so on are not translated.

To illustrate:

A section like:

<html>
  <div class="custom">
    <h1>Indexing Informations</h1>
  </div>
</html>

Will be translated with success.

A non html section like:

<single>
  <searchPostProcess>fields index</searchPostProcess>
  <option name="beforeLabel">Data Index:</option>
  <option name="linkView">search</option>
</single>

Won't be translated even if the pattern "Data Index:" in present within the messages.pot catalog and translated.

Every non translated pattern are present in catalog file, so the i18n extract works with success but this does not seem to be enough for Splunk to fully translate pages...

I've seen some other related questions on Splunk base like:

http://answers.splunk.com/answers/62110/how-to-localize-the-dashboard-panels

--> I tried this with absolutely no changes

And http://answers.splunk.com/answers/26690/splunk-translation-not-applied-correctly

2. How to translate Django views:

A related question in Splunk base:

http://answers.splunk.com/answers/119704/how-to-translate-an-app-that-uses-the-web-framework-django

I don't have any issue while generating the catalog, and i can see django views are being examined:

Here as some extract generated by splunk while extracting i18n datas:

extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/django/nmon/templates/UI_Usage_per_process_dj_LINUX.html (input_encoding="utf-8")
extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/django/nmon/templates/UI_Usage_per_process_dj_LINUX.html (input_encoding="utf-8")
extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/django/nmon/templates/UI_Usage_per_process_dj_SOLARIS.html (input_encoding="utf-8")
extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/django/nmon/templates/UI_Usage_per_process_dj_SOLARIS.html (input_encoding="utf-8")

--> Django views are being analysed but no message is being extracted, the same job for a Simple XML view would produce:

extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/default/data/ui/views/UI_Nmon_VM_SOLARIS.xml (sources="t:title, t:label, t:description, t:option:name=beforeLabel, t:option:name=afterLabel, t:option:name=underLabel, t:fieldset/input/choice, t:option:name=charting.axisTitleX.text, t:option:name=charting.axisTitleY.text, t:option:name=tooltipChartTitle, e:html")
extracting messages from /opt/splunk/splunk_demo2/etc/apps/nmon/default/data/ui/views/UI_Nmon_VM_SOLARIS.xml (sources="t:title, t:label, t:description, t:option:name=beforeLabel, t:option:name=afterLabel, t:option:name=underLabel, t:fieldset/input/choice, t:option:name=charting.axisTitleX.text, t:option:name=charting.axisTitleY.text, t:option:name=tooltipChartTitle, e:html")

So, it seems the current version of related python scripts and config files are not yet designed to extract messages from Django views ?

Or perhaps have we to apply something specific for django views ?

I've also searched for information in Splunk Dev with no luck...

Thanks in advance for any help.

Guilhem

jbranislav
Explorer

Only solution for translating Django templates that worked for me is:
- in Django templates add {% load i18n %} at the top of every where translations is needed
- use {% trans "STRING" %} somewhere in template
- create in $SPLUNK_HOME/etc/apps/[APP_NAME]/django/[APP_NAME]/locale/[LOCALE]/LC_MESSAGES/django.po file
- Add STRING manually in django.po file
- Open django.po file in Poedit, translate strings and create django.mo file
- Restart Splunk

As far as i read, "splunk extract i18n -app APPNAME" won't read Django templates. There must be way to access django-admin.py for app in splunk and then generate files but i still did not find a way how to do that.

If anybody knows any better way of translating Django templates in Splunk that will be great to know 🙂

sideview
SplunkTrust
SplunkTrust

Very detailed writeup. I know that in the older versions of the UI the i18n coverage was tricky to keep at 100%. Out of curiosity, and a selfish desire to find bugs I can fix, have you found any untranslated strings with views built with the advanced xml or sideview xml?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...