Fork me on GitHub Fork me on GitHub

i18n


<%
	var i18n = require("i18n");
	i18n.init(request);
%>

<%
	print(i18n.localize("greetings.local", "Greetings from Jaggery"));
%>

Overview

i18n provides the ability to internationalize text in webapps
The content related to localization, need to be placed as json files with the name locale_{language_code}.json, i.e french locale file will be locale_fr.json The content is in JSON which will have simple key-vale pairs like follows.

{
"greetings.local": "Français - Démo de l10n.js", 
"info.local": "Vous lisez une localisation en français de cette page."
}


Members

Member Type Description
localeResourcesBasePathString
i18n.localeResourcesBasePath
Sets base path for locale resources

Operations

Member Returns Description
init(request)none

initialize i18n object with the request

var i18n = require("i18n");
i18n.init(request);
localize(key, fallback)StringReturns the localized String, if not provided the fallback text

print(i18n.localize("greetings.local", "Greetings from Jaggery"));