Merge pull request #371 from Stremio/refactor/player-translations

Player: add translation strings
This commit is contained in:
Tim 2023-05-25 10:33:06 +02:00 committed by GitHub
commit a98f6f73d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 21 deletions

14
package-lock.json generated
View file

@ -36,7 +36,7 @@
"react-i18next": "^12.1.1",
"react-is": "18.2.0",
"spatial-navigation-polyfill": "git+https://git@github.com/Stremio/spatial-navigation.git#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "git+https://git@github.com/Stremio/stremio-translations.git#ef047329f5bcb0a8f96008fca05c68b449b34cb1",
"stremio-translations": "git+https://git@github.com/Stremio/stremio-translations.git#f55fe0d7dfe33bd6be461b4430cba2319afd1d8e",
"url": "0.11.0"
},
"devDependencies": {
@ -12847,9 +12847,9 @@
}
},
"node_modules/stremio-translations": {
"version": "1.43.15",
"resolved": "git+https://git@github.com/Stremio/stremio-translations.git#ef047329f5bcb0a8f96008fca05c68b449b34cb1",
"integrity": "sha512-cG1GZIbCy2xWQpyYXJvlvnkWLtMBypL+BhMFJmC9LRHteAmJU++t37b5Wc6Sm1IbWoXqG508Tc9YfQ28bHTzaQ==",
"version": "1.43.16",
"resolved": "git+https://git@github.com/Stremio/stremio-translations.git#f55fe0d7dfe33bd6be461b4430cba2319afd1d8e",
"integrity": "sha512-yCFQSjZ1R/xjbHiPb7UZnWUFNu5YQq6vsdzSQZ1DGizwGnERxUvRwyzh8a1tlNOEyjZoZyI4cqdbv/LHRGCqbA==",
"license": "MIT"
},
"node_modules/string_decoder": {
@ -24508,9 +24508,9 @@
"dev": true
},
"stremio-translations": {
"version": "git+https://git@github.com/Stremio/stremio-translations.git#ef047329f5bcb0a8f96008fca05c68b449b34cb1",
"integrity": "sha512-cG1GZIbCy2xWQpyYXJvlvnkWLtMBypL+BhMFJmC9LRHteAmJU++t37b5Wc6Sm1IbWoXqG508Tc9YfQ28bHTzaQ==",
"from": "stremio-translations@git+https://git@github.com/Stremio/stremio-translations.git#ef047329f5bcb0a8f96008fca05c68b449b34cb1"
"version": "git+https://git@github.com/Stremio/stremio-translations.git#f55fe0d7dfe33bd6be461b4430cba2319afd1d8e",
"integrity": "sha512-yCFQSjZ1R/xjbHiPb7UZnWUFNu5YQq6vsdzSQZ1DGizwGnERxUvRwyzh8a1tlNOEyjZoZyI4cqdbv/LHRGCqbA==",
"from": "stremio-translations@git+https://git@github.com/Stremio/stremio-translations.git#f55fe0d7dfe33bd6be461b4430cba2319afd1d8e"
},
"string_decoder": {
"version": "1.1.1",

View file

@ -39,7 +39,7 @@
"react-i18next": "^12.1.1",
"react-is": "18.2.0",
"spatial-navigation-polyfill": "git+https://git@github.com/Stremio/spatial-navigation.git#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "git+https://git@github.com/Stremio/stremio-translations.git#ef047329f5bcb0a8f96008fca05c68b449b34cb1",
"stremio-translations": "git+https://git@github.com/Stremio/stremio-translations.git#f55fe0d7dfe33bd6be461b4430cba2319afd1d8e",
"url": "0.11.0"
},
"devDependencies": {

View file

@ -3,12 +3,14 @@
const React = require('react');
const PropTypes = require('prop-types');
const classnames = require('classnames');
const { useTranslation } = require('react-i18next');
const { useToast } = require('stremio/common');
const { useServices } = require('stremio/services');
const Option = require('./Option');
const styles = require('./styles');
const OptionsMenu = ({ className, stream, playbackDevices }) => {
const { t } = useTranslation();
const { core } = useServices();
const toast = useToast();
const [streamingUrl, downloadUrl] = React.useMemo(() => {
@ -29,7 +31,7 @@ const OptionsMenu = ({ className, stream, playbackDevices }) => {
toast.show({
type: 'success',
title: 'Copied',
message: 'Stream link was copied to your clipboard',
message: t('PLAYER_COPY_STREAM_SUCCESS'),
timeout: 3000
});
})
@ -37,8 +39,8 @@ const OptionsMenu = ({ className, stream, playbackDevices }) => {
console.error(e);
toast.show({
type: 'error',
title: 'Error',
message: `Failed to copy stream link: ${streamingUrl || downloadUrl}`,
title: t('Error'),
message: `${t('PLAYER_COPY_STREAM_ERROR')}: ${streamingUrl || downloadUrl}`,
timeout: 3000
});
});
@ -72,7 +74,7 @@ const OptionsMenu = ({ className, stream, playbackDevices }) => {
streamingUrl || downloadUrl ?
<Option
icon={'ic_link'}
label={'Copy Stream Link'}
label={t('CTX_COPY_STREAM_LINK')}
disabled={stream === null}
onClick={onCopyStreamButtonClick}
/>
@ -83,7 +85,7 @@ const OptionsMenu = ({ className, stream, playbackDevices }) => {
streamingUrl || downloadUrl ?
<Option
icon={'ic_downloads'}
label={'Download Video'}
label={t('CTX_DOWNLOAD_VIDEO')}
disabled={stream === null}
onClick={onDownloadVideoButtonClick}
/>
@ -95,7 +97,7 @@ const OptionsMenu = ({ className, stream, playbackDevices }) => {
<Option
key={id}
icon={'ic_vlc'}
label={`Play in ${name}`}
label={t('PLAYER_PLAY_IN', { device: name })}
deviceId={id}
disabled={stream === null}
onClick={onExternalDeviceRequested}

View file

@ -5,6 +5,7 @@ const PropTypes = require('prop-types');
const classnames = require('classnames');
const debounce = require('lodash.debounce');
const langs = require('langs');
const { useTranslation } = require('react-i18next');
const { useRouteFocused } = require('stremio-router');
const { useServices } = require('stremio/services');
const { HorizontalNavBar, Button, useFullscreen, useBinaryState, useToast, useStreamingServer, withCoreSuspender } = require('stremio/common');
@ -23,6 +24,7 @@ const useSettings = require('./useSettings');
const styles = require('./styles');
const Player = ({ urlParams, queryParams }) => {
const { t } = useTranslation();
const { chromecast, shell, core } = useServices();
const [forceTranscoding, maxAudioChannels] = React.useMemo(() => {
return [
@ -124,7 +126,7 @@ const Player = ({ urlParams, queryParams }) => {
} else {
toast.show({
type: 'error',
title: 'Error',
title: t('ERROR'),
message: error.message,
timeout: 3000
});
@ -133,16 +135,16 @@ const Player = ({ urlParams, queryParams }) => {
const onSubtitlesTrackLoaded = React.useCallback(() => {
toast.show({
type: 'success',
title: 'Subtitles loaded',
message: 'Embedded subtitles loaded',
title: t('PLAYER_SUBTITLES_LOADED'),
message: t('PLAYER_SUBTITLES_LOADED_EMBEDDED'),
timeout: 3000
});
}, []);
const onExtraSubtitlesTrackLoaded = React.useCallback((track) => {
toast.show({
type: 'success',
title: 'Subtitles loaded',
message: track.exclusive ? 'Exclusice subtitles loaded' : `Subtitles from ${track.origin} loaded`,
title: t('PLAYER_SUBTITLES_LOADED'),
message: track.exclusive ? t('PLAYER_SUBTITLES_LOADED_EXCLUSIVE') : t('PLAYER_SUBTITLES_LOADED_ORIGIN', { origin: track.origin }),
timeout: 3000
});
}, []);
@ -597,9 +599,9 @@ const Player = ({ urlParams, queryParams }) => {
<div className={styles['error-label']} title={error.message}>{error.message}</div>
{
player.selected !== null ?
<Button className={styles['playlist-button']} title={'Open in external player'} href={player.selected.stream.deepLinks.externalPlayer.href} download={player.selected.stream.deepLinks.externalPlayer.fileName} target={'_blank'}>
<Button className={styles['playlist-button']} title={t('PLAYER_OPEN_IN_EXTERNAL')} href={player.selected.stream.deepLinks.externalPlayer.href} download={player.selected.stream.deepLinks.externalPlayer.fileName} target={'_blank'}>
<Icon className={styles['icon']} icon={'ic_downloads'} />
<div className={styles['label']}>Open in external player</div>
<div className={styles['label']}>{t('PLAYER_OPEN_IN_EXTERNAL')}</div>
</Button>
:
null