mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 04:00:38 +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 { Provider } from 'react-redux'
|
||||
import { createHashHistory } from 'history'
|
||||
import { Admin, resolveBrowserLocale, Resource } from 'react-admin'
|
||||
import { Admin, Resource } from 'react-admin'
|
||||
import dataProvider from './dataProvider'
|
||||
import authProvider from './authProvider'
|
||||
import polyglotI18nProvider from 'ra-i18n-polyglot'
|
||||
@ -21,7 +21,7 @@ import createAdminStore from './store/createAdminStore'
|
||||
|
||||
const i18nProvider = polyglotI18nProvider(
|
||||
(locale) => (messages[locale] ? messages[locale] : messages.en),
|
||||
localStorage.getItem('locale') || resolveBrowserLocale()
|
||||
localStorage.getItem('locale') || 'en'
|
||||
)
|
||||
|
||||
const history = createHashHistory()
|
||||
|
@ -1,13 +1,18 @@
|
||||
import deepmerge from 'deepmerge'
|
||||
import en from './en'
|
||||
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"
|
||||
Object.keys(allLanguages).forEach(
|
||||
(k) => (allLanguages[k].resources.albumSong = allLanguages[k].resources.song)
|
||||
Object.keys(languages).forEach(
|
||||
(k) => (languages[k].resources.albumSong = languages[k].resources.song)
|
||||
)
|
||||
|
||||
export default allLanguages
|
||||
export default languages
|
||||
|
@ -1,113 +1,112 @@
|
||||
import deepmerge from 'deepmerge'
|
||||
import en from './en'
|
||||
import portugueseMessages from 'ra-language-portuguese'
|
||||
|
||||
export default deepmerge.all([
|
||||
en,
|
||||
portugueseMessages,
|
||||
{
|
||||
languageName: 'Português',
|
||||
resources: {
|
||||
song: {
|
||||
name: 'Música |||| Músicas',
|
||||
fields: {
|
||||
title: 'Título',
|
||||
artist: 'Artista',
|
||||
album: 'Álbum',
|
||||
path: 'Caminho',
|
||||
genre: 'Gênero',
|
||||
compilation: 'Coletânea',
|
||||
duration: 'Duração',
|
||||
year: 'Ano',
|
||||
trackNumber: '#'
|
||||
},
|
||||
bulk: {
|
||||
addToQueue: 'Play Later'
|
||||
}
|
||||
export default deepmerge(portugueseMessages, {
|
||||
languageName: 'Português',
|
||||
resources: {
|
||||
song: {
|
||||
name: 'Música |||| Músicas',
|
||||
fields: {
|
||||
title: 'Título',
|
||||
artist: 'Artista',
|
||||
album: 'Álbum',
|
||||
path: 'Arquivo',
|
||||
genre: 'Gênero',
|
||||
compilation: 'Coletânea',
|
||||
duration: 'Duração',
|
||||
year: 'Ano',
|
||||
playCount: 'Execuções',
|
||||
trackNumber: '#',
|
||||
size: 'Tamanho',
|
||||
updatedAt: 'Últ. Atualização'
|
||||
},
|
||||
album: {
|
||||
name: 'Álbum |||| Álbuns',
|
||||
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'
|
||||
}
|
||||
bulk: {
|
||||
addToQueue: 'Play Later'
|
||||
}
|
||||
},
|
||||
ra: {
|
||||
auth: {
|
||||
welcome1: 'Thanks for installing Navidrome!',
|
||||
welcome2: 'To start, create an admin user',
|
||||
confirmPassword: 'Confirm Password',
|
||||
buttonCreateAdmin: 'Create Admin'
|
||||
album: {
|
||||
name: 'Álbum |||| Álbuns',
|
||||
fields: {
|
||||
name: 'Nome',
|
||||
artist: 'Artista',
|
||||
songCount: 'Músicas',
|
||||
genre: 'Gênero',
|
||||
playCount: 'Execuções',
|
||||
compilation: 'Coletânea',
|
||||
duration: 'Duração',
|
||||
year: 'Ano'
|
||||
},
|
||||
validation: {
|
||||
invalidChars: 'Please only use letter and numbers',
|
||||
passwordDoesNotMatch: 'Password does not match'
|
||||
actions: {
|
||||
playAll: 'Play',
|
||||
playNext: 'Play Next',
|
||||
addToQueue: 'Play Later',
|
||||
shuffle: 'Shuffle'
|
||||
}
|
||||
},
|
||||
menu: {
|
||||
library: 'Biblioteca',
|
||||
settings: 'Configurações',
|
||||
version: 'Versão %{version}',
|
||||
personal: {
|
||||
name: 'Pessoal',
|
||||
options: {
|
||||
theme: 'Tema',
|
||||
language: 'Língua'
|
||||
}
|
||||
artist: {
|
||||
name: 'Artista |||| Artistas',
|
||||
fields: {
|
||||
name: 'Nome',
|
||||
albumCount: 'Total de Álbuns'
|
||||
}
|
||||
},
|
||||
user: {
|
||||
name: 'Usuário |||| Usuários',
|
||||
fields: {
|
||||
name: 'Nome'
|
||||
}
|
||||
},
|
||||
transcoding: {
|
||||
name: 'Conversão |||| Conversões',
|
||||
fields: {
|
||||
name: 'Nome'
|
||||
}
|
||||
},
|
||||
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'
|
||||
name: 'Tocador |||| Tocadores',
|
||||
fields: {
|
||||
name: 'Nome'
|
||||
}
|
||||
}
|
||||
},
|
||||
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 baseUrl from "../utils/baseUrl"
|
||||
import baseUrl from '../utils/baseUrl'
|
||||
|
||||
const url = (command, id, options) => {
|
||||
const params = new URLSearchParams()
|
||||
|
Loading…
x
Reference in New Issue
Block a user