6

I want to make a simple outline map on QGIS with basic city names. I downloaded the map from Nature maps but the city names keep appearing in greek, even though I changed the locale and application language.

What should I do to make the names appear in english?

enter image description here

6

You would need to change the column used for labeling. The NaturalEarth dataset contains the NAME column, with the town name in its original language, as well as several translations. You might be displaying name_el. If you want to always show the name in English, select name_en.

Let's note that it is purely a la labeling aspect, so it is unrelated to the application language or your locale.

  • I wouldn't totaly agree that this is purely a labeling aspect and not related to user locale settings, since locale settings can be uses to automatically determine column used for labeling, cp. answer below. – Jochen Schwarze Aug 3 '18 at 7:07
  • @JochenSchwarze Until you write/use custom code tailored to a specific dataset, the two concepts are indeed unrelated. (nice function by the way) – JGH Aug 3 '18 at 11:52
1

In QGIS 3 under Project|Project Properties|Variables you find a Global called qgis_locale wich you can use to automatically determine the column used for labeling. Use the following expression for this:

eval('"name_' || @qgis_locale || '"')

The @ references a variable, the string concatenation "name_' || @qgis_locale || '" will give you the column (here: "name_el") and eval() does evaluate the column name to its value.

Since in QGIS 2 there is no such variable, so one might define a custom function to get the first two letters of the user locale (en, de) and use this for the expression that automatically selects the column to get labels from:

"""
Define new functions using @qgsfunction. feature and parent must always be the
last args. Use args=-1 to pass a list of values as arguments
"""

from qgis.core import *
from qgis.gui import *
from PyQt4.QtCore import QSettings

@qgsfunction(args='auto', group='Locale')
def getLocale(feature, parent):
    return QSettings().value("locale/userLocale")[0:2]

enter image description here

The expression then changes to

eval('"name_' || getLocale() || '"')

enter image description here

With this the language of the labels in the map should directly depend on the users locale settings.

  • For your information, there is a global variable called 'qgis_locale'. So no need for the python function. – etrimaille Aug 1 '18 at 12:19
  • you are right for QGIS 3, but @qgis_locale does not exists in QGIS 2, so in QGIS 2 I think you can't get around the python function. But thanks for this hint, I'll update my answer accordingly. – Jochen Schwarze Aug 1 '18 at 13:32
0

I had a similar problem importing Natural Earth Quick Starter Kit using QGIS version 3, all my labels were in Russian (Cyrillic). Similarly, Wikipedia Maps Tile Server displayed country labels in each country's language, i.e. "Thailand" was labeled in Thai characters, "Japan" was labeled with Kanji, etc.


Here's how I fixed it:

  1. Open QGIS (version 3), Click Project in the upper-left corner of your workspace.
  2. Select Properties
  3. Click Variables in the column on the left of the Project Properties viewport.
  4. Find project_language variable.
  5. Replace the value name_el with the new value name_en
  6. Click Apply
  7. Click OK
  8. Restart QGIS
  9. (Re)Open the file: Natural_Earth_quick_start_for_QGIS_v3.qgs
  10. Labels in English.



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.