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 { | |
6808d7a1 | 28 | st: store.state |
c66a829b BA |
29 | }; |
30 | }, | |
4f887105 | 31 | mounted: function() { |
41c80bb6 | 32 | // NOTE: better style would be in pug directly, but how? |
4f887105 | 33 | document.querySelectorAll("#langSelect > option").forEach(opt => { |
6808d7a1 | 34 | if (opt.value == this.st.lang) opt.selected = true; |
4f887105 BA |
35 | }); |
36 | }, | |
37 | methods: { | |
98db2082 BA |
38 | setLanguage: function(e) { |
39 | localStorage["lang"] = e.target.value; | |
c66a829b | 40 | store.setLanguage(e.target.value); |
6808d7a1 BA |
41 | } |
42 | } | |
98db2082 BA |
43 | }; |
44 | </script> |