mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-28 07:56:15 -04:00
Added french translation and language switcher
This commit is contained in:
parent
7555ed0ff1
commit
1b4d2fba81
7 changed files with 341 additions and 298 deletions
|
@ -5,9 +5,12 @@ import {getSettingValue} from "../settings";
|
|||
type translationKeys = keyof typeof en
|
||||
type translation= { [key in translationKeys] : string }
|
||||
const languages:Record<string, translation>= {fr,en}
|
||||
export function getCurrentLang(){
|
||||
return getSettingValue('lang',getFirstBrowserLanguage())
|
||||
}
|
||||
|
||||
export function t(key: translationKeys, params: {[key:string]:any} = {}):string {
|
||||
const lang = getSettingValue('lang',getFirstBrowserLanguage())
|
||||
const lang = getCurrentLang()
|
||||
let template=languages[lang]?.[key] || languages.en[key]
|
||||
for(let key in params){
|
||||
template=template.split('{{'+key+'}}').join(`${params[key]}`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue