leaflet-elevation icon indicating copy to clipboard operation
leaflet-elevation copied to clipboard

Translate legend item labels (small legend switcher)

Open hupe13 opened this issue 3 years ago • 2 comments

Version 2.2.6

Hi Raruto,

I translated all strings. But I can't change this one: grafik

grafik No matter whether Altitude, Slope, Speed or Acceleration appears.

Can you please fix this? Thank you very much.

hupe13 avatar Sep 20 '22 12:09 hupe13

Hi hupe,

the problem should be near to these lines:

https://github.com/Raruto/leaflet-elevation/blob/2589a937188792eae88c9822a5627845aed2027d/src/components/d3.js#L271

https://github.com/Raruto/leaflet-elevation/blob/46918ce42f27cc438e969407ae0a85bc56801132/src/components/chart.js#L573-L581

To understand how you can make a string translatable you can take look at: yohanboniface/Leaflet.i18n

courtesy of leaflet-ui >= 0.5.4 😄

Raruto avatar Sep 20 '22 17:09 Raruto

After I found the solution, it's very simple:

label.text(items.length ? L._((items[idx][0].toUpperCase() + items[idx].slice(1))) : '');

hupe13 avatar Sep 21 '22 16:09 hupe13