3
votes

I'm using this plugin , I want to set language as French fr, for that I use formatter: new L.Routing.Formatter(language: 'fr') like you can see the code bellow :

L.Routing.control({
  waypoints: [L.latLng(48.8534, 2.3488), L.latLng(44.837789, -0.57918)],
  routeWhileDragging: true,
  show: true,
  formatter: new L.Routing.Formatter({ units: 'metric', language: 'fr' }),
  autoRoute: true
}).addTo(this.mapInstance);

But, the result is always in English 'en'.

1

1 Answers

3
votes

Try to use this :

  • First, add localization.js to your other scripts in angular.json file, like that:
 "scripts": [
              "node_modules/leaflet-routing-machine/src/localization.js" 
            ]

  • Then, add the option language : 'fr' to your Routing control as bellow :
 L.Routing.control({
      waypoints: [
        L.latLng(57.74, 11.94),
        L.latLng(57.6792, 11.949)
      ],
      collapsible: true, // hide/show panel routing
      autoRoute: true, // possibility to take autoRoute
      language : 'fr', // < --- THIS IS ESPECIALLY WHAT YOU SHOULD ADD
      // ...
    }).addTo(this.map);