Skip to content

glemmal/pimcore-js-translations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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 :)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published