Skip to content

Commit

Permalink
Localize query result in API
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 30, 2020
1 parent 0ce48ee commit 520b255
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,25 +361,26 @@ class Map {
}
const geometryName = feature.getGeometryName();
const properties = feature.getProperties();
let contentHTML = '';
if (table) {
contentHTML += '<table><tbody>';
for (const key in properties) {
if (!EXCLUDE_PROPERTIES.includes(key) && key !== geometryName && properties[key] !== undefined) {
contentHTML += '<tr>';
contentHTML += `<th>${key}</th>`;
contentHTML += `<td>${properties[key]}</td>`;
contentHTML += '</tr>';
themes.getLocalePromise().then((translations) => {
let contentHTML = '';
if (table) {
contentHTML += '<table><tbody>';
for (const key in properties) {
if (!EXCLUDE_PROPERTIES.includes(key) && key !== geometryName && properties[key] !== undefined) {
contentHTML += '<tr>';
contentHTML += `<th>${translations[key] || key}</th>`;
contentHTML += `<td>${properties[key]}</td>`;
contentHTML += '</tr>';
}
}
contentHTML += '</tbody></table>';
} else {
contentHTML += `<div><b>${properties.title}</b></div>`;
contentHTML += `<p>${properties.description}</p>`;
}
contentHTML += '</tbody></table>';
} else {
contentHTML += `<div><b>${properties.title}</b></div>`;
contentHTML += `<p>${properties.description}</p>`;
}
const content = this.overlay_.getElement().querySelector('.ol-popup-content');
content.innerHTML = contentHTML;
this.overlay_.setPosition(position);
const content = this.overlay_.getElement().querySelector('.ol-popup-content');
content.innerHTML = contentHTML;
this.overlay_.setPosition(position);
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let localePromise;
* @hidden
* @return {Promise<Object<string, string>>} Promise
*/
function getLocalePromise() {
export function getLocalePromise() {
if (!constants.localeUrl) {
// Fallback to an empty dict
return Promise.resolve({});
Expand Down

0 comments on commit 520b255

Please sign in to comment.