geonode icon indicating copy to clipboard operation
geonode copied to clipboard

LANGUAGE example is not valid and results in broken home page

Open gannebamm opened this issue 2 years ago • 2 comments

Expected Behavior

Using a list of languages in settings.py / .env will limit the frontend language choices

https://github.com/GeoNode/geonode/blob/master/.env#L17

Actual Behavior

If these values are used:

LANGUAGES=(('en','English'),('de','German'))

The language fetch will fail and results in a broken UI. The fetch will try to get:

http://localhost/static/mapstore/gn-translations/data.de.json?v=4c486ba53191710186e90e7a9ee1d40c2b6e228b // http://localhost/static/mapstore/gn-translations/data.en.json?v=4c486ba53191710186e90e7a9ee1d40c2b6e228b

which both are not present and result in a 404.

Steps to Reproduce the Problem

  1. start geonode with LANGUAGES like shown in .env as an example
  2. open the homepage
  3. take a look at the network tab

Specifications

  • GeoNode version: 4.x
  • Installation method (manual, GeoNode Docker, SPCGeoNode Docker): Docker
  • Platform:
  • Additional details:

gannebamm avatar Aug 23 '22 16:08 gannebamm

The files available in mapstore support sub-languages, hence the 404.We either need to add support for the given formmart or change the example to ('en-us','English'),('pt-pt','Portuguese')

marthamareal avatar Aug 26 '22 12:08 marthamareal

@allyoucanmap I thought we already supported this, but apparently, it doesn't.

Here I expected MapStore to map the languages to the sub-language filename. I know MapStore only supports a few languages, compared to GeoNode, but it should try with the correct path (e.g. de -> de-de).

What do you think?

giohappy avatar Aug 30 '22 09:08 giohappy

@giohappy mapstore is building the path for json files with this logic data.${locale}.json see the available json files here.

I think you can try with MAPSTORE_DEFAULT_LANGUAGES=(('en-US','English'),('de-De','German'))

allyoucanmap avatar Sep 26 '22 10:09 allyoucanmap

@allyoucanmap the point is that languages in GeoNode do not require the sublanguage, which is required by MapStore instead.

If a LANGUAGE (without the subllanguage) is set, it overrides MAPSTORE_DEFAULT_LANGUAGES.

To avoid having to rewrite documentations and several places in GeoNode code, I was considering to implement a "compatibility" layer, where we automatically map languages the form accepted by MapStore.

Given the current supported MapStore languages this basically means the following mapping:

('de', 'Deutsch') -> ('de-de', 'Deutsch')
('en', 'English') -> ('en-us', 'English')
('es', 'Español') -> ('es-es', 'Español')
('fr', 'Français') -> ('fr-fr', 'Français')
('it', 'Italiano') -> ('it-it', 'Italiano')

A straightforward solution is to put this mapping in this area of the settings

giohappy avatar Sep 26 '22 11:09 giohappy

This solution works well for Geonode 4:

Editing .env for LANGUAGE_CODE=pt LANGUAGES=(('pt-pt','Portuguese'),('en-us','English'),('fr-fr', 'Francais'))

Fifoterra avatar Oct 19 '22 08:10 Fifoterra

The examples must be fixed in:

  • GeoNode: https://github.com/GeoNode/geonode/blob/master/.env#L17
  • GeoNode Project: https://github.com/GeoNode/geonode-project/blob/master/.env.sample#L17

To make it more robust a mapping should be added below this line as suggested in https://github.com/GeoNode/geonode/issues/9879#issuecomment-1257871713

giohappy avatar Feb 23 '23 10:02 giohappy