Fix i18n word used as variables.

This is the same as concatenating strings, which we must avoid. It will be hard for translators to handle as they see strings as individual entries, not programmable strings. Untranslated variable values are fine.

https://www.linkedin.com/pulse/internationalization-localization-tips-concatenation-daniel-neumann
This commit is contained in:
infinite-persistence 2021-09-11 10:34:18 +08:00
parent 058b8f82ab
commit f5fb5c87c4
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 13 additions and 4 deletions

View file

@ -1177,7 +1177,11 @@
"Tap to unmute": "Tap to unmute", "Tap to unmute": "Tap to unmute",
"Retry": "Retry", "Retry": "Retry",
"Playing in %seconds_left% seconds...": "Playing in %seconds_left% seconds...", "Playing in %seconds_left% seconds...": "Playing in %seconds_left% seconds...",
"Playing next free content in %seconds_left% seconds...": "Playing next free content in %seconds_left% seconds...",
"Autoplay timer paused.": "Autoplay timer paused.", "Autoplay timer paused.": "Autoplay timer paused.",
"Play Previous": "Play Previous",
"Purchase?": "Purchase?",
"Replay?": "Replay?",
"0 Bytes": "0 Bytes", "0 Bytes": "0 Bytes",
"Bytes": "Bytes", "Bytes": "Bytes",
"KB": "KB", "KB": "KB",

View file

@ -50,6 +50,14 @@ function AutoplayCountdown(props: Props) {
return elm && elm.getBoundingClientRect().top < 0; return elm && elm.getBoundingClientRect().top < 0;
} }
function getMsgPlayingNext() {
if (skipPaid) {
return __('Playing next free content in %seconds_left% seconds...', { seconds_left: timer });
} else {
return __('Playing in %seconds_left% seconds...', { seconds_left: timer });
}
}
// Update 'setTimerPaused'. // Update 'setTimerPaused'.
React.useEffect(() => { React.useEffect(() => {
// Ensure correct 'setTimerPaused' on initial render. // Ensure correct 'setTimerPaused' on initial render.
@ -112,10 +120,7 @@ function AutoplayCountdown(props: Props) {
)} )}
{!isTimerPaused && ( {!isTimerPaused && (
<div className="file-viewer__overlay-secondary autoplay-countdown__counter"> <div className="file-viewer__overlay-secondary autoplay-countdown__counter">
{__('Playing %message% in %seconds_left% seconds...', { {getMsgPlayingNext()}{' '}
message: skipPaid ? __('next free content') : __(''),
seconds_left: timer,
})}{' '}
<Button <Button
label={__('Cancel')} label={__('Cancel')}
button="link" button="link"