Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit 914f8e9

Browse files
Dobromir Hristovmartinlindhe
authored andcommitted
docs: Update README.md to annotate the UMD feature. (#21)
1 parent 82e7895 commit 914f8e9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,29 @@ Vue.use(VueInternationalization, {
6161
...
6262
```
6363

64+
## UMD module
65+
66+
If you want to generate an UMD style export, you can with the `--umd` option
67+
```
68+
php artisan vue-i18n:generate --umd
69+
```
70+
An UMD module can be imported into the browser, build system, node and etc.
71+
72+
Now you can include the generated script in the browser as a normal script and reference it with window.vuei18nLocales.
73+
```
74+
<script src="{{ asset('js/vue-i18n-locales.generated.js') }}"></script>
75+
76+
// in your js
77+
Vue.use(VueI18n)
78+
Vue.config.lang = Laravel.language
79+
Object.keys(window.vuei18nLocales).forEach(function (lang) {
80+
Vue.locale(lang, window.vuei18nLocales[lang])
81+
})
82+
```
83+
You can still require/import it in your build system as stated above.
84+
85+
One advantage of doing things like this is you are not obligated to do a build of your javascript each time a the translation files get changed/saved. A good example is if you have a backend that can read and write to your translation files (like Backpack). You can listen to a save event there and call vue-i18n-generator.
86+
6487

6588
## Parameters
6689

0 commit comments

Comments
 (0)