mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-09 11:52:35 +03:00
Move language merge logic to i18n/index
This simplifies implementations one new languages
This commit is contained in:
parent
a6c9bf1b15
commit
3c4de3c8b5
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import { createHashHistory } from 'history'
|
import { createHashHistory } from 'history'
|
||||||
import { Admin, resolveBrowserLocale, Resource } from 'react-admin'
|
import { Admin, Resource } from 'react-admin'
|
||||||
import dataProvider from './dataProvider'
|
import dataProvider from './dataProvider'
|
||||||
import authProvider from './authProvider'
|
import authProvider from './authProvider'
|
||||||
import polyglotI18nProvider from 'ra-i18n-polyglot'
|
import polyglotI18nProvider from 'ra-i18n-polyglot'
|
||||||
@ -21,7 +21,7 @@ import createAdminStore from './store/createAdminStore'
|
|||||||
|
|
||||||
const i18nProvider = polyglotI18nProvider(
|
const i18nProvider = polyglotI18nProvider(
|
||||||
(locale) => (messages[locale] ? messages[locale] : messages.en),
|
(locale) => (messages[locale] ? messages[locale] : messages.en),
|
||||||
localStorage.getItem('locale') || resolveBrowserLocale()
|
localStorage.getItem('locale') || 'en'
|
||||||
)
|
)
|
||||||
|
|
||||||
const history = createHashHistory()
|
const history = createHashHistory()
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
|
import deepmerge from 'deepmerge'
|
||||||
import en from './en'
|
import en from './en'
|
||||||
import pt from './pt'
|
import pt from './pt'
|
||||||
|
|
||||||
// When adding a new translation, import it above and add it to the list bellow
|
const addLanguages = (lang) => {
|
||||||
|
Object.keys(lang).forEach((l) => (languages[l] = deepmerge(en, lang[l])))
|
||||||
|
}
|
||||||
|
const languages = { en }
|
||||||
|
|
||||||
const allLanguages = { en, pt }
|
// Add new languages to the object bellow
|
||||||
|
addLanguages({ pt })
|
||||||
|
|
||||||
// "Hack" to make "albumSongs" resource use the same translations as "song"
|
// "Hack" to make "albumSongs" resource use the same translations as "song"
|
||||||
Object.keys(allLanguages).forEach(
|
Object.keys(languages).forEach(
|
||||||
(k) => (allLanguages[k].resources.albumSong = allLanguages[k].resources.song)
|
(k) => (languages[k].resources.albumSong = languages[k].resources.song)
|
||||||
)
|
)
|
||||||
|
|
||||||
export default allLanguages
|
export default languages
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
import deepmerge from 'deepmerge'
|
import deepmerge from 'deepmerge'
|
||||||
import en from './en'
|
|
||||||
import portugueseMessages from 'ra-language-portuguese'
|
import portugueseMessages from 'ra-language-portuguese'
|
||||||
|
|
||||||
export default deepmerge.all([
|
export default deepmerge(portugueseMessages, {
|
||||||
en,
|
|
||||||
portugueseMessages,
|
|
||||||
{
|
|
||||||
languageName: 'Português',
|
languageName: 'Português',
|
||||||
resources: {
|
resources: {
|
||||||
song: {
|
song: {
|
||||||
@ -14,12 +10,15 @@ export default deepmerge.all([
|
|||||||
title: 'Título',
|
title: 'Título',
|
||||||
artist: 'Artista',
|
artist: 'Artista',
|
||||||
album: 'Álbum',
|
album: 'Álbum',
|
||||||
path: 'Caminho',
|
path: 'Arquivo',
|
||||||
genre: 'Gênero',
|
genre: 'Gênero',
|
||||||
compilation: 'Coletânea',
|
compilation: 'Coletânea',
|
||||||
duration: 'Duração',
|
duration: 'Duração',
|
||||||
year: 'Ano',
|
year: 'Ano',
|
||||||
trackNumber: '#'
|
playCount: 'Execuções',
|
||||||
|
trackNumber: '#',
|
||||||
|
size: 'Tamanho',
|
||||||
|
updatedAt: 'Últ. Atualização'
|
||||||
},
|
},
|
||||||
bulk: {
|
bulk: {
|
||||||
addToQueue: 'Play Later'
|
addToQueue: 'Play Later'
|
||||||
@ -30,9 +29,9 @@ export default deepmerge.all([
|
|||||||
fields: {
|
fields: {
|
||||||
name: 'Nome',
|
name: 'Nome',
|
||||||
artist: 'Artista',
|
artist: 'Artista',
|
||||||
songCount: 'Songs',
|
songCount: 'Músicas',
|
||||||
genre: 'Gênero',
|
genre: 'Gênero',
|
||||||
playCount: 'Plays',
|
playCount: 'Execuções',
|
||||||
compilation: 'Coletânea',
|
compilation: 'Coletânea',
|
||||||
duration: 'Duração',
|
duration: 'Duração',
|
||||||
year: 'Ano'
|
year: 'Ano'
|
||||||
@ -47,7 +46,8 @@ export default deepmerge.all([
|
|||||||
artist: {
|
artist: {
|
||||||
name: 'Artista |||| Artistas',
|
name: 'Artista |||| Artistas',
|
||||||
fields: {
|
fields: {
|
||||||
name: 'Nome'
|
name: 'Nome',
|
||||||
|
albumCount: 'Total de Álbuns'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
@ -109,5 +109,4 @@ export default deepmerge.all([
|
|||||||
shufflePlay: 'Aleatório'
|
shufflePlay: 'Aleatório'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
])
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { fetchUtils } from 'react-admin'
|
import { fetchUtils } from 'react-admin'
|
||||||
import baseUrl from "../utils/baseUrl"
|
import baseUrl from '../utils/baseUrl'
|
||||||
|
|
||||||
const url = (command, id, options) => {
|
const url = (command, id, options) => {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user