Can't set the shop language in Satchmo

603 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

The only necessary steps to enable switching languages are:

1) Change languages in local_settings.py:

LANGUAGE_CODE = 'nl'      # not as important as would expected
LANGUAGES = (
    ('nl', "Nederlands"), # languages supported by you 
)

2) Enable switching by adding the following line to the dictionary SATCHMO_SETTINGS in settings.py:

    'SHOP_URLS' : patterns('', (r'^i18n/', include('l10n.urls')),),

Select your language on the web page.

Notes:

I have verified now the previous with new installed old Satchmo valid at the date of your report. (last change at end of Februar 2011)

For sure look that no previous value is set later to a different value in settings.py or local_settings.py.

I am not sure that LANGUAGE_CODE does what is expected by most people. It is used only if user did not selected any language manually and the language preferred by user's browser is not enabled by site. Therefore I usually disable English.

If you are adding a new language to Satchmo, verify that it is in django/conf/locale. (there are more than 50 languages) Otherwise use FORMAT_MODULE_PATH and read Django documentation about it.