1.0.8 • Published 6 years ago

pimcore-js-translations v1.0.8

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Pimcore JS translations

This package helps you to bring your shared translations from Pimcore to you Javascript frontend. It uses the Pimcore translation REST Endpoint. You can use the simple t function to request any translation by key.

Usage

You can attach the t function to your window object to make it globally available to your Javascript source. The init function

  • Make sure the Pimcore REST Api is enabled.
  • Use the package like:
npm i pimcore-js-translations
import { t, init } from 'pimcore-js-translations';

// define the locale you wanna fetch
// The translations are available inside the Promise!

// You need a pimcore user with a configured api key.
// Create a user in pimcore and assign the translation permissions to it.
const apiKey = 'xxxxxxxxxxxx';
const locale = 'de';
const fallbackLocale = 'en';

init(apiKey, locale, fallbackLocale).then(() => {
  const myTranslation = t('my-crazy-translation-key')
});

This version is still in Alpha! It initially loads all your translations from your CMS! If you have a huge amount of translations please consider another solution. Feel free to contribute :)

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago