Language as window.language for access in pure function
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
sidebar:
|
||||
now_playing: GERMAN
|
||||
search: GERMAN
|
||||
now_playing: Läuft gerade
|
||||
settings: Einstellungen
|
||||
now_playing:
|
||||
title: Läuft gerade
|
||||
settings:
|
||||
title: Einstellungen
|
||||
@ -1,5 +1,9 @@
|
||||
import { merge } from 'lodash';
|
||||
import en from './en.yaml';
|
||||
import de from './de.yaml';
|
||||
import _de from './de.yaml';
|
||||
|
||||
const de = {};
|
||||
merge(de, en, _de);
|
||||
|
||||
export default {
|
||||
en,
|
||||
|
||||
@ -22,4 +22,23 @@ now_playing:
|
||||
current_track:
|
||||
playing_from: Playling from
|
||||
shuffle: Shuffle
|
||||
clear: Clear
|
||||
clear: Clear
|
||||
search:
|
||||
title: 'Search: %{term}'
|
||||
context_actions:
|
||||
sort: Sort
|
||||
source: Sources (%{count})
|
||||
placeholder: Search
|
||||
artists:
|
||||
title: Artists
|
||||
more: All artists (%{count})
|
||||
albums:
|
||||
title: Albums
|
||||
more: All albums (%{count})
|
||||
playlists:
|
||||
title: Playlists
|
||||
more: All playlists (%{count})
|
||||
tracks:
|
||||
title: Tracks
|
||||
settings:
|
||||
title: Settings
|
||||
@ -7,9 +7,11 @@ import { titleCase } from '../util/helpers';
|
||||
const PARAMS_REG_EXP = '%{(.*?)}';
|
||||
const paramsRegExp = new RegExp(PARAMS_REG_EXP, 'g');
|
||||
|
||||
const content = (path, params = {}, transform, dictionary) => {
|
||||
const content = (path, params = {}, transform) => {
|
||||
console.log(window.language);
|
||||
const dictionary = dictionaries[window.language || 'en'] || dictionaries.en;
|
||||
|
||||
let value = get((dictionary || dictionaries.en), path, '');
|
||||
let value = get((dictionary), path, '');
|
||||
value = value.replace(
|
||||
paramsRegExp,
|
||||
(replaceText, key) => params.hasOwnProperty(key) ? params[key] : '',
|
||||
@ -32,16 +34,12 @@ const content = (path, params = {}, transform, dictionary) => {
|
||||
return value;
|
||||
};
|
||||
|
||||
const Content = ({ path, params = {}, transform, children }) => {
|
||||
const language = useSelector((state) => state.ui.language);
|
||||
const dictionary = dictionaries[language];
|
||||
return (
|
||||
<Fragment>
|
||||
{content(path, params, transform, dictionary)}
|
||||
{children}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
const Content = ({ path, params = {}, transform, children }) => (
|
||||
<Fragment>
|
||||
{content(path, params, transform)}
|
||||
{children}
|
||||
</Fragment>
|
||||
);
|
||||
|
||||
export default {
|
||||
Content,
|
||||
|
||||
Reference in New Issue
Block a user