forked from MapComplete/MapComplete
More translations!
This commit is contained in:
parent
369c19a58a
commit
7e768c1472
6 changed files with 77 additions and 32 deletions
|
@ -5,13 +5,18 @@ import {FixedUiElement} from "./Base/FixedUiElement";
|
|||
import {Geocoding} from "../Logic/Geocoding";
|
||||
import {Basemap} from "../Logic/Basemap";
|
||||
import {VariableUiElement} from "./Base/VariableUIElement";
|
||||
import Translation from "./i18n/Translation";
|
||||
import Locale from "./i18n/Locale";
|
||||
import Translations from "./i18n/Translations";
|
||||
|
||||
|
||||
export class SearchAndGo extends UIElement {
|
||||
|
||||
private _placeholder = new UIEventSource("Search a location...")
|
||||
private _placeholder = new UIEventSource<Translation>(Translations.general.search.search)
|
||||
private _searchField = new TextField<string>({
|
||||
placeholder: new VariableUiElement(this._placeholder),
|
||||
placeholder: new VariableUiElement(
|
||||
this._placeholder.map(uiElement => uiElement.InnerRender(), [Locale.language])
|
||||
),
|
||||
fromString: str => str,
|
||||
toString: str => str
|
||||
}
|
||||
|
@ -41,12 +46,12 @@ export class SearchAndGo extends UIElement {
|
|||
private RunSearch() {
|
||||
const searchString = this._searchField.GetValue().data;
|
||||
this._searchField.Clear();
|
||||
this._placeholder.setData("Searching...");
|
||||
this._placeholder.setData(Translations.general.search.searching);
|
||||
const self = this;
|
||||
Geocoding.Search(searchString, this._map, (result) => {
|
||||
|
||||
if (result.length == 0) {
|
||||
this._placeholder.setData("Niets gevonden");
|
||||
this._placeholder.setData(Translations.general.search.nothing);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,16 +61,15 @@ export class SearchAndGo extends UIElement {
|
|||
[bb[1], bb[3]]
|
||||
]
|
||||
self._map.map.fitBounds(bounds);
|
||||
this._placeholder.setData("Search a location...");
|
||||
this._placeholder.setData(Translations.general.search.search);
|
||||
},
|
||||
() => {
|
||||
this._placeholder.setData("Something went wrong. Try again.");
|
||||
this._placeholder.setData(Translations.general.search.error);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
// "<img class='search' src='./assets/search.svg' alt='Search'> " +
|
||||
return this._searchField.Render() +
|
||||
this._goButton.Render();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue