-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
294 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/** | ||
Mixin class extending the core to add helpers to manage the internationalization. | ||
@mixin LocaleMixin | ||
@typicalname prophecies | ||
*/ | ||
|
||
const LocaleMixin = superclass => class extends superclass { | ||
/** | ||
* Set the i18n language from the locale | ||
* @param {String} locale - Locale code to load | ||
* @memberof LocaleMixin.prototype | ||
*/ | ||
setI18nLanguage (locale) { | ||
this.i18n.locale = locale | ||
return locale | ||
} | ||
/** | ||
* Load the application language from the locale | ||
* @param {String} locale - Locale code to load | ||
* @memberof LocaleMixin.prototype | ||
*/ | ||
loadLocale (locale) { | ||
if (this.loadedLocales === undefined) { | ||
this.loadedLocales = [] | ||
} | ||
if (this.i18n.locale !== locale) { | ||
if (!this.loadedLocales.includes(locale)) { | ||
return import(/* webpackChunkName: "[request]" */ '@/messages/' + locale + '.json').then(messages => { | ||
this.i18n.setLocaleMessage(locale, messages.default) | ||
this.loadedLocales.push(locale) | ||
return this.setI18nLanguage(locale) | ||
}) | ||
} | ||
return Promise.resolve(this.setI18nLanguage(locale)) | ||
} | ||
return Promise.resolve(locale) | ||
} | ||
} | ||
|
||
export default LocaleMixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ export { | |
FilmIcon, | ||
FilterIcon, | ||
FrownIcon, | ||
GlobeIcon, | ||
GridIcon, | ||
HomeIcon, | ||
HelpCircleIcon, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.