Skip to content

Internationalization for Extension Module

Extension modules can have their own localization resource files in i18n folder. These localized strings can be accessed via I18nHelper.localizeExtensionText class.

let labelCaption = I18nHelper.localizeExtensionText(<i18n_key>, this.definition().data.Module, [<optional_parameter_values, ...]);

This allows the extension to have its own i18n strings that is independent of the app's i18n strings resource file. This is useful for fixed texts or default texts provided by the extensions and even more useful if the extension can be reused in different applications.

For example: your extension provide a button and it has an 'OK' default text that you want to localize to multiple languages.

You will define:

  • button_cancel_label=Cancel in
  • button_cancel_label=Stornieren in
  • button_cancel_label=Annullare in

The detailed folder structure and string resources file can be found here.

In your MyExtensionControl.ts you can access them via:

let labelCaption = I18nHelper.localizeExtensionText('button_cancel_label', this.definition().data.Module);

The explanation on extension folder structure is available here.


import { IView } from 'mdk-core/IView';
import { Label } from 'tns-core-modules/ui/label';
import { Color } from 'tns-core-modules/color';
import { I18nHelper } from 'mdk-core/utils/I18nHelper';

export class MyObjectHeaderI18nExtension extends IView {
  public _label: Label;

  public view(): any {

    if (app.ios) {
      this._label = UILabel.alloc().init();
    } else {
      this._label = new android.widget.TextView(this.androidContext());

    let orderId = this.context.binding ? this.context.binding.OrderId : '';
    let labelCaption = I18nHelper.localizeExtensionText('first_work_order_id', this.definition().data.Module, [orderId]);

    if (app.ios) {
      this._label.text = labelCaption;
    } else {

    return this._label;

Last update: April 14, 2021