Skip to content

Commit aae85af

Browse files
committed
Pass translatable strings POC
Signed-off-by: Daniel Kastl <[email protected]>
1 parent eedb44f commit aae85af

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

config/locales/en.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,13 @@ en:
8989

9090
title_geojson_upload: "Import GeoJSON"
9191
placeholder_geojson_upload: "Please paste a GeoJSON geometry here, or import the GeoJSON data from a file."
92+
93+
# Localize for use in Javascript
94+
gtt_js:
95+
control:
96+
geocoding: "Geocoding"
97+
maximize: "Zoom to all features"
98+
upload: "Upload GeoJSON"
99+
modal:
100+
load: "Load"
101+
cancel: "Cancel"

lib/redmine_gtt/hooks/view_layouts_base_html_head_hook.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def view_layouts_base_body_bottom(context={})
2929
:maxzoom => Setting.plugin_redmine_gtt['default_map_maxzoom_level'],
3030
:fit_maxzoom => Setting.plugin_redmine_gtt['default_map_fit_maxzoom_level'],
3131
:geocoder => geocoder,
32-
:plugin_settings => Setting.plugin_redmine_gtt.select{ |key, value| key.to_s.match(/^(?!default).+/) }
32+
:plugin_settings => Setting.plugin_redmine_gtt.select{ |key, value| key.to_s.match(/^(?!default).+/) },
33+
:i18n => l(:gtt_js).to_json.html_safe
3334
}, :id => 'gtt-defaults', :style => 'display:none')
3435
return tags.join("\n")
3536
end

src/components/gtt-client.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export class GttClient {
7575
layerArray: Layer[]
7676
defaults: DOMStringMap
7777
contents: DOMStringMap
78+
i18n: any
7879
toolbar: Bar
7980
filters: FilterOption
8081
vector: VectorLayer<VectorSource<Geometry>>
@@ -120,8 +121,8 @@ export class GttClient {
120121
this.defaults.geocoder = JSON.stringify(quick_hack.geocoder)
121122
}
122123

123-
124124
this.contents = options.target.dataset
125+
this.i18n = JSON.parse(this.defaults.i18n)
125126

126127
// create map at first
127128
this.map = new Map({
@@ -287,8 +288,6 @@ export class GttClient {
287288
})
288289
}
289290

290-
291-
292291
// For map div focus settings
293292
if (options.target) {
294293
if (options.target.getAttribute('tabindex') == null) {
@@ -316,7 +315,7 @@ export class GttClient {
316315
// Control button
317316
const maximizeCtrl = new Button({
318317
html: '<i class="material-icons" >zoom_out_map</i>',
319-
title: "Maximize",
318+
title: this.i18n.control.maximize,
320319
handleClick: () => {
321320
this.zoomToExtent(true);
322321
}
@@ -538,7 +537,7 @@ export class GttClient {
538537

539538
editbar.addControl(new Button({
540539
html: '<i class="material-icons">file_upload</i>',
541-
title: 'Upload GeoJSON',
540+
title: this.i18n.control.geojson,
542541
handleClick: () => {
543542
dialog.dialog('open')
544543
}
@@ -1011,7 +1010,7 @@ export class GttClient {
10111010
// Control button
10121011
const geolocationCtrl = new Toggle({
10131012
html: '<i class="material-icons">my_location</i>',
1014-
title: "Geolocation",
1013+
title: this.i18n.control.geolocation,
10151014
active: false,
10161015
onToggle: (active: boolean) => {
10171016
geolocation.setTracking(active)
@@ -1200,7 +1199,7 @@ export class GttClient {
12001199
// Control button
12011200
const geocodingCtrl = new Toggle({
12021201
html: '<i class="material-icons">manage_search</i>',
1203-
title: "Geocoding",
1202+
title: this.i18n.control.geocoding,
12041203
className: "ctl-geocoding",
12051204
onToggle: (active: boolean) => {
12061205
const text = (document.querySelector("div#" + mapId + " .ctl-geocoding div input") as HTMLInputElement)

0 commit comments

Comments
 (0)