Commit | Line | Data |
---|---|---|
98db2082 BA |
1 | <template lang="pug"> |
2 | div | |
3 | - | |
4 | var langName = { | |
5 | "en": "English", | |
6 | "es": "Español", | |
7 | "fr": "Français", | |
8 | }; | |
9 | input#modalLang.modal(type="checkbox") | |
dcd68c41 | 10 | div(role="dialog" data-checkbox="modalLang") |
9a3049f3 | 11 | .card |
98db2082 | 12 | label.modal-close(for="modalLang") |
9a3049f3 | 13 | form(@change="setLanguage($event)") |
98db2082 | 14 | fieldset |
c66a829b | 15 | label(for="langSelect") {{ st.tr["Language"] }} |
98db2082 BA |
16 | select#langSelect |
17 | each language,langCode in langName | |
4f887105 | 18 | option(value=langCode) |
98db2082 BA |
19 | =language |
20 | </template> | |
21 | ||
22 | <script> | |
c66a829b | 23 | import { store } from "@/store"; |
98db2082 | 24 | export default { |
c66a829b BA |
25 | name: "my-language", |
26 | data: function() { | |
27 | return { | |
28 | st: store.state, | |
29 | }; | |
30 | }, | |
4f887105 | 31 | mounted: function() { |
41c80bb6 | 32 | // NOTE: better style would be in pug directly, but how? |
4f887105 BA |
33 | document.querySelectorAll("#langSelect > option").forEach(opt => { |
34 | if (opt.value == this.st.lang) | |
35 | opt.selected = true; | |
36 | }); | |
37 | }, | |
38 | methods: { | |
98db2082 BA |
39 | setLanguage: function(e) { |
40 | localStorage["lang"] = e.target.value; | |
c66a829b | 41 | store.setLanguage(e.target.value); |
98db2082 | 42 | }, |
dac39588 | 43 | }, |
98db2082 BA |
44 | }; |
45 | </script> |