Multilingual catalogue and content

1,655 views
Skip to first unread message

val...@valsor.com

unread,
Jan 4, 2013, 7:04:33 AM1/4/13
to django...@googlegroups.com
Hi all,

Browsing the code I can see that most (if not all) text messages can be translated using Django's built-in gettext. But it's me not clear how can I localize catalog data and content (pages and blocks). It seems database has no appropriate tables or fields. I read in documentation about multilingual products and categories but didn't understand how this works. What is a proper way to make products, categories, pages and content blocks localizable?

And also related question. How can I add and activate GUI languages? I see that in sandbox demo setting file two languages are defied - German and French. But how can I make them visible? How can I switch them from the GUI? 

I need to make shop fully multilingual both GUI and data. Any advice will be appreciated.

Valery Sorokin

David Winterbottom

unread,
Jan 4, 2013, 7:36:05 AM1/4/13
to django...@googlegroups.com
On 4 January 2013 12:04, <val...@valsor.com> wrote:
Hi all,

Browsing the code I can see that most (if not all) text messages can be translated using Django's built-in gettext.

If you spot any that aren't, let me know.
 
But it's me not clear how can I localize catalog data and content (pages and blocks). It seems database has no appropriate tables or fields. I read in documentation about multilingual products and categories but didn't understand how this works. What is a proper way to make products, categories, pages and content blocks localizable?

By default, Oscar doesn't support multilingual products/pages etc but it isn't that difficult to add support.  

Multilingual content is tricky in that you need to have a strategy for storing the various translations.  At Tangent, we generally use model translation (https://github.com/deschler/django-modeltranslation).  To use this, you will need to modify the core models of Oscar that you need to have stored in different languages.

Oscar's dashboard doesn't support showing alternative forms for each language but I would be interested to know how hard it would be to add support.  
 

And also related question. How can I add and activate GUI languages? I see that in sandbox demo setting file two languages are defied - German and French. But how can I make them visible? How can I switch them from the GUI? 

Those languages were defined so that I could test rosetta.  There isn't support for picking a language at the moment although I don't think it would be hard to add (I've created a ticket: https://github.com/tangentlabs/django-oscar/issues/451)

So for now, you'll need to implement your own language picker.  See this thread for a guidehttp://stackoverflow.com/questions/5489601/django-i18n-change-language

 

I need to make shop fully multilingual both GUI and data. Any advice will be appreciated.

Valery Sorokin

--
https://github.com/tangentlabs/django-oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
Visit this group at http://groups.google.com/group/django-oscar?hl=en-US.
 
 



--
David Winterbottom
Head of Programming

Tangent Labs
84-86 Great Portland Street
London W1W 7NR
England, UK

אברהם סרור

unread,
Feb 12, 2013, 1:42:03 PM2/12/13
to django...@googlegroups.com, david.win...@tangentlabs.co.uk
> By default, Oscar doesn't support multilingual products/pages etc but it isn't that difficult to add support.  

This is interesting, the page at http://django-oscar.readthedocs.org/en/latest/ says:

Example requirements that Oscar applications already handle:
...
Multi-lingual products and categories

David Winterbottom

unread,
Feb 13, 2013, 4:11:24 PM2/13/13
to django-oscar
On 12 February 2013 18:42, אברהם סרור <tov...@gmail.com> wrote:
> By default, Oscar doesn't support multilingual products/pages etc but it isn't that difficult to add support.  

This is interesting, the page at http://django-oscar.readthedocs.org/en/latest/ says:

Example requirements that Oscar applications already handle:
...
Multi-lingual products and categories

It's not a contradiction although I can see how it is slightly misleading.  Tangent has several Oscar projects that support multi-lingual products, they simply use model-translation in conjunction with Oscar.​  

 
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sergey Maranchuk

unread,
Nov 22, 2013, 11:53:23 AM11/22/13
to django...@googlegroups.com
Implement something like this for RawHtml content blocks via modeltranslation, dashboard will be display all fieldname_<lang> fields automatically

Maybe only what u what - removing  multiltranslate fields dublication (it for example field name and name_en), but this is not hard:
Example:

translation:
from modeltranslation.translator import translator, TranslationOptions
from oscar.apps.promotions.models import RawHTML


class RawHTMLTranslationOptions(TranslationOptions):
    fields = ('name', 'body',)

translator.register(RawHTML, RawHTMLTranslationOptions)

dashboard.promotion.app:
from oscar.apps.dashboard.promotions import app
from .views import CreateRawHTMLView, UpdateRawHTMLView


class PromotionsDashboardApplication(app.PromotionsDashboardApplication):
    create_rawhtml_view = CreateRawHTMLView
    update_rawhtml_view = UpdateRawHTMLView

dashboard.promotion.forms:
from django.conf import settings
from oscar.apps.dashboard.promotions.forms import RawHTMLForm as RawHTMLFormOrig
from mapstore.apps.core.translation import RawHTMLTranslationOptions

# Dynamically generate something like ['name_en', 'titile_en']
rawhtml_exclude_fields = map(lambda f: '_'.join([f, settings.MODELTRANSLATION_DEFAULT_LANGUAGE]),
                             RawHTMLTranslationOptions.fields)

class RawHTMLForm(RawHTMLFormOrig):
    class Meta(RawHTMLFormOrig.Meta):
        exclude = rawhtml_exclude_fields + list(RawHTMLFormOrig.Meta.exclude)

dashboard.promotion.views:
from oscar.apps.dashboard.promotions.views import (CreateRawHTMLView as CreateRawHTMLViewOrig,
                                                   UpdateRawHTMLView as UpdateRawHTMLViewOrig)
from .forms import RawHTMLForm

class CreateRawHTMLView(CreateRawHTMLViewOrig):
    form_class = RawHTMLForm

class UpdateRawHTMLView(UpdateRawHTMLViewOrig):
    form_class = RawHTMLForm

dashboard.app:
from oscar.apps.dashboard import app
from .promotions.app import PromotionsDashboardApplication

class DashboardApplication(app.DashboardApplication):
    promotions_app = PromotionsDashboardApplication()

application = DashboardApplication()

app.py:
from oscar.app import Shop
from .dashboard.app import application as dashboard_app

class Application(Shop):
    dashboard_app = dashboard_app

application = Application()


Reply all
Reply to author
Forward
0 new messages