From c0f98eeafe5eeb5a1ffed74c3783581b5cd66aea Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Thu, 13 Oct 2022 13:51:15 +0200 Subject: [PATCH] Use named parameters instead of $ and % in localised strings (#2685) * Use named parameters instead of $ and % in localised strings * Fix URL warning again * Update placeholders in most locales * Let the translators fix the problematic RTL strings * Fix the missing quotes in some of the YAML files --- src/renderer/App.js | 6 +- .../components/data-settings/data-settings.js | 2 +- .../external-player-settings.js | 4 +- .../ft-age-restricted/ft-age-restricted.js | 2 +- .../ft-list-playlist/ft-list-playlist.js | 1 - .../ft-list-playlist/ft-list-playlist.vue | 2 +- .../components/ft-list-video/ft-list-video.js | 5 - .../ft-list-video/ft-list-video.vue | 2 +- .../ft-profile-channel-list.js | 3 +- .../ft-profile-edit/ft-profile-edit.js | 4 +- .../ft-profile-filter-channels-list.js | 3 +- .../ft-profile-selector.js | 2 +- .../ft-video-player/ft-video-player.js | 8 +- .../general-settings/general-settings.js | 3 +- .../general-settings/general-settings.vue | 2 +- .../watch-video-comments.js | 4 - .../watch-video-comments.vue | 2 +- .../watch-video-info/watch-video-info.js | 4 +- .../watch-video-info/watch-video-info.vue | 2 +- src/renderer/i18n/index.js | 4 +- src/renderer/store/modules/utils.js | 112 +++++++----------- src/renderer/views/Channel/Channel.js | 3 +- .../SubscribedChannels/SubscribedChannels.js | 4 +- .../SubscribedChannels/SubscribedChannels.vue | 4 +- static/locales/ar.yaml | 61 +++++----- static/locales/as.yaml | 1 - static/locales/az.yaml | 31 ++--- static/locales/bg.yaml | 57 +++++---- static/locales/bn.yaml | 15 ++- static/locales/bs.yaml | 15 ++- static/locales/ca.yaml | 33 +++--- static/locales/cs.yaml | 55 +++++---- static/locales/da.yaml | 57 +++++---- static/locales/de-DE.yaml | 54 ++++----- static/locales/el.yaml | 45 ++++--- static/locales/en-US.yaml | 60 ++++------ static/locales/en_GB.yaml | 60 ++++------ static/locales/eo.yaml | 15 ++- static/locales/es-MX.yaml | 47 ++++---- static/locales/es.yaml | 59 +++++---- static/locales/es_AR.yaml | 15 ++- static/locales/et.yaml | 55 +++++---- static/locales/eu.yaml | 57 +++++---- static/locales/fa.yaml | 28 ++--- static/locales/fi.yaml | 53 ++++----- static/locales/fil.yaml | 7 +- static/locales/fr-FR.yaml | 57 +++++---- static/locales/gl.yaml | 29 +++-- static/locales/gsw.yaml | 32 ++--- static/locales/he.yaml | 55 ++++----- static/locales/hi.yaml | 15 ++- static/locales/hr.yaml | 57 +++++---- static/locales/hu.yaml | 57 +++++---- static/locales/id.yaml | 45 ++++--- static/locales/is.yaml | 59 +++++---- static/locales/it.yaml | 57 +++++---- static/locales/ja.yaml | 51 ++++---- static/locales/ka.yaml | 36 +++--- static/locales/km.yaml | 27 ++--- static/locales/ko.yaml | 51 ++++---- static/locales/ku.yaml | 15 ++- static/locales/la.yaml | 17 ++- static/locales/lt.yaml | 40 +++---- static/locales/nb_NO.yaml | 43 ++++--- static/locales/ne.yaml | 24 ++-- static/locales/nl.yaml | 57 +++++---- static/locales/nn.yaml | 29 +++-- static/locales/pl.yaml | 55 +++++---- static/locales/pt-BR.yaml | 57 +++++---- static/locales/pt-PT.yaml | 53 ++++----- static/locales/pt.yaml | 53 ++++----- static/locales/ro.yaml | 57 +++++---- static/locales/ru.yaml | 55 +++++---- static/locales/sat.yaml | 15 ++- static/locales/si.yaml | 15 ++- static/locales/sk.yaml | 37 +++--- static/locales/sl.yaml | 19 ++- static/locales/sr.yaml | 17 ++- static/locales/sv.yaml | 39 +++--- static/locales/tok.yaml | 27 ++--- static/locales/tr.yaml | 51 ++++---- static/locales/uk.yaml | 55 +++++---- static/locales/ur.yaml | 51 ++++---- static/locales/vi.yaml | 57 +++++---- static/locales/zh-CN.yaml | 51 ++++---- static/locales/zh-TW.yaml | 51 ++++---- 86 files changed, 1279 insertions(+), 1457 deletions(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index f7447b94..ec94e628 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -207,8 +207,7 @@ export default Vue.extend({ this.updateChangelog = marked.parse(json[0].body) this.changeLogTitle = json[0].name - const message = this.$t('Version $ is now available! Click for more details') - this.updateBannerMessage = message.replace('$', versionNumber) + this.updateBannerMessage = this.$t('Version {versionNumber} is now available! Click for more details', { versionNumber }) const appVersion = packageDetails.version.split('.') const latestVersion = versionNumber.split('.') @@ -242,8 +241,7 @@ export default Vue.extend({ const latestPubDate = new Date(latestBlog.pubDate) if (lastAppWasRunning === null || latestPubDate > lastAppWasRunning) { - const message = this.$t('A new blog is now available, $. Click to view more') - this.blogBannerMessage = message.replace('$', latestBlog.title) + this.blogBannerMessage = this.$t('A new blog is now available, {blogTitle}. Click to view more', { blogTitle: latestBlog.title }) this.latestBlogUrl = latestBlog.link this.showBlogBanner = true } diff --git a/src/renderer/components/data-settings/data-settings.js b/src/renderer/components/data-settings/data-settings.js index 14201469..2f28ab5d 100644 --- a/src/renderer/components/data-settings/data-settings.js +++ b/src/renderer/components/data-settings/data-settings.js @@ -1013,7 +1013,7 @@ export default Vue.extend({ const objectKeys = Object.keys(playlistObject) if ((objectKeys.length < requiredKeys.length) || playlistObject.videos.length === 0) { - const message = this.$t('Settings.Data Settings.Playlist insufficient data').replace('$', playlistData.playlistName) + const message = this.$t('Settings.Data Settings.Playlist insufficient data', { playlist: playlistData.playlistName }) this.showToast({ message: message }) 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 1b5eabb4..5e4c6841 100644 --- a/src/renderer/components/external-player-settings/external-player-settings.js +++ b/src/renderer/components/external-player-settings/external-player-settings.js @@ -47,8 +47,8 @@ export default Vue.extend({ const cmdArgs = this.$store.getters.getExternalPlayerCmdArguments[this.externalPlayer] if (cmdArgs && typeof cmdArgs.defaultCustomArguments === 'string' && cmdArgs.defaultCustomArguments !== '') { - const defaultArgs = this.$t('Tooltips.External Player Settings.DefaultCustomArgumentsTemplate') - .replace('$', cmdArgs.defaultCustomArguments) + const defaultArgs = this.$t('Tooltips.External Player Settings.DefaultCustomArgumentsTemplate', + { defaultCustomArguments: cmdArgs.defaultCustomArguments }) return `${tooltip} ${defaultArgs}` } diff --git a/src/renderer/components/ft-age-restricted/ft-age-restricted.js b/src/renderer/components/ft-age-restricted/ft-age-restricted.js index 5769012b..cc38888f 100644 --- a/src/renderer/components/ft-age-restricted/ft-age-restricted.js +++ b/src/renderer/components/ft-age-restricted/ft-age-restricted.js @@ -16,7 +16,7 @@ export default Vue.extend({ restrictedMessage: function () { const contentType = this.$t('Age Restricted.Type.' + this.contentTypeString) - return this.$t('Age Restricted.This $contentType is age restricted').replace('$contentType', contentType) + return this.$t('Age Restricted.This {videoOrPlaylist} is age restricted', { videoOrPlaylist: contentType }) } } }) diff --git a/src/renderer/components/ft-list-playlist/ft-list-playlist.js b/src/renderer/components/ft-list-playlist/ft-list-playlist.js index d6305b9e..308ec463 100644 --- a/src/renderer/components/ft-list-playlist/ft-list-playlist.js +++ b/src/renderer/components/ft-list-playlist/ft-list-playlist.js @@ -65,7 +65,6 @@ export default Vue.extend({ methods: { handleExternalPlayer: function () { this.openInExternalPlayer({ - strings: this.$t('Video.External Player'), watchProgress: 0, playbackRate: this.defaultPlayback, videoId: null, diff --git a/src/renderer/components/ft-list-playlist/ft-list-playlist.vue b/src/renderer/components/ft-list-playlist/ft-list-playlist.vue index 6e055c11..e7f38432 100644 --- a/src/renderer/components/ft-list-playlist/ft-list-playlist.vue +++ b/src/renderer/components/ft-list-playlist/ft-list-playlist.vue @@ -25,7 +25,7 @@
profile.name !== this.profile.name ? [profile.name] : []) }, selectedText: function () { - const localeText = this.$t('Profile.$ selected') - return localeText.replace('$', this.selectedLength) + return this.$t('Profile.{number} selected', { number: this.selectedLength }) } }, watch: { diff --git a/src/renderer/components/ft-profile-selector/ft-profile-selector.js b/src/renderer/components/ft-profile-selector/ft-profile-selector.js index c1507a78..94d343b9 100644 --- a/src/renderer/components/ft-profile-selector/ft-profile-selector.js +++ b/src/renderer/components/ft-profile-selector/ft-profile-selector.js @@ -78,7 +78,7 @@ export default Vue.extend({ if (targetProfile) { this.updateActiveProfile(targetProfile._id) - const message = this.$t('Profile.$ is now the active profile').replace('$', profile.name) + const message = this.$t('Profile.{profile} is now the active profile', { profile: profile.name }) this.showToast({ message }) } } diff --git a/src/renderer/components/ft-video-player/ft-video-player.js b/src/renderer/components/ft-video-player/ft-video-player.js index 1a1b2836..bb5dd269 100644 --- a/src/renderer/components/ft-video-player/ft-video-player.js +++ b/src/renderer/components/ft-video-player/ft-video-player.js @@ -1344,7 +1344,7 @@ export default Vue.extend({ } catch (err) { console.error(`Parse failed: ${err.message}`) this.showToast({ - message: this.$t('Screenshot Error').replace('$', err.message) + message: this.$t('Screenshot Error', { error: err.message }) }) canvas.remove() return @@ -1412,7 +1412,7 @@ export default Vue.extend({ } catch (err) { console.error(err) this.showToast({ - message: this.$t('Screenshot Error').replace('$', err) + message: this.$t('Screenshot Error', { error: err }) }) canvas.remove() return @@ -1429,11 +1429,11 @@ export default Vue.extend({ if (err) { console.error(err) this.showToast({ - message: this.$t('Screenshot Error').replace('$', err) + message: this.$t('Screenshot Error', { error: err }) }) } else { this.showToast({ - message: this.$t('Screenshot Success').replace('$', filePath) + message: this.$t('Screenshot Success', { filePath }) }) } }) diff --git a/src/renderer/components/general-settings/general-settings.js b/src/renderer/components/general-settings/general-settings.js index 6d650a48..f01a9332 100644 --- a/src/renderer/components/general-settings/general-settings.js +++ b/src/renderer/components/general-settings/general-settings.js @@ -193,9 +193,8 @@ export default Vue.extend({ const instance = this.currentInvidiousInstance this.updateDefaultInvidiousInstance(instance) - const message = this.$t('Default Invidious instance has been set to $') this.showToast({ - message: message.replace('$', instance) + message: this.$t('Default Invidious instance has been set to {instance}', { instance }) }) }, diff --git a/src/renderer/components/general-settings/general-settings.vue b/src/renderer/components/general-settings/general-settings.vue index a5aff4a1..82f25f6b 100644 --- a/src/renderer/components/general-settings/general-settings.vue +++ b/src/renderer/components/general-settings/general-settings.vue @@ -116,7 +116,7 @@ v-if="defaultInvidiousInstance !== ''" class="center" > - {{ $t('Settings.General Settings.The currently set default instance is $').replace('$', defaultInvidiousInstance) }} + {{ $t('Settings.General Settings.The currently set default instance is {instance}', { instance: defaultInvidiousInstance }) }}