From e6c7dd012216214ecc5eb24ced0f0ba98c0c7dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Tue, 16 Jun 2020 02:09:05 +0200 Subject: [PATCH] keyboard layouts from file --- client/public/keyboard_layouts.json | 1 + client/src/components/settings.vue | 17 +++++++++-------- client/src/store/index.ts | 1 + client/src/store/settings.ts | 28 +++++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 client/public/keyboard_layouts.json diff --git a/client/public/keyboard_layouts.json b/client/public/keyboard_layouts.json new file mode 100644 index 00000000..cebd4635 --- /dev/null +++ b/client/public/keyboard_layouts.json @@ -0,0 +1 @@ +{"af":"Afghani","al":"Albanian","et":"Amharic","ma":"Arabic (Morocco)","sy":"Arabic (Syria)","am":"Armenian","az":"Azerbaijani","ml":"Bambara","bd":"Bangla","by":"Belarusian","be":"Belgian","dz":"Berber (Algeria, Latin characters)","ba":"Bosnian","bg":"Bulgarian","mm":"Burmese","hr":"Croatian","cz":"Czech","dk":"Danish","mv":"Dhivehi","nl":"Dutch","bt":"Dzongkha","au":"English (Australian)","cm":"English (Cameroon)","gh":"English (Ghana)","ng":"English (Nigeria)","za":"English (South Africa)","us":"English (US)","gb":"English (UK)","ee":"Estonian","fo":"Faroese","ph":"Filipino","fi":"Finnish","fr":"French","ca":"French (Canada)","cd":"French (Democratic Republic of the Congo)","gn":"French (Guinea)","tg":"French (Togo)","ge":"Georgian","de":"German","at":"German (Austria)","ch":"German (Switzerland)","gr":"Greek","il":"Hebrew","hu":"Hungarian","cn":"Chinese","is":"Icelandic","in":"Indian","id":"Indonesian (Jawi)","iq":"Iraqi","ie":"Irish","it":"Italian","jp":"Japanese","kz":"Kazakh","kh":"Khmer (Cambodia)","kr":"Korean","kg":"Kyrgyz","la":"Lao","lv":"Latvian","lt":"Lithuanian","mk":"Macedonian","my":"Malay (Jawi)","mt":"Maltese","md":"Moldavian","mn":"Mongolian","me":"Montenegrin","np":"Nepali","no":"Norwegian","ir":"Persian","pl":"Polish","pt":"Portuguese","br":"Portuguese (Brazil)","ro":"Romanian","ru":"Russian","rs":"Serbian","lk":"Sinhala (phonetic)","sk":"Slovak","si":"Slovenian","es":"Spanish","ke":"Swahili (Kenya)","tz":"Swahili (Tanzania)","se":"Swedish","tw":"Taiwanese","tj":"Tajik","th":"Thai","bw":"Tswana","tr":"Turkish","tm":"Turkmen","ua":"Ukrainian","pk":"Urdu (Pakistan)","uz":"Uzbek","vn":"Vietnamese","sn":"Wolof"} \ No newline at end of file diff --git a/client/src/components/settings.vue b/client/src/components/settings.vue index 921d2762..946d9369 100644 --- a/client/src/components/settings.vue +++ b/client/src/components/settings.vue @@ -39,14 +39,11 @@ {{ $t('setting.keyboard_layout') }} @@ -277,6 +274,10 @@ this.$accessor.settings.setSound(value) } + get keyboard_layouts_list() { + return this.$accessor.settings.keyboard_layouts_list + } + get keyboard_layout() { return this.$accessor.settings.keyboard_layout } diff --git a/client/src/store/index.ts b/client/src/store/index.ts index 97ae6f58..ba186175 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -55,6 +55,7 @@ export const actions = actionTree( { initialise(store) { accessor.emoji.initialise() + accessor.settings.initialise() }, lock() { diff --git a/client/src/store/settings.ts b/client/src/store/settings.ts index ba3d06b7..eb1295db 100644 --- a/client/src/store/settings.ts +++ b/client/src/store/settings.ts @@ -1,8 +1,13 @@ -import { getterTree, mutationTree } from 'typed-vuex' +import { getterTree, mutationTree, actionTree } from 'typed-vuex' import { get, set } from '~/utils/localstorage' +import { accessor } from '~/store' export const namespaced = true +interface KeyboardLayouts { + [code: string]: string +} + export const state = () => { return { scroll: get('scroll', 10), @@ -11,6 +16,8 @@ export const state = () => { ignore_emotes: get('ignore_emotes', false), chat_sound: get('chat_sound', true), keyboard_layout: get('keyboard_layout', 'us'), + + keyboard_layouts_list: {} as KeyboardLayouts, } } @@ -46,4 +53,23 @@ export const mutations = mutationTree(state, { state.keyboard_layout = value set('keyboard_layout', value) }, + + setKeyboardLayoutsList(state, value: KeyboardLayouts) { + state.keyboard_layouts_list = value + }, }) + +export const actions = actionTree( + { state, getters, mutations }, + { + initialise() { + $http + .get('/keyboard_layouts.json') + .then((req) => { + accessor.settings.setKeyboardLayoutsList(req.data) + console.log(req.data) + }) + .catch(console.error) + }, + }, +)