5.1.7 • Published 12 months ago

@smartface/i18n v5.1.7

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

Twitter: @Smartface_io License: MIT

i18n

Intro

This module implements multi language support for Smartface applications.

Getting started

Create language files like below, for detailed instructions you can check out https://www.i18next.com/overview/getting-started#basic-sample

en.ts

export default {
  helloWorld: "Hello World",
  welcomeUser: "Welcome {{user}}",
  keyWithCount_one: "{{count}} key",
  keyWithCount_other: "{{count}} keys"
};

tr.ts

export default {
  helloWorld: "Merhaba Dünya",
  welcomeUser: "Hoşgeldin {{user}}",
  keyWithCount_one: "{{count}} anahtar",
  keyWithCount_other: "{{count}} anahtarlar"
};

Initialize i18n instance

import i18n from "@smartface/i18n";
import System from "@smartface/native/device/system"

import en from "./en";
import tr from "./tr";

new i18n({
  lng: Device.language,
  debug: System.isEmulator,
  resources: {
    en: {
      translation: en
    },
    tr: {
      translation: tr
    }
  },
  fallbackLng: "en"
  // many options available
  // https://www.i18next.com/overview/configuration-options
});

//You can get formatted string like this
i18n.instance.t("helloWorld");
i18n.instance.t("welcomeUser", { user: "Smartface" });
i18n.instance.t("keyWithCount", { count: 0 });
i18n.instance.t("keyWithCount", { count: 1 });
i18n.instance.t("keyWithCount", { count: 5 });

//Change the language without app reload, it updates the instance
i18n.changeLanguage("tr");

//subscribe to locale changes
const unsubscribe = i18n.on('change', () => {
  console.log("subscribe trigger");
});

//this will unsubscribe
unsubscribe();
5.1.5

1 year ago

5.1.4

1 year ago

5.1.7

12 months ago

5.1.6

1 year ago

5.1.3

1 year ago

5.1.1

1 year ago

5.1.0

1 year ago

5.0.10

1 year ago

5.1.0-beta.0

1 year ago

5.0.9

1 year ago

5.0.8

1 year ago

5.0.5

2 years ago

5.0.5-alpha.7

2 years ago

5.0.7

2 years ago

5.0.5-alpha.6

2 years ago

5.0.5-alpha.2

2 years ago

5.0.5-alpha.1

2 years ago

5.0.4

2 years ago

5.0.4-beta.0

2 years ago

5.0.1-alpha.1

2 years ago

5.0.3

2 years ago

5.0.2-alpha.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

5.0.3-beta.0

2 years ago

5.0.0-beta.1

2 years ago

5.0.3-beta.2

2 years ago

5.0.0-alpha.7

2 years ago

5.0.0-alpha.6

2 years ago

5.0.0-alpha.8

2 years ago

5.0.0-beta.0

2 years ago

5.0.0-alpha.0

2 years ago

1.0.0

2 years ago