Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
255 stars 85 forks source link

Translate legend item labels (small legend switcher) #213

Closed hupe13 closed 2 years ago

hupe13 commented 2 years ago

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.

Raruto commented 2 years ago

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 😄

hupe13 commented 2 years ago

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

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