InApp Localization in Roku

InApp Localization in Roku

18 January 2022

Language localization is the process of translating an application to a specific country or regional language. So it must help people to understand things with their language. However Roku also supports localization for applications.

For implementing localization first you need to find out device language with the following steps:

local = CreateObject("roDeviceInfo")
print local.GetCurrentLocal()

The result provides a string for current locale based user settings. The string has a standard format in which two letters for language code followed by underscore and two letters for country or region code. For example you fetched output as “en_US”, then it is defined as a US English locale. It may vary with different regions or countries.

Adding Localization to your Application

The string localized files and data may be placed in the pkg:/local/ to access information for current localization settings. Also we need to initialize a.json file with local names like “en_US” for US English, “fr_CA” for Canadian French and “it_IT” for Italian to access data according to current localization settings.

After that you need to convert all strings in the specified local language according to file name for accessing strings throughout the application. The important thing is we need to set the same key with strings of different languages throughout the files. So it is easy to access string values for different languages by just fetching key values from files.

The process to fetch string values from a .json file requires a line of code in the main file.  And the accessed data may pass with current local value to the application.

Below is the code snippet for fetching string data:

deviceInfo = CreateObject("roDeviceInfo")

lang = deviceInfo.GetCurrentLocale()

url = "pkg:/local/" + lang + ".json"

jsonString = ReadAsciiFile(url)

local = ParseJSON(jsonString)

The url is used to fetch strings data associated with .json files from the local folder. And the associated data stores in a local array. The array may be passed to the global string to use throughout the application and may be accessed with The code snippet to pass local array to the global string is:

Graphics Image Localization

We can also localize graphics images using scene graph localization techniques. For applying graphics image we need to provide each localized image in pkg:/local/ directory. Then use the following format for the value of the uri field of the Poster node:


The first graphical image of the specified name found in this search sequence is returned to be rendered by the SceneGraph application.

  1. Not localized
  2. Current locale
  3. Default
  4. US English

Request a quote