Search code examples
pythondjangosatchmowebfaction

Can't set the shop language in Satchmo


I'm trying to set the default and only shop language of a Satchmo 0.9.2 installationto Dutch.

I'm following the instructions on translating content:

From the directory /home/myusername/webapps/myshop/lib/python2.7/Satchmo-0.9.2-py2.7.egg I issued the following command to compile the Dutch langauge files:

find . -name locale -exec sh -c 'cd $0 && cd ../ && python2.7 
/home/myusername/webapps/myshop/lib/python2.7/django/bin/django-admin.py 
makemessages -l nl -e html,txt,rml' {} \;

I can now see multiple .../locale/nl/LC_MESSAGES/django.po files wich contain messagestrings translated into Dutch.

My local_settings.py file has a LOCALE_PATHS variable defined:

LOCALE_PATHS = ""

I have compiled the .po files to .mo files with:

find . -name locale -exec sh -c 'cd $0 && cd ../ && python2.7
/home/myusername/webapps/myshop/lib/python2.7/django/bin/django-admin.py 
compilemessages' {} \;

I only want text to appear in Dutch, so my local_settings.py only contains:

LANGUAGE_CODE = 'nl'
LANGUAGES = (
    ('nl', "Nederlands"),
)

Users should not be ablo to choose other translations, so allow_translation_choice is set to False in settings.py:

L10N_SETTINGS = {
  'currency_formats' : {
     'EURO' : {'symbol': u'€', 'positive' : u"€%(val)0.2f", 'negative':
u"€(%(val)0.2f)",
               'decimal' : ','},
  },
  'default_currency' : 'EURO',
  'show_admin_translations': True,
  'allow_translation_choice': False,
}

and in the same file I have enabled my i18n urls:

SATCHMO_SETTINGS = {
    'SHOP_BASE' : '',
    'MULTISHOP' : False,
    'SHOP_URLS' : patterns('', (r'^i18n/', include('l10n.urls')),)
}

To make sure that my templates use the correct language code, I also have in settings.py:

TEMPLATE_CONTEXT_PROCESSORS = (
    'satchmo_store.shop.context_processors.settings',
    'django.core.context_processors.auth',
    'django.core.context_processors.i18n',
)

After jumping through all these hoops, my shop language still shows up in English and still has the 'Change language' with an empty drop-down button in the lower right corner.

Anyone have a clue where I went wrong?

Thanks in advance.


Solution

  • I also had to setup the shop to an "almost" new language 'es' Spanish. So I'll just put in here any differences from our installation:

    In my settings I also have:

    LC_CTYPE = 'es_ES.utf8'
    TIME_ZONE = 'Europe/Madrid'
    

    'allow_translation_choice': False, <- this is strange, that worked just fine for me... is this maybe overriden in your local-settings file?

    I also changed this on settings.py

    #### Satchmo unique variables ####
    from django.conf.urls.defaults import patterns, include
    SATCHMO_SETTINGS = {
        'SHOP_BASE' : '',
        'MULTISHOP' : False,
        #'SHOP_URLS' : patterns('satchmo_store.shop.views',)
        'SHOP_URLS' :  patterns('', (r'^i18n/', include('l10n.urls')),),
        'CUSTOM_SHIPPING_MODULES': ['FLAT_SHIPPING_NORMAL',],
        #'SSL': True
    }
    

    If that all doesn't help, have you tried adding more languages, like de, en and enable the language selector to see if it changes to e.g. german? This way your can find out if it's just a problem with the dutch-translation.

    Did you translated any missing messages... I've just looked in my installation, and it already has po-files for nl. And at least the product-po looks fine. So you probably didn't need to run makemessages/compilemessages... that's only needed for "new" languages, or when you want to update the po-files (in case the source-files changed)...

    But if you need to update-translations I would recommend you to take a look to rosetta... it's great! Have sometimes some bugs with new generated translation-files (only with the headers, I had to put some of them manually, based on existing files from the django-src: "Content-Type: text/plain; charset=UTF-8\n" and "Content-Transfer-Encoding: 8bit\n") but after adding the headers to new files, it works great. And you don't have to compile the po-files yourself, as rosetta does this when you save.