geonode icon indicating copy to clipboard operation
geonode copied to clipboard

Portuguese language/translation does not show in dropdown

Open gioman opened this issue 8 months ago • 2 comments

Expected Behavior

By editing the .env file as

LANGUAGES=(('en-us','English'),('it-it','Italiano'),('es-es','Spanish'),('de-de','German'),('pt-pt','Portuguese'))

and after rebuilding the containers, the Portuguese language should show (as the others do) in the language selector

Actual Behavior

Portuguese does not show among the list of languages in Geonode GUI.

Steps to Reproduce the Problem

  1. edit .env, add portuguese LANGUAGES=(('en-us','English'),('it-it','Italiano'),('es-es','Spanish'),('de-de','German'),('pt-pt','Portuguese'))
  2. rebuild containers and start them again

Specifications

  • GeoNode version: 4.4.2
  • Installation type (vanilla, geonode-project): geonode-project
  • Installation method (manual, docker): docker
  • Platform: ubuntu 22.04
  • Additional details:

gioman avatar Apr 21 '25 09:04 gioman

Hello! This issue can be fixed with a small change — it's a mistake in geonode/settings.py (lines 1560–1566).

if os.getenv("LANGUAGES"):
    # Map given languages to MapStore-supported languages.
    LANGUAGES = tuple(
        (k, v) for k, v in dict(MAPSTORE_DEFAULT_LANGUAGES).items()
        if any(m in k for m in dict(LANGUAGES).keys())
    )
else:
    LANGUAGES = MAPSTORE_DEFAULT_LANGUAGES

The environment variable is being checked, but not actually assigned to a variable — so the code later tries to use LANGUAGES before it's been set.

Also, make sure to include Portuguese in MAPSTORE_DEFAULT_LANGUAGES.

A possible fix would be:

import ast

MAPSTORE_DEFAULT_LANGUAGES = (
        ("de-de", "Deutsch"),
        ("en-us", "English"),
        ("es-es", "Español"),
        ("fr-fr", "Français"),
        ("it-it", "Italiano"),
        ('pt-pt', 'Portuguese'),
        ('pt-br', 'Portuguese (Brazil)'),
    )

env_langs = os.getenv("LANGUAGES")
if env_langs:
    # Map given languages to MapStore-supported languages.
    env_langs_tuple = ast.literal_eval(env_langs)
    env_lang_keys = {k for k, _ in env_langs_tuple}
    LANGUAGES = tuple(
        (k, v) for k, v in MAPSTORE_DEFAULT_LANGUAGES if k in env_lang_keys
    )
else:
    LANGUAGES = MAPSTORE_DEFAULT_LANGUAGES

Don't forget to set the language variable between commas in .env:

LANGUAGES="(('en-us','English'),('it-it','Italiano'),('es-es','Spanish'),('de-de','German'),('pt-pt','Portuguese'),('pt-br', 'Portuguese (Brazil)'))"

Hope this helps!

MarlonSantos avatar May 22 '25 19:05 MarlonSantos

@MarlonSantos thanks!

gioman avatar May 23 '25 09:05 gioman