Added test for italiano

This commit is contained in:
Grzegorz Leoniec 2018-12-20 20:41:32 +01:00
parent 3626fb2fa0
commit 5f244eba1a
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
4 changed files with 19 additions and 4 deletions

View File

@ -68,7 +68,7 @@ export default {
},
computed: {
current() {
console.log('locales', this.locales)
console.log('current', this.$i18n.locale())
return find(this.locales, ['code', this.$i18n.locale()])
}
},

View File

@ -10,10 +10,15 @@ Feature: Internationalization
When I select "Deutsch" in the language menu
Then The whole user interface appears in "Deutsch"
When I select "Français" in the language menu
Then The whole user interface appears in "Français"
When I select "English" in the language menu
Then The whole user interface appears in "English"
Scenario: Keep preferred language after refresh
When I select "Deutsch" in the language menu
Then The whole user interface appears in "Deutsch"
And I refresh the page
Then The whole user interface appears in "Deutsch"

View File

@ -5,6 +5,14 @@ const baseUrl = 'http://localhost:3000'
const username = 'Peter Lustig'
const locales = require('../../../locales')
// TODO: use the native locale files
const localeStrings = {
login: {
English: 'Login',
Deutsch: 'Einloggen',
Français: 'Connexion'
}
}
const login = (email, password) => {
cy.visit(`${baseUrl}/login`)
@ -91,7 +99,6 @@ Then('I am still logged in', () => {
When('I select {string} in the language menu', name => {
cy.get('.login-locale-switch a')
.click()
.wait(50)
const code = find(locales, ['name', name]).code
cy.get(`.locale-menu-popover a.${code}`)
.click()
@ -100,6 +107,7 @@ When('I select {string} in the language menu', name => {
Then('The whole user interface appears in {string}', name => {
const code = find(locales, ['name', name]).code
cy.getCookie('locale').should('have.property', 'value', code)
cy.contains(localeStrings.login[name])
})
When('I navigate to the administration dashboard', () => {

View File

@ -1,7 +1,7 @@
import Vue from 'vue'
import Vuex from 'vuex'
import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js'
import { debounce, isEmpty } from 'lodash'
import { debounce, isEmpty, find } from 'lodash'
/**
* TODO: Refactor and simplify browser detection
@ -63,7 +63,9 @@ export default ({ app, req, cookie, store }) => {
}
const availableLocales = process.env.locales.filter(lang => !!lang.enabled)
const locale = availableLocales.indexOf(userLocale) >= 0 ? userLocale : 'en'
const locale = find(availableLocales, ['code', userLocale])
? userLocale
: 'en'
if (locale !== 'en') {
Vue.i18n.add(locale, require(`~/locales/${locale}.json`))