-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regionalization added, so that texts are displayed according to the u…
…ser's browser language. To add new languages, create the json file in the locales folder in the same pattern as the existing ones, and add the translation. Regionalization added, so that texts are displayed according to the user's browser language. To add new languages, create the json file in the locales folder in the same pattern as the existing ones, and add the translation.
- Loading branch information
1 parent
abe5754
commit 690a097
Showing
11 changed files
with
234 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VUE_APP_I18N_LOCALE=en | ||
VUE_APP_I18N_FALLBACK_LOCALE=en |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Vue from 'vue' | ||
import VueI18n from 'vue-i18n' | ||
|
||
Vue.use(VueI18n) | ||
|
||
function loadLocaleMessages () { | ||
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i) | ||
const messages = {} | ||
locales.keys().forEach(key => { | ||
const matched = key.match(/([A-Za-z0-9-_]+)\./i) | ||
if (matched && matched.length > 1) { | ||
const locale = matched[1] | ||
messages[locale] = locales(key) | ||
} | ||
}) | ||
return messages | ||
} | ||
|
||
export default new VueI18n({ | ||
locale: process.env.VUE_APP_I18N_LOCALE || 'en', | ||
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', | ||
messages: loadLocaleMessages() | ||
}) |
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,21 @@ | ||
{ | ||
"message": "hello i18n !!", | ||
"card": { | ||
"cardHolder": "Card Holder", | ||
"fullName": "Full Name", | ||
"expires": "Expires", | ||
"MM": "MM", | ||
"YY": "YY" | ||
}, | ||
|
||
"cardForm": { | ||
"cardNumber": "Card Number", | ||
"cardName": "Card Name", | ||
"expirationDate": "Expiration Date", | ||
"month": "Month", | ||
"year": "Year", | ||
"CVV": "CVV", | ||
"submit": "Submit", | ||
"invalidCardNumber": "Invalid Card Number" | ||
} | ||
} |
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,21 @@ | ||
{ | ||
"message": "hello i18n !!", | ||
"card": { | ||
"cardHolder": "Titular Cartão", | ||
"fullName": "Nome Completo", | ||
"expires": "Expira", | ||
"MM": "MM", | ||
"YY": "AA" | ||
}, | ||
|
||
"cardForm": { | ||
"cardNumber": "Numero do Cartão", | ||
"cardName": "Nome Titular", | ||
"expirationDate": "Data de Vencimento", | ||
"month": "Mês", | ||
"year": "Ano", | ||
"CVV": "CVV", | ||
"submit": "Enviar", | ||
"invalidCardNumber": "Número do Cartão Inválido" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import Vue from 'vue' | ||
import App from './App.vue' | ||
import i18n from './i18n' | ||
|
||
Vue.config.productionTip = false | ||
|
||
new Vue({ | ||
i18n, | ||
render: h => h(App) | ||
}).$mount('#app') |
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,10 @@ | ||
module.exports = { | ||
pluginOptions: { | ||
i18n: { | ||
locale: 'en', | ||
fallbackLocale: 'en', | ||
localeDir: 'locales', | ||
enableInSFC: true | ||
} | ||
} | ||
} |
Oops, something went wrong.