Skip to content

Commit

Permalink
Locale-aware sort of the OS keyboard layouts by their labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
precondition committed Aug 18, 2022
1 parent 64686c4 commit cc349e1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/SettingsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
v-model="osKeyboardLayout"
>
<option
v-for="osLayout in osKeyboardLayouts"
v-for="osLayout in sortedOSKeyboardLayouts"
:key="osLayout"
:value="osLayout"
>
Expand Down Expand Up @@ -179,6 +179,14 @@ export default {
async set(value) {
await this.changeOSKeyboardLayout(value);
}
},
sortedOSKeyboardLayouts: function () {
// Locale-aware sort of the OS keyboard layouts by their labels.
const translatedLayoutName = (osLayout) =>
this.$t('settingsPanel.osKeyboardLayout.label.' + osLayout);
return [...this.osKeyboardLayouts].sort((a, b) =>
translatedLayoutName(a).localeCompare(translatedLayoutName(b))
);
}
},
methods: {
Expand Down

0 comments on commit cc349e1

Please sign in to comment.