Browse Source

fix language selection

Brian Wiborg 1 year ago
parent
commit
59effcf9bb
Signed by: Brian Wiborg <brian@flux.fail> GPG Key ID: F1200FAE077A4313
6 changed files with 34 additions and 14 deletions
  1. 16
    5
      components/pages/account/MyAccount.vue
  2. 4
    4
      components/pages/home/Hero.vue
  3. 5
    2
      lang/de.json
  4. 4
    2
      lang/en.json
  5. 4
    0
      layouts/default.vue
  6. 1
    1
      nuxt.config.js

+ 16
- 5
components/pages/account/MyAccount.vue View File

@@ -7,15 +7,21 @@
7 7
     </v-toolbar>
8 8
     <v-card>
9 9
       <v-container>
10
-        <v-layout>
11
-          <v-flex>
12
-            <nuxt-link
10
+        <v-layout row wrap>
11
+          <v-flex xs12 class="text-xs-center" pb-2>
12
+            <small>
13
+              {{ $t('accountPage.myAccount.language.info') }}
14
+            </small>
15
+            <v-divider />
16
+          </v-flex>
17
+          <v-flex xs12>
18
+            <a
13 19
               v-for="locale in availableLocales"
14 20
               :key="locale.code"
15
-              :to="switchLocalePath(locale.code)"
21
+              @click="changeLocale(locale.code)"
16 22
             >
17 23
               {{ locale.name }}
18
-            </nuxt-link>
24
+            </a>
19 25
           </v-flex>
20 26
         </v-layout>
21 27
       </v-container>
@@ -162,6 +168,11 @@ export default {
162 168
         params.city = e.target.value
163 169
       }
164 170
       this.$store.dispatch('autoComplete/complete', params)
171
+    },
172
+
173
+    changeLocale: function (locale) {
174
+      this.$i18n.setLocaleCookie(locale)
175
+      this.$router.push(this.switchLocalePath(locale))
165 176
     }
166 177
   }
167 178
 }

+ 4
- 4
components/pages/home/Hero.vue View File

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <v-parallax
3 3
     dark
4
-      :height="420"
4
+    :height="420"
5 5
     :src="require('@/assets/trainstation_dark_small.jpg')"
6 6
   >
7 7
     <v-layout
@@ -33,8 +33,8 @@
33 33
             </v-btn>
34 34
           </nuxt-link>
35 35
 
36
-            <nuxt-link
37
-              :to="localePath('flux-report')"
36
+          <nuxt-link
37
+            :to="localePath('flux-report')"
38 38
           >
39 39
             <v-btn
40 40
               color="#5ccbf0"
@@ -43,7 +43,7 @@
43 43
               raised
44 44
             >
45 45
               <span class="grey--text text--darken-4 login-btn">
46
-                  {{ $t('homePage.btn.delayReport') }}
46
+                {{ $t('homePage.btn.delayReport') }}
47 47
               </span>
48 48
             </v-btn>
49 49
           </nuxt-link>

+ 5
- 2
lang/de.json View File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "language": "Sprache",
2 3
   "vehicle": {
3 4
     "none": "-",
4 5
     "bus": "Bus",
@@ -59,7 +60,7 @@
59 60
   },
60 61
   "nav": {
61 62
     "home": "Home",
62
-    "account": "Mein Konto",
63
+    "account": "Benutzerverwaltung",
63 64
     "login": "Anmelden",
64 65
     "stream": "Live Stream",
65 66
     "report": "flux.fail melden",
@@ -129,7 +130,9 @@
129 130
       "title": "Mein Konto",
130 131
       "moreFeaturesComingSoon": "Wir sind noch in einem sehr frühen Entwicklungsstadium. Schau öfter mal bei uns vorbei!",
131 132
       "language": {
132
-        "title": "Sprachauswahl"
133
+        "title": "Sprachauswahl",
134
+        "info": "Wähle eine Sprache aus:"
135
+
133 136
       },
134 137
       "defaults": {
135 138
         "title": "Einstellungen",

+ 4
- 2
lang/en.json View File

@@ -1,4 +1,5 @@
1 1
 {
2
+  "language": "Language",
2 3
   "vehicle": {
3 4
     "none": "-",
4 5
     "bus": "Bus",
@@ -59,7 +60,7 @@
59 60
   },
60 61
   "nav": {
61 62
     "home": "Home",
62
-    "account": "Profile",
63
+    "account": "User Profile",
63 64
     "login": "Login",
64 65
     "stream": "Live STream",
65 66
     "report": "Report a flux.fail",
@@ -130,7 +131,8 @@
130 131
       "title": "Account",
131 132
       "moreFeaturesComingSoon": "More features coming soon...",
132 133
       "language": {
133
-        "title": "Language Selector"
134
+        "title": "Language Selector",
135
+        "info": "Select a language from the list and switch to it:"
134 136
       },
135 137
       "defaults": {
136 138
         "title": "Settings",

+ 4
- 0
layouts/default.vue View File

@@ -94,6 +94,10 @@ export default {
94 94
   },
95 95
 
96 96
   computed: {
97
+    availableLocales: function () {
98
+      return this.$i18n.locales.filter(i => i.code !== this.$i18n.locale)
99
+    },
100
+
97 101
     items: function () {
98 102
       return [
99 103
         {

+ 1
- 1
nuxt.config.js View File

@@ -64,7 +64,7 @@ module.exports = {
64 64
         { name: 'Deutsch', code: 'de', iso: 'de_DE', file: 'de.json' }
65 65
       ],
66 66
       detectBrowserLanguage: {
67
-        alwaysRedirect: false,
67
+        alwaysRedirect: true,
68 68
         useCookie: true,
69 69
         cookieKey: 'fluxfail_i18n_redirected'
70 70
       },

Loading…
Cancel
Save