laravel-vue-i18n
Advanced tools
Comparing version
@@ -8,1 +8,5 @@ import { OptionsInterface } from './options'; | ||
} | ||
export interface VitePluginOptionsInterface { | ||
langPath?: string; | ||
additionalLangPaths?: string[]; | ||
} |
@@ -7,2 +7,3 @@ import { ParsedLangFileInterface } from './interfaces/parsed-lang-file'; | ||
export declare const readThroughDir: (dir: any) => {}; | ||
export declare const prepareExtendedParsedLangFiles: (langPaths: string[]) => ParsedLangFileInterface[]; | ||
export declare const generateFiles: (langPath: string, data: ParsedLangFileInterface[]) => ParsedLangFileInterface[]; |
@@ -0,2 +1,3 @@ | ||
import { VitePluginOptionsInterface } from './interfaces/plugin-options'; | ||
import { Plugin } from 'vite'; | ||
export default function i18n(langPath?: string): Plugin; | ||
export default function i18n(options?: string | VitePluginOptionsInterface): Plugin; |
{ | ||
"name": "laravel-vue-i18n", | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Francisco Madeira", |
@@ -51,3 +51,3 @@ <h1 align="center" style="border:none !important"> | ||
For Server Side Rendering the resolve method should not receive a `Promise` and instead take advantage of the `globEager` method like this: | ||
For Server Side Rendering the resolve method should not receive a `Promise` and instead take advantage of the `eager` param like this: | ||
@@ -58,3 +58,3 @@ ```js | ||
resolve: lang => { | ||
const langs = import.meta.globEager('../../lang/*.json'); | ||
const langs = import.meta.glob('../../lang/*.json', { eager: true }); | ||
return langs[`../../lang/${lang}.json`].default; | ||
@@ -91,2 +91,31 @@ }, | ||
#### Vite plugin options | ||
In addition to that, you can use this `Vite` plugin with additional paths to load from, this is usefull when you are using a package that let's you override your translations, or in case you are getting your application's lang files from different paths. | ||
Note that if one key found in two paths, priority will be given to the last given path between these two (In this example translation key will be loaded from `public/locales`) | ||
```js | ||
// vite.config.js | ||
import i18n from 'laravel-vue-i18n/vite'; | ||
export default defineConfig({ | ||
plugins: [ | ||
laravel([ | ||
'resources/css/app.css' | ||
'resources/js/app.js', | ||
]), | ||
vue(), | ||
i18n({ | ||
// you can also change your langPath here | ||
// langPath: 'locales' | ||
additionalLangPaths: [ | ||
'public/locales' // Load translations from this path too! | ||
] | ||
}), | ||
], | ||
}); | ||
``` | ||
> During the `npm run dev` execution time, the plugin will create some files like this `php_{lang}.json` on your lang folder. | ||
@@ -93,0 +122,0 @@ > And to avoid that to be commited to your code base, I suggest to your `.gitignore` this like: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
158319
2.18%2298
0.79%396
7.9%