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.
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.
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.
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.
Copy the contents of the directory en_US to the de_CH directory.
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.
1. Move to the directory where Splunk locales reside.
# cd $SPLUNK_HOME/lib/python2.7/site-packages/splunk/appserver/mrsparkle/locale
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
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.
# $SPLUNK_HOME/bin/splunk restart
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)
Thanks, for reading…