Hiding non-translated pages

11 views
Skip to first unread message

kfomichev

unread,
Mar 1, 2010, 9:43:34 AM3/1/10
to django-multilingual
Hi!
I'm using dj.multilingual to translate my flatpages. To switch
language I use localeurl and a switch link (in the site base
template). The problem is, I don't want ALL of my flatpages to be
translated, only the most significant. But when I'm reading a page
(that has no translation) in default language and try to switch
language, the loaded page shows "none" (because the tranclationis
absent). I'd like to avoid this by one of two means:
- when trying to switch language of a page without translation an
automatic regirection could be done to some common page (maybe home
page in that language)
or
- hiding the language switch link on the page that has no translation.
I'd prefer the first, but the second would also do.
I suppose it's quite easy, but I'm a complete newbie in django so
can't figure out how to do this.
Thanks for help.

Panos Laganakos

unread,
Mar 1, 2010, 11:45:59 AM3/1/10
to django-mu...@googlegroups.com
Hey mate.

localeurl provides an `LOCALE_INDEPENDENT_PATHS` which is a tuple of
regexes, so you can include paths you want to remain, well local
independent :)

A more interesting alternative is multilingual's
`MULTILINGUAL_FALLBACK_LANGUAGES`, where you define a list of the
languages you in order of precedence.

i.e. I usually have this set for my clients:

MULTILINGUAL_FALLBACK_LANGUAGES = ['en', 'el']

> --
> You received this message because you are subscribed to the Google Groups "django-multilingual" group.
> To post to this group, send email to django-mu...@googlegroups.com.
> To unsubscribe from this group, send email to django-multilin...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-multilingual?hl=en.
>
>

--
Panos Laganakos

kfomichev

unread,
Mar 4, 2010, 9:37:08 AM3/4/10
to django-multilingual

> localeurl provides an `LOCALE_INDEPENDENT_PATHS` which is a tuple of
> regexes, so you can include paths you want to remain, well local
> independent :)
Haven't tried it yet. Will it automatically hide my language switch
link on pages that match the regexes?
Anyway it doesn't seem to be good solution because I'll have to edit
settings file each time after a non-translated flatpagepage is added
to site.

> A more interesting alternative is multilingual's
> `MULTILINGUAL_FALLBACK_LANGUAGES`, where you define a list of the
> languages you in order of precedence.
>
> i.e. I usually have this set for my clients:
>
> MULTILINGUAL_FALLBACK_LANGUAGES = ['en', 'el']

my local language (primary site langage) is Russian.
In the settings.py i have following language parameters:

LANGUAGES = (
('ru', 'ru'),
('en', 'en'),
)
DEFAULT_LANGUAGE = 0

I have added to my site settings.py MULTILINGUAL_FALLBACK_LANGUAGES =
['ru']
Is the syntax correct?
Doesn't seem to change anything... Still getting "None" when trying to
view a flatpage with missing translation.
How exactly is it supposed to work? (haven't found description in any
docs).


>
>
>
>
> On Mon, Mar 1, 2010 at 4:43 PM, kfomichev <kfomic...@yandex.ru> wrote:
> > Hi!
> > I'm using dj.multilingual to translate my flatpages. To switch
> > language I use localeurl and a switch link (in the site base
> > template). The problem is, I don't want ALL of my flatpages to be
> > translated, only the most significant. But when I'm reading a page
> > (that has no translation) in default language and try to switch
> > language, the loaded page  shows "none" (because the tranclationis
> > absent). I'd like to avoid this by one of two means:
> > - when trying to switch language of a page without translation an
> > automatic regirection could be done to some common page (maybe home
> > page in that language)
> > or
> > - hiding the language switch link on the page that has no translation.
> > I'd prefer the first, but the second would also do.
> > I suppose it's quite easy, but I'm a complete newbie in django so
> > can't figure out how to do this.
> > Thanks for help.
>
> > --
> > You received this message because you are subscribed to the Google Groups "django-multilingual" group.
> > To post to this group, send email to django-mu...@googlegroups.com.
> > To unsubscribe from this group, send email to django-multilin...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/django-multilingual?hl=en.
>
> --

> Panos Laganakos- Скрыть цитируемый текст -
>
> - Показать цитируемый текст -

Madhu

unread,
Jun 7, 2012, 1:22:24 AM6/7/12
to django-mu...@googlegroups.com
Hi!
Can please you tell me, how you done done the switching into different languages
in multilingual flatpages?
I am also working in Multilingaul flatpages.

Thanks


kfomichev

unread,
Jun 9, 2012, 4:45:28 AM6/9/12
to django-multilingual
I solved it in a not very graceful manner.
I edited the file templates/flatpages/default.html
I added a JavaScript condition, that checks, if page title is 'None'
and makes browser to redirect to default page.

{% block content %}<script language="JavaScript">if
("{{ flatpage.title }}"=="None") location.replace("/en/
about_company/");</script><h1 id="ft">{{ flatpage.title }}</
h1>{{ flatpage.html }}
If a page translation is absent, the page title is 'None', so django
will generate HTML with condition
if ("None"=="None") whitch evaluates to true and lets browser go to
default location.

I wish I could solve this better...
Reply all
Reply to author
Forward
0 new messages