Spread our blog

Creating a Splunk Locale

This post is intended to help those Splunkers who wish to create a Splunk locale, a set of parameters that defines the user’s language, region and any special variant preferences that the user wants to see in their user interface.

User Interface(UI) Internationalization

Internationalization (i18n) is the process of preparing software which can support local languages and cultural settings. These products support the requirement of local markets around the world, giving the option of more appropriate functioning based on local norms and fulfilling in-country user expectations. Splunk software uses the gettext internationalization and localization (i18n) system to achieve greater in-country customer acceptance and satisfaction.

Let’s say you land a new contract with a company in Korea, or your management team is looking to target a new market in some other country. Then internationalizing your software is the key to meeting the needs and expectations of local users in those markets.

Said that, lets come back to Splunk and continue the topic in Splunk context. 

Internationalization of the Splunk Web user interface includes:

  • Setting language/locale specific alternatives for static resources such as images, CSS etc.
  • Creating new languages or locales.
  • Translation of text generated by Python code, JavaScript code, views, menus, and Mako templates (variable custom module templates).
  • Formatting of times, dates and other numerical strings.

Translating the Splunk software

When you launch the Splunk software, it uses the language settings of your browser which you are accessing Splunk Web on. Change the browser language settings to see the user interface in another language(if locale already exists of that language in Splunk).

The Locale strings indicate the language and location that Splunk uses to translate the user interface(UI). In Splunk, a locale string consists of two lowercase letters and two uppercase letters linked by an underscore. Example, en_US stands for American English.

In addition to language, translation can also address the formatting of dates, times, numbers, and other localized settings.

The Splunk Localization files

Splunk stores all the localization information at the following location.

$SPLUNK_HOME/lib/python/site-packages/splunk/appserver/mrsparkle/locale

This directory includes the following members.

  • messages.pot : This file holds the strings that can be translated.
  • Directories containing localization files for the locale specified by (for ex-, it_IT ).
  • /LC_MESSAGES/messages.po : holds the source strings specified for localization in messages.pot
  • /LC_MESSAGES/messages.mo : This file is the machine readable version of messages.po. Splunk uses this file to find translated strings.

Localize the dates and numbers

You can format numbers and dates to the standards of a locale without translating any text. Create a directory for the locale whose numbers and dates you want to format. Copy the contents of the en_US directory to the target locale directory.

For Example:
You can enable the localization of numbers and dates for the de_CH locale (German – Switzerland).

Create a target directory for the de_CH locale.

$SPLUNK_HOME/lib/python2.7/site-packages/splunk/appserver/mrsparkle/locale/de_CH

Copy the contents of the directory en_US to the de_CH directory.

$SPLUNK_HOME/lib/python2.7/site-packages/splunk/appserver/mrsparkle/locale/en_US

Configuration of a Splunk locale

Follow the steps below to create a Splunk locale, we will create a Splunk locale in Hindi as an example.

Steps

1. Move to the directory where Splunk locales reside.

# cd $SPLUNK_HOME/lib/python2.7/site-packages/splunk/appserver/mrsparkle/locale

abcde

2. Create a directory for the locale. (we created a directory mn_MN) 

# mkdir <locale_dir>

now, move to this directory and create a sub-directory LC_MESSAGES

# cd <locale_dir>
# mkdir LC_MESSAGES

jsvhhh

3. Visit POEditor (Online Translation Service), and Load the messages.pot file into your POEditor (see the image in step 1)

$SPLUNK_HOME/lib/python2.7/site-packages/splunk/appserver/mrsparkle/locale/messages.pot
Capturejkghkjhjgfhj
Capturebngj.PNG
4. Using the POEditor translate any strings that you want to localize.
    We translated around 20 terms.
kbskl
5. Click on the import button shown in the picture above and save the files as messages.po and messages.mo (machine-readable version of the PO file).
hgkshlk

Note: The download files will appear as .po and .mo, change the file names to messages.po and messages.mo respectively.

6. Copy the files messages.po and messages.mo to the directory LC_MESSAGES you created in Step-2.

jsvh - Copy

7. Restart your Splunk instance. You don’t need to make any other configuration file edits/changes. Splunk will automatically detect the new language files when it restarts.
# $SPLUNK_HOME/bin/splunk restart
8. Open the Splunk web and change the locale specifier in URL to the one you created. 
hfhjf
You can also know about :  Load-balancing Splunk Search heads

Translating the Splunk Apps

You can use gettext to translate the Splunk apps. Most of the apps that Splunk offers must be translated in their own locale sub-directory.

NOTE: You don’t need to translate the apps that ship with Splunk as their text is included already in the core messages.pot file.

If you wish to extract the strings from any installed app to translate the strings in a POEditor, run the extraction command shown below on the CLI.

# $SPLUNK_HOME/bin/splunk extract i18n -app <app_name>

The above command creates a locale/ subdirectory in the app root directory and populates it with a messages.pot file.

The picture below is for your reference, (we extracted the strings for Splunk app: Web analytics)

final

Thanks, for reading…

Happy Splunking!!

What’s your Reaction?
+1
+1
+1
1
+1
+1
1
+1
+1

Spread our blog

4 COMMENTS

  1. Анализ механизмов локализации интерфейса приложений в Splunk - Bank News, Банк новости, Седат Игдеджи(Sedat Igdedzhi), Все новости вместе, робот новостей,

    […] docs.splunk.com/Documentation/Splunk/6.4.1/AdvancedDev/TranslateSplunkdocs.splunk.com/Documentation/Splunk/7.2.6/Viz/tokenssplunkonbigdata.com/2018/11/01/creating-a-splunk-localeanswers.splunk.com […]

  2. Hi,

    Nobody have ever shown how to change number formats, nor did you do in your presentation above – do you know how, and can you show an example of how?
    I’ve asked (several months ago) Splunk, and not even they have come up with an answer yet.

LEAVE A REPLY

Please enter your comment!
Please enter your name here