forked from MapComplete/MapComplete
Half complete i18n
This commit is contained in:
parent
7c1c9bc80a
commit
232664ee14
10 changed files with 100 additions and 24 deletions
18
UI/i18n/Locale.ts
Normal file
18
UI/i18n/Locale.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { UIEventSource } from "../UIEventSource";
|
||||
|
||||
|
||||
const LANGUAGE_KEY = 'language'
|
||||
|
||||
export default class Locale {
|
||||
public static language: UIEventSource<string> = new UIEventSource(Locale.getInitialLanguage())
|
||||
|
||||
public static init() {
|
||||
Locale.language.addCallback(data => {
|
||||
localStorage.setItem(LANGUAGE_KEY, data)
|
||||
})
|
||||
}
|
||||
|
||||
private static getInitialLanguage() {
|
||||
return localStorage.getItem(LANGUAGE_KEY)
|
||||
}
|
||||
}
|
16
UI/i18n/Translation.ts
Normal file
16
UI/i18n/Translation.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { UIElement } from "../UIElement"
|
||||
import Locale from "./Locale"
|
||||
|
||||
|
||||
export default class Translation extends UIElement{
|
||||
protected InnerRender(): string {
|
||||
return this.translations[Locale.language.data]
|
||||
}
|
||||
|
||||
public readonly translations: object
|
||||
|
||||
constructor(translations: object) {
|
||||
super(Locale.language)
|
||||
this.translations = translations
|
||||
}
|
||||
}
|
18
UI/i18n/Translations.ts
Normal file
18
UI/i18n/Translations.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import Translation from "./Translation";
|
||||
|
||||
|
||||
export default class Translations {
|
||||
static t = {
|
||||
cylofix: {
|
||||
title: new Translation({en: 'Cyclofix bicycle infrastructure', nl: 'Cyclofix fietsinfrastructuur', fr: 'TODO: FRENCH TRANSLATION'}),
|
||||
description: new Translation({
|
||||
en: "On this map we want to collect data about the whereabouts of bicycle pumps and public racks in Brussels." +
|
||||
"As a result, cyclists will be able to quickly find the nearest infrastructure for their needs.",
|
||||
nl: "Op deze kaart willen we gegevens verzamelen over de locatie van fietspompen en openbare stelplaatsen in Brussel." +
|
||||
"Hierdoor kunnen fietsers snel de dichtstbijzijnde infrastructuur vinden die voldoet aan hun behoeften.",
|
||||
fr: "Sur cette carte, nous voulons collecter des données sur la localisation des pompes à vélo et des supports publics à Bruxelles." +
|
||||
"Les cyclistes pourront ainsi trouver rapidement l'infrastructure la plus proche de leurs besoins."
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue