leaflet-routing-machine icon indicating copy to clipboard operation
leaflet-routing-machine copied to clipboard

Language support

Open RuthLanguismedia opened this issue 7 years ago • 12 comments

Hi, first thanks a lot for your work! But please let me make a suggestion: The file leaflet-routing-machine.js (leaflet-routing-machine.min.js) is getting quite big in the meanwhile and therefore takes longer to download it when implementing it in your own projects. At the same time there are very "exotic" languages in this file which maybe you never need in your personal project. So would it be better to provide these languages in seperate files so the developer can add those languages he actually wants/needs to have in his own project?

Best regards Ruth

RuthLanguismedia avatar Nov 20 '17 14:11 RuthLanguismedia

Hi Ruth, thanks for you suggestion and also great to hear you're finding Leaflet Routing Machine useful.

In theory, I think your suggestion is sound, but as it is now, these translations are incorporated from the osrm-text-instructions package, which is included in the pre-built bundle. I don't think it's possible for me to break out the actual languages from it, but I should say I haven't looked closely.

Also, at the moment I have very limited amount of time to spend on Leaflet Routing Machine, so it's not likely I will have time to do anything like this at this time. Help is of course welcome, as long as we can agree on a way to do this that doesn't cause trouble for other users.

perliedman avatar Nov 21 '17 14:11 perliedman

Hi Per,

thanks very much for your response.

I know the time..

But I am not sure whether my help is of use…, I am just happy that I got through your code to make minor adjustments there. So I deleted those “exotic” languages as well.

Again thanks a lot for your work!

Ruth

Von: Per Liedman [mailto:[email protected]] Gesendet: Dienstag, 21. November 2017 15:50 An: perliedman/leaflet-routing-machine [email protected] Cc: RuthLanguismedia [email protected]; Author [email protected] Betreff: Re: [perliedman/leaflet-routing-machine] Language support (#446)

Hi Ruth, thanks for you suggestion and also great to hear you're finding Leaflet Routing Machine useful.

In theory, I think your suggestion is sound, but as it is now, these translations are incorporated from the osrm-text-instructions package, which is included in the pre-built bundle. I don't think it's possible for me to break out the actual languages from it, but I should say I haven't looked closely.

Also, at the moment I have very limited amount of time to spend on Leaflet Routing Machine, so it's not likely I will have time to do anything like this at this time. Help is of course welcome, as long as we can agree on a way to do this that doesn't cause trouble for other users.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/perliedman/leaflet-routing-machine/issues/446#issuecomment-346049439 , or mute the thread https://github.com/notifications/unsubscribe-auth/AgRJWM9WauMGJAX3tUq13LHkmi54V9Gcks5s4uMcgaJpZM4QkTgh . https://github.com/notifications/beacon/AgRJWLk8hdfNwzCCsaTLYjKYuxcUMectks5s4uMcgaJpZM4QkTgh.gif

RuthLanguismedia avatar Nov 24 '17 08:11 RuthLanguismedia

Hi Per, Any way to add português to the languages? The translation I can do. Thank you Thomas

ragapack avatar Nov 28 '17 07:11 ragapack

@ragapack you should check osrm-text-instructions, which we use for the instruction texts, I don't know if they support Portuguese yet. There are a few strings that are specific to Leaflet Routing Machine as well, but I think they are already translated (since pt is Portuguese, right?): https://github.com/perliedman/leaflet-routing-machine/blob/master/src/localization.js#L441

perliedman avatar Nov 28 '17 09:11 perliedman

@ragapack osrm-text-instructions has a pt-BR localization but no plain pt, like it does with spanish es/es-ES. Either use pt-BR as the name of the locale or even use it as a template for your translation, or use this branch which includes a workaround to make Portugese work with the generic pt locale.

ggl avatar Dec 12 '17 10:12 ggl

@perliedman , @ggl I need Brazilian Portuguese so pt-BR is OK for me. Now I have tried it out, works fine with all languages except pt-BR and es-ES If I set: language: 'es', It Works perfect with the Spanish language. language: 'es-ES', Does not work language: 'pt-BR', Does not work I think there is any problem with the size of the language key. In the leaflet-routing-machine.min.js file I found anything correct. I am using the sample code from the tutorial.

<script>

        var map = L.map('map');
        mapLink = 
            '<a href="http://openstreetmap.org">OpenStreetMap</a>';
        L.tileLayer(
            'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '&copy; ' + mapLink + ' Contributors',
            maxZoom: 18,
            }).addTo(map);

L.Routing.control({
    waypoints: [
        L.latLng(57.74, 11.94),
        L.latLng(57.6792, 11.949)
    ],
 language: 'pt-BR',
    routeWhileDragging: true
}).addTo(map);
    </script>

ragapack avatar Dec 29 '17 11:12 ragapack

I too fervently hope for another source code version that contains only the English language. Upon inspecting the current code, I dare not try removing the other languages due to my novice familiarity in JavaScript..

JAT86 avatar Jan 28 '18 11:01 JAT86

I changed the code from pt-BR to only pt and now the português version Works. The 2 files are attached to this zip file. lrm.zip

ragapack avatar Jan 28 '18 14:01 ragapack

very good guys! Thanks!

italocassio avatar Jan 30 '18 17:01 italocassio

very good guys! Thanks!

I am using 'pt' with version 3.1.12 but the instructions continue on 'en'.

var control = L.Routing.control(L.extend(window.lrmConfig,{

	language: 'pt',
	formatter: new L.Routing.Formatter({
		language: 'pt'
	}),

	geocoder: L.Control.Geocoder.nominatim(),                
	routeWhileDragging: true,                
	reverseWaypoints: true,
	altLineOptions: {
		styles: [
			{ color: 'black', opacity: 0.15, weight: 9 },
			{ color: 'white', opacity: 0.8, weight: 6 },
			{ color: 'blue', opacity: 0.5, weight: 2 }
		]
	},
	router: L.Routing.osrmv1({
		serviceUrl: 'http://192.168.0.78:5000/route/v1'
	})
})).addTo(map);

Can anyone help? Thanks.

phoenixproject avatar Jul 09 '19 19:07 phoenixproject

Hi @phoenixproject, you should add the language option in the Routing object, like this.

var control = L.Routing.control({
....
     , router: L.Routing.osrmv1({
          serviceUrl: getUrlServidorDeRotas()
         ,language: 'pt'
     })
....
}).addTo(mymap);

matheuslrsouza avatar Jan 21 '20 00:01 matheuslrsouza

Pelase translate 'Indonesia'

deden10 avatar Mar 21 '21 02:03 deden10