Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes it possible to translate Leaflet.draw #87

Merged
merged 2 commits into from
May 21, 2013

Conversation

Starefossen
Copy link
Contributor

All localization specific strings has been refactored out of the core and into a /locales/Leaflet.draw.en.js file which is then referenced throughout the project.

This makes it possible to translate Leaflet.draw into other languages.

@yohanboniface
Copy link
Member

FYI, here is a proposal to add a simple i18n system centralized in Leaflet and make all the plugins share the same rules: Leaflet/Leaflet#1232

@Starefossen
Copy link
Contributor Author

Very interesting. I'll have a look and see if I can make this pull compliant with your suggestion :-)

@jacobtoye jacobtoye mentioned this pull request Apr 23, 2013
@Starefossen
Copy link
Contributor Author

@jacobtoye bump!

@oleksii-leonov
Copy link

Thanks!

It would be great to make function to switch locales, like L.drawLocal.setLocale("en").
And make localisation files this way:

// Leaflet.draw.en.js
L.drawLocal.en = {
  draw: {
    toolbar: {
      polyline: 'Draw a polyline',
      polygon: 'Draw a polygon',
      ...

// Leaflet.draw.ru.js
L.drawLocal.ru = {
  draw: {
    toolbar: {
      polyline: 'Добавить линию',
      polygon: 'Добавить полигон',
      ...

So, it would be possible to include all localisation files from folder and than just set locale with function.

@oleksii-leonov
Copy link

I think very important for current users of Leaflet.draw (they mostly don't use localisation) is ability to make simple update without necessity to add any localisation files.

Maybe solution is to set default locale to "en" and include "en" localisation strings directly in leaflet.draw.js.
So, current users could just replace their leaflet.draw.js with updated version without any drawbacks. And users which want localisation feature could just add localisation files and switch locale.

@Starefossen
Copy link
Contributor Author

@aleksejleonov don't get me wrong but the reason they don't use translation is that there is no translation atm.

What I am pretty sure about is that most users won't compile their own leaflet.draw.js from source, meaning that we need to provide users an easy mean to include their own translation. The simplest way is to have one namespace that they can override if they like. Either by including their own translation file or by simply setting the variables, one by one, L.drawLocal.draw.simpleshape.tooltip.end = 'End this thing'. This is favorable because it won't break when new locals are introduced.

I'm thinking about rewriting this pull to the suggested model by @mourner in [https://github.com/Leaflet/Leaflet/pull/1232](this thread).

@yohanboniface
Copy link
Member

FYI, work in progress: https://github.com/yohanboniface/Leaflet.i18n

@jacobtoye
Copy link
Member

Finally found the time to look into this pull guys. Sorry :( It should be "good enough" until (if ever) leaflet decides to support localization officially.

jacobtoye added a commit that referenced this pull request May 21, 2013
Makes it possible to translate Leaflet.draw
@jacobtoye jacobtoye merged commit ea19da9 into Leaflet:master May 21, 2013
@Starefossen Starefossen deleted the translation-wip branch May 21, 2013 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants