Laravel Translations Loader is a webpack loader to import your Laravel translation files (PHP or JSON) by Luís Dalmolin and Kirschbaum Development Group.
You install this package as an NPM dependency with NPM or Yarn:
npm install @kirschbaum-development/laravel-translations-loader --save-dev # Or... yarn add @kirschbaum-development/laravel-translations-loader --dev
Kirschbaum also has a demo project you can reference to see how it works. Here’s an example of how it works from the demo project’s ExampleComponent component:
<template>
<div class="container">
<p><strong>Translation for "auth.php" (PHP file):</strong><br>
{{ $t('auth.failed') }}</p>
<p><strong>Translation for "Hello World" (JSON file):</strong><br>
{{ $t('Hello World') }}</p>
</div>
</template>
And here’s an example of how you might use this package with vue-i18n:
import languageBundle from '@kirschbaum-development/laravel-translations-loader!@kirschbaum-development/laravel-translations-loader';
import VueI18n from 'vue-i18n';
Vue.use(VueI18n);
const i18n = new VueI18n({
locale: window.Locale,
messages: languageBundle,
})
To learn more about this project, installation, and usage instructions, check out the project’s GitHub repo: laravel-translations-loader. The readme also has useful packages you can use with the Laravel Translations Loader project if you’re using React, Vue, and i18next in your projects with this package.