mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-06 10:23:21 +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,113 +1,112 @@
|
|||||||
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,
|
languageName: 'Português',
|
||||||
portugueseMessages,
|
resources: {
|
||||||
{
|
song: {
|
||||||
languageName: 'Português',
|
name: 'Música |||| Músicas',
|
||||||
resources: {
|
fields: {
|
||||||
song: {
|
title: 'Título',
|
||||||
name: 'Música |||| Músicas',
|
artist: 'Artista',
|
||||||
fields: {
|
album: 'Álbum',
|
||||||
title: 'Título',
|
path: 'Arquivo',
|
||||||
artist: 'Artista',
|
genre: 'Gênero',
|
||||||
album: 'Álbum',
|
compilation: 'Coletânea',
|
||||||
path: 'Caminho',
|
duration: 'Duração',
|
||||||
genre: 'Gênero',
|
year: 'Ano',
|
||||||
compilation: 'Coletânea',
|
playCount: 'Execuções',
|
||||||
duration: 'Duração',
|
trackNumber: '#',
|
||||||
year: 'Ano',
|
size: 'Tamanho',
|
||||||
trackNumber: '#'
|
updatedAt: 'Últ. Atualização'
|
||||||
},
|
|
||||||
bulk: {
|
|
||||||
addToQueue: 'Play Later'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
album: {
|
bulk: {
|
||||||
name: 'Álbum |||| Álbuns',
|
addToQueue: 'Play Later'
|
||||||
fields: {
|
|
||||||
name: 'Nome',
|
|
||||||
artist: 'Artista',
|
|
||||||
songCount: 'Songs',
|
|
||||||
genre: 'Gênero',
|
|
||||||
playCount: 'Plays',
|
|
||||||
compilation: 'Coletânea',
|
|
||||||
duration: 'Duração',
|
|
||||||
year: 'Ano'
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
playAll: 'Play',
|
|
||||||
playNext: 'Play Next',
|
|
||||||
addToQueue: 'Play Later',
|
|
||||||
shuffle: 'Shuffle'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
artist: {
|
|
||||||
name: 'Artista |||| Artistas',
|
|
||||||
fields: {
|
|
||||||
name: 'Nome'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
user: {
|
|
||||||
name: 'Usuário |||| Usuários',
|
|
||||||
fields: {
|
|
||||||
name: 'Nome'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
transcoding: {
|
|
||||||
name: 'Conversão |||| Conversões',
|
|
||||||
fields: {
|
|
||||||
name: 'Nome'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
player: {
|
|
||||||
name: 'Tocador |||| Tocadores',
|
|
||||||
fields: {
|
|
||||||
name: 'Nome'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ra: {
|
album: {
|
||||||
auth: {
|
name: 'Álbum |||| Álbuns',
|
||||||
welcome1: 'Thanks for installing Navidrome!',
|
fields: {
|
||||||
welcome2: 'To start, create an admin user',
|
name: 'Nome',
|
||||||
confirmPassword: 'Confirm Password',
|
artist: 'Artista',
|
||||||
buttonCreateAdmin: 'Create Admin'
|
songCount: 'Músicas',
|
||||||
|
genre: 'Gênero',
|
||||||
|
playCount: 'Execuções',
|
||||||
|
compilation: 'Coletânea',
|
||||||
|
duration: 'Duração',
|
||||||
|
year: 'Ano'
|
||||||
},
|
},
|
||||||
validation: {
|
actions: {
|
||||||
invalidChars: 'Please only use letter and numbers',
|
playAll: 'Play',
|
||||||
passwordDoesNotMatch: 'Password does not match'
|
playNext: 'Play Next',
|
||||||
|
addToQueue: 'Play Later',
|
||||||
|
shuffle: 'Shuffle'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
menu: {
|
artist: {
|
||||||
library: 'Biblioteca',
|
name: 'Artista |||| Artistas',
|
||||||
settings: 'Configurações',
|
fields: {
|
||||||
version: 'Versão %{version}',
|
name: 'Nome',
|
||||||
personal: {
|
albumCount: 'Total de Álbuns'
|
||||||
name: 'Pessoal',
|
}
|
||||||
options: {
|
},
|
||||||
theme: 'Tema',
|
user: {
|
||||||
language: 'Língua'
|
name: 'Usuário |||| Usuários',
|
||||||
}
|
fields: {
|
||||||
|
name: 'Nome'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
transcoding: {
|
||||||
|
name: 'Conversão |||| Conversões',
|
||||||
|
fields: {
|
||||||
|
name: 'Nome'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
playListsText: 'Fila de Execução',
|
name: 'Tocador |||| Tocadores',
|
||||||
openText: 'Abrir',
|
fields: {
|
||||||
closeText: 'Fechar',
|
name: 'Nome'
|
||||||
clickToPlayText: 'Clique para tocar',
|
|
||||||
clickToPauseText: 'Clique para pausar',
|
|
||||||
nextTrackText: 'Próxima faixa',
|
|
||||||
previousTrackText: 'Faixa anterior',
|
|
||||||
clickToDeleteText: `Clique para remover %{name}`,
|
|
||||||
playModeText: {
|
|
||||||
order: 'Em ordem',
|
|
||||||
orderLoop: 'Repetir tudo',
|
|
||||||
singleLoop: 'Repetir',
|
|
||||||
shufflePlay: 'Aleatório'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
ra: {
|
||||||
|
auth: {
|
||||||
|
welcome1: 'Thanks for installing Navidrome!',
|
||||||
|
welcome2: 'To start, create an admin user',
|
||||||
|
confirmPassword: 'Confirm Password',
|
||||||
|
buttonCreateAdmin: 'Create Admin'
|
||||||
|
},
|
||||||
|
validation: {
|
||||||
|
invalidChars: 'Please only use letter and numbers',
|
||||||
|
passwordDoesNotMatch: 'Password does not match'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
menu: {
|
||||||
|
library: 'Biblioteca',
|
||||||
|
settings: 'Configurações',
|
||||||
|
version: 'Versão %{version}',
|
||||||
|
personal: {
|
||||||
|
name: 'Pessoal',
|
||||||
|
options: {
|
||||||
|
theme: 'Tema',
|
||||||
|
language: 'Língua'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
player: {
|
||||||
|
playListsText: 'Fila de Execução',
|
||||||
|
openText: 'Abrir',
|
||||||
|
closeText: 'Fechar',
|
||||||
|
clickToPlayText: 'Clique para tocar',
|
||||||
|
clickToPauseText: 'Clique para pausar',
|
||||||
|
nextTrackText: 'Próxima faixa',
|
||||||
|
previousTrackText: 'Faixa anterior',
|
||||||
|
clickToDeleteText: `Clique para remover %{name}`,
|
||||||
|
playModeText: {
|
||||||
|
order: 'Em ordem',
|
||||||
|
orderLoop: 'Repetir tudo',
|
||||||
|
singleLoop: 'Repetir',
|
||||||
|
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