1

In GeoNode you can select the language in which you want to display the portal.

Default is English, sometimes it uses automatically German, French...does this depend on the Windows language/ region where you log in?

How can I disable this function to have the portal default in English and only when the user want to switch, the user should get that option.

How/where can I set that English is the default in all cases?

  • Which version of GeoNode and OS are you using? – whyzar Nov 30 '16 at 17:23
1

You can read more at the GeoNode documentation

So yes English is the default language for GeoNode, it is only different if it has been changed by the user not depending on location or other factors.

GeoNode’s default language is English, but GeoNode users can change the interface language with the pulldown menu at the top-right of most GeoNode pages. Once a user selects a language GeoNode remembers that language for subsequent pages.

Unless as mentioned here by GeoNode:

Unfortunately Django overrides this setting, giving the language setting of a user’s browser priority. For example, if LANGUAGE_CODE is set to French, but the user has configured their operating system for Spanish they may see the Spanish version when they first visit GeoNode.

GeoNode provides a list of languages that can be selected,

A list of language codes can be found in the global django config file /usr/local/lib/python2.7/dist-packages/django/conf/global_settings.py (or /var/lib/geonode/lib/python2.7/site-packages/django/conf/global_settings.py if GeoNode has been installed using apt-get).

For example, to make French the default language use:

LANGUAGE_CODE = 'fr'

Now if you would like the user's browser not to change languages and keep the default as desired (in this case English) GeoNode provides the following:

Additional Steps

If this is not the desired behaviour, and all users should initially see the default LANGUAGE_CODE, regardless of their browser’s settings, do the following steps to ensure Django ignores the browser language settings. (Users can always use the pulldown language menu to change the language at any time.)

As root create a new directory within GeoNode’s site packages:

mkdir /usr/lib/python2.7/dist-packages/setmydefaultlanguage or:: mkdir /var/lib/geonode/lib/python2.7/site-packages/setmydefaultlanguage if GeoNode has been installed using apt-get.

As root create and edit a new file /usr/lib/python2.7/dist-packages/setmydefaultlanguage/init.py and add the following lines:

class ForceDefaultLanguageMiddleware(object): """ Ignore Accept-Language HTTP headers

This will force the I18N machinery to always choose settings.LANGUAGE_CODE
as the default initial language, unless another one is set via sessions or cookies

Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'],
namely django.middleware.locale.LocaleMiddleware
"""
def process_request(self, request):
    if request.META.has_key('HTTP_ACCEPT_LANGUAGE'):
        del request.META['HTTP_ACCEPT_LANGUAGE']

At the end of the GeoNode configuration file /home/geonode/geonode/geonode/settings.py (or /etc/geonode/settings.py if GeoNode has been installed using apt-get) add the following lines to ensure the above class is executed:

MIDDLEWARE_CLASSES += ( 'setmydefaultlanguage.ForceDefaultLanguageMiddleware', )

Restart Finally restart Apache as root with:

service apache2 restart

Again, You can read more at the GeoNode documentation starting at additional steps

  • that is exactly the problem with the browser priority. I want that the user see only the english version, everytime the user visit the portal. For sure, the user should have the opportuinity to change the language but manually and not by browser or system. Is there any way to avoid this browser/system automatically changing of the language? – blackgis Dec 1 '16 at 9:43
  • Yes there is a way to avoid the browser from automatically changing the language. I've updated my answer, you can start at "Additional steps" – whyzar Dec 1 '16 at 12:41
  • Thank you, thats exactly what I am looking for. Unfortunatelly it throw an 500 error when applying. I have copypasted to avoid typos. Any ideas which component could cause this 500 error? – blackgis Dec 2 '16 at 12:47
  • I would suggest posting a different question in regards to the 500 error. As this question is answered. We could follow-up there. – whyzar Dec 2 '16 at 12:49

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.