无法在 Satchmo 设置商店语言

发布于 2024-10-20 08:32:12 字数 2080 浏览 6 评论 0原文

我正在尝试将 Satchmo 0.9.2 安装的默认且唯一的商店语言设置为荷兰语。

我正在按照翻译内容上的说明进行操作:

来自目录 / home/myusername/webapps/myshop/lib/python2.7/Satchmo-0.9.2-py2.7.egg 我发出以下命令来编译荷兰语语言文件:

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' {} \;

我现在可以看到多个 。 ../locale/nl/LC_MESSAGES/django.po 文件包含翻译成荷兰语的消息字符串。

我的 local_settings.py 文件定义了 LOCALE_PATHS 变量:

LOCALE_PATHS = ""

我已将 .po 文件编译为 .mo 文件其中:

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

我只希望文本以荷兰语显示,因此我的 local_settings.py 仅包含:

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

用户不应该选择其他翻译,因此 allow_translation_choice 设置为 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,
}

在同一个文件中,我启用了 i18n url:

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

为了确保我的模板使用正确的语言代码,我还在 settings 中启用了.py

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

在经历了所有这些麻烦之后,我的商店语言仍然显示为英语,并且右下角仍然有“更改语言”和一个空的下拉按钮。

有人知道我哪里出错了吗?

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

澜川若宁 2024-10-27 08:32:12

我还必须将商店设置为“几乎”新的语言“es”西班牙语。因此,我将在这里添加与我们的安装的任何差异:

在我的设置中,我还有:

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

'allow_translation_choice': False, <- 这很奇怪,对我来说效果很好......这可能会在您的本地设置文件中被覆盖吗?

我还在 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
}

如果这一切都没有帮助,您是否尝试添加更多语言,例如 de、en 并启用语言选择器以查看它是否更改为德语?这样您就可以确定这是否只是荷兰语翻译的问题。

你翻译了任何丢失的消息吗...我刚刚查看了我的安装,它已经有 nl 的 po 文件。至少产品看起来不错。因此,您可能不需要运行 makemessages/compilemessages...这仅适用于“新”语言,或者当您想要更新 po 文件时(以防源文件更改)...

但是如果您需要要更新翻译,我建议您看看罗塞塔......它太棒了!有时,新生成的翻译文件会出现一些错误(仅限标头,我必须根据 django-src 中的现有文件手动放置其中一些:"Content-Type: text/plain; charset=UTF -8\n" 和 "Content-Transfer-Encoding: 8bit\n"),但将标头添加到新文件后,效果很好。而且您不必自己编译 po 文件,因为 Rosetta 在您保存时会这样做。

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.

薄暮涼年 2024-10-27 08:32:12

启用切换语言的唯一必要步骤是:

1) 在 local_settings.py 中更改语言:

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

2) 通过将以下行添加到 settings.py 中的字典 SATCHMO_SETTINGS 来启用切换:

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

在网页上选择您的语言。

注:

我现在已经验证了之前的新安装的旧 Satchmo 在您报告之日是否有效。 (最后一次更改是在 2011 年 2 月末)

可以肯定的是,以后在 settings.py 或 local_settings.py 中没有将先前的值设置为不同的值。

我不确定 LANGUAGE_CODE 是否符合大多数人的预期。仅当用户未手动选择任何语言并且站点未启用用户浏览器首选语言时才使用它。因此我通常禁用英语。

如果您要向 Satchmo 添加新语言,请验证它是否位于 django/conf/locale 中。 (有超过 50 种语言)否则使用 FORMAT_MODULE_PATH 并阅读有关它的 Django 文档。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文