1.0.7 • Published 1 year ago

ma-localization-js v1.0.7

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago
Usage

const trans = await MAlocalization('PROJECT_ID', 'API_KEY', 'https://functionEndpointUrl');

trans.setLanguage(lang);

const msg = trans.translate(key,placeholders);

const availableLocales = trans.getAvailableLanguages();

const msgsInVueFormat = trans.getVue(locale);

Function types

translate: (string, null | Object | Array<string | number> = null) => string;

setLanguage: (string) => boolean;

getAvailableLanguages: () => string[];

getVue: () => {key:string:string};

Vue trans example

import { createApp, nextTick } from 'vue'; import { createI18n } from 'vue-i18n';

const i18n = createI18n({ legacy: false, locale: localStorage.getItem('locale') ?? 'en', messages: defaultTranslations }); let trans: any; let availableLocales = 'en', 'da';

async function loadLocaleMessages() { if (!trans) trans = await MAlocalization('PROJECT_ID', 'API_KEY', 'https://functionEndpointUrl'); availableLocales = trans.getAvailableLanguages(); availableLocales.forEach((locale) => { const msgs = trans.getVue(locale); i18n.global.setLocaleMessage(locale, msgs); }); return nextTick(); }

createApp(App).use(i18n).mount('#app'); loadLocaleMessages();

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago