From f8eff0e422f04e2e765a8f07b622c1629cdea9be Mon Sep 17 00:00:00 2001 From: 9ekaitz <56532157+9ekaitz@users.noreply.github.com> Date: Wed, 10 Aug 2022 23:52:31 +0200 Subject: [PATCH] External player choice 'None' translated in Settings (#2075) * External player choice 'None' translated in Settings * requested fix related to Vue i18n import * suggested changes using translation key and fallback to player name --- .../external-player-settings.js | 5 ++++- src/renderer/store/modules/utils.js | 13 ++++++++++++- static/external-player-map.json | 4 ++++ static/locales/en-US.yaml | 3 +++ static/locales/es.yaml | 3 +++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/external-player-settings/external-player-settings.js b/src/renderer/components/external-player-settings/external-player-settings.js index 04d7bd26..f847a987 100644 --- a/src/renderer/components/external-player-settings/external-player-settings.js +++ b/src/renderer/components/external-player-settings/external-player-settings.js @@ -24,7 +24,10 @@ export default Vue.extend({ }, externalPlayerNames: function () { - return this.$store.getters.getExternalPlayerNames + const fallbackNames = this.$store.getters.getExternalPlayerNames + const nameTranslationKeys = this.$store.getters.getExternalPlayerNameTranslationKeys + + return nameTranslationKeys.map((translationKey, idx) => this.$te(translationKey) ? this.$t(translationKey) : fallbackNames[idx]) }, externalPlayerValues: function () { return this.$store.getters.getExternalPlayerValues diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index 4f6f26a2..5e7d120a 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -107,6 +107,7 @@ const state = { '#B4BEFE' ], externalPlayerNames: [], + externalPlayerNameTranslationKeys: [], externalPlayerValues: [], externalPlayerCmdArguments: {} } @@ -168,6 +169,10 @@ const getters = { return state.externalPlayerNames }, + getExternalPlayerNameTranslationKeys () { + return state.externalPlayerNameTranslationKeys + }, + getExternalPlayerValues () { return state.externalPlayerValues }, @@ -939,10 +944,11 @@ const actions = { } const externalPlayerMap = JSON.parse(fileData).map((entry) => { - return { name: entry.name, value: entry.value, cmdArguments: entry.cmdArguments } + return { name: entry.name, nameTranslationKey: entry.nameTranslationKey, value: entry.value, cmdArguments: entry.cmdArguments } }) const externalPlayerNames = externalPlayerMap.map((entry) => { return entry.name }) + const externalPlayerNameTranslationKeys = externalPlayerMap.map((entry) => { return entry.nameTranslationKey }) const externalPlayerValues = externalPlayerMap.map((entry) => { return entry.value }) const externalPlayerCmdArguments = externalPlayerMap.reduce((result, item) => { result[item.value] = item.cmdArguments @@ -950,6 +956,7 @@ const actions = { }, {}) commit('setExternalPlayerNames', externalPlayerNames) + commit('setExternalPlayerNameTranslationKeys', externalPlayerNameTranslationKeys) commit('setExternalPlayerValues', externalPlayerValues) commit('setExternalPlayerCmdArguments', externalPlayerCmdArguments) }, @@ -1162,6 +1169,10 @@ const mutations = { state.externalPlayerNames = value }, + setExternalPlayerNameTranslationKeys (state, value) { + state.externalPlayerNameTranslationKeys = value + }, + setExternalPlayerValues (state, value) { state.externalPlayerValues = value }, diff --git a/static/external-player-map.json b/static/external-player-map.json index 721549db..ac28c4aa 100644 --- a/static/external-player-map.json +++ b/static/external-player-map.json @@ -1,11 +1,13 @@ [ { "name": "None", + "nameTranslationKey": "Settings.External Player Settings.Players.None.Name", "value": "", "cmdArguments": null }, { "name": "mpv", + "nameTranslationKey": "Settings.External Player Settings.Players.mpv.Name", "value": "mpv", "cmdArguments": { "defaultExecutable": "mpv", @@ -23,6 +25,7 @@ }, { "name": "VLC", + "nameTranslationKey": "Settings.External Player Settings.Players.VLC.Name", "value": "vlc", "cmdArguments": { "defaultExecutable": "vlc", @@ -40,6 +43,7 @@ }, { "name": "iina", + "nameTranslationKey": "Settings.External Player Settings.Players.iina.Name", "value": "iina", "cmdArguments": { "defaultExecutable": "iina", diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index dc192515..277575bc 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -279,6 +279,9 @@ Settings: Ignore Unsupported Action Warnings: Ignore Unsupported Action Warnings Custom External Player Executable: Custom External Player Executable Custom External Player Arguments: Custom External Player Arguments + Players: + None: + Name: None Privacy Settings: Privacy Settings: Privacy Settings Remember History: Remember History diff --git a/static/locales/es.yaml b/static/locales/es.yaml index 32dbdb1a..d5bbc82d 100644 --- a/static/locales/es.yaml +++ b/static/locales/es.yaml @@ -383,6 +383,9 @@ Settings: Ignore Unsupported Action Warnings: Omitir advertencias sobre acciones no soportadas External Player: Reproductor externo External Player Settings: Reproductor externo + Players: + None: + Name: Ninguno Download Settings: Download Settings: Descargas Ask Download Path: Preguntar ruta de descarga