4

I just tested the measure tool in the leaflet output of the latest version of qgis2web plugin (2.28.0, QGIS 2.14.5LTR):

enter image description here

I've been trying to find a way to translate it to german and found that the /qgis2web/js/leaflet-measure.js contains a broad variety of languages, somewhere from line 6360... like

...
},{}],28:[function(require,module,exports){
// de.js
// German i18n translations

module.exports = {
  'measure': 'Messung',
  'measureDistancesAndAreas': 'Messung von Abständen und Flächen',
  'createNewMeasurement': 'Eine neue Messung durchführen',
  'startCreating': 'Führen Sie die Messung durch, indem Sie der Karte Punkte hinzufügen.',
  'finishMeasurement': 'Messung beenden',
  'lastPoint': 'Letzter Punkt',
...

way below (line 7048), I find some requirements, that might indicate that something is missing under /qgis2web/i18n/:

...
var i18n = new (require('i18n-2'))({
  devMode: false,
  locales: {
    'ca': require('./i18n/ca'),
    'cn': require('./i18n/cn'),
    'da': require('./i18n/da'),
    'de': require('./i18n/de'),
...

My last javascript experience is long ago, but are there some changes in the code that apply for a translation to german?

4

Open the exported file index.html in a text editor. and find the following code:

var measureControl = new L.Control.Measure({
    primaryLengthUnit: 'meters',
    secondaryLengthUnit: 'kilometers',
    primaryAreaUnit: 'sqmeters',
    secondaryAreaUnit: 'hectares'
});

Add another option as follows:

var measureControl = new L.Control.Measure({
    primaryLengthUnit: 'meters',
    secondaryLengthUnit: 'kilometers',
    primaryAreaUnit: 'sqmeters',
    secondaryAreaUnit: 'hectares',
    localization: 'de'
});

The supported languages are:

en (default), ca, cn, da, de, de_CH, en_UK, es, fa, fil_PH, fr, it, nl, pl, pt_BR, pt_PT, ru, sv, and tr

The underlying plugin is https://github.com/ljagis/leaflet-measure, which is where I got this info from (I've tested to confirm it works).

  • hey, great! should more often have a look at github... Isn't this worth a little dropdown with all the languages in the next version of qgis2web to make localization easier for people like me? – Jochen Schwarze Oct 11 '17 at 13:38
  • Even better, perhaps I could detect the local language of QGIS, and insert the tag accordingly. – Tom Chadwin Oct 11 '17 at 14:31
  • I know that I should avoid +1, but: +1 – Jochen Schwarze Oct 11 '17 at 14:35
  • 1
    But what if I have a german QGIS and want a chinese leaflet map? ;-) – Jochen Schwarze Oct 11 '17 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.