The resources reside in the widget /locales
directory:
<extension-name> : the root folder of your extension ext.json widget/ <widget-type>/ widget.json locales/ <locale code, for example, en or en_US>/ ns.<widget-type>.json <other locale codes>/ ns.<widget-type>.json
A child directory exists in the /locales
directory for each locale you want to provide resources for and their names can be either a two-letter language code (for example, en
) or a two-letter language code and a two-letter country code with an underscore in between (for example, en_US
). ISO 639-1
defines the two-letter language codes. ISO 3166-1 alpha-2
defines the two-letter country codes.
The naming convention for resource files contained in these directories is ns.<widget-type>.json
, for example, ns.mywidget.json
. The ns
prefix stands for “namespace” and widget-type
corresponds to the /widget/widget-type
directory. Resource files are in JSON format. Refer to the Resource loading section for more information on this format.
Localizable resources are defined using JSON objects composed of string keys mapped to string values. The keys represent the resource names and the values represent the localized version of each resource. The i18next JavaScript library is used to perform the client-side translations. An example locale file is shown below:
{ "resources": { "siteNavigationFooter" : "Site Navigation Footer", "editFooterHeader" : "Select Header Links (multi-select allowed)" } }