Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 June 16, 2010 21:00:44

Aaron L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


Hi guys,

Inhttp://www.djangobook.com/en/2.0/chapter19, there is a paragraph

Translation works on variables. Again, here’s an identical example:

def my_view(request):
sentence = 'Welcome to my site.'
output = _(sentence)
return HttpResponse(output)

(The caveat with using variables or computed values, as in the previous two
examples, is that Django’s translation-string-detecting utility,
django-admin.py makemessages, won’t be able to find these strings. More on
makemessages later.)
It's a bit confusing, one one hand it says Translation works on variables,
on the other hand, it says makemessages won't be able to find these strings.

Which one is right? The makemessages section didn't mention how to "fix"
this problem neither.

Any ideas?
-Aaron

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 16, 2010 21:35:59

Baurzhan I.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


On Wed, Jun 16, 2010 at 01:00:36PM -0700, Aaron Lee wrote:
> def my_view(request):
> sentence = 'Welcome to my site.'
> output = _(sentence)
> return HttpResponse(output)
>
> (The caveat with using variables or computed values, as in the previous two
> examples, is that Django’s translation-string-detecting utility,
> django-admin.py makemessages, won’t be able to find these strings. More on
> makemessages later.)
> It's a bit confusing, one one hand it says Translation works on variables,
> on the other hand, it says makemessages won't be able to find these strings.

Yes, it will work if you happen to have a translation, and yes, it
doesn't say how to identify such strings for translation, because the
value of the variable may not be known at the time makemessages is run
(neither is it straightforward in cases where it could in theory be
calculated).

What kind of problem are you trying to solve?

With kind regards,
--
Baurzhan Ismagulovhttp://www.kz-easy.com/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 16, 2010 22:09:08

A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


Well what happened was I have a forms.py

which has

CONSTANT = _("Hello World")
x = {'var': CONSTANT }

and in the django.po, I do have a translation

msgid "Hello World"
msgstr "xxx"

But it doesn't show up on the website, all the other translations
work, so I am wondering what am I missing

-Aaron


On Jun 16, 1:35 pm, Baurzhan Ismagulov <i...@radix50.net> wrote:
> On Wed, Jun 16, 2010 at 01:00:36PM -0700, Aaron Lee wrote:
> > def my_view(request):
> >     sentence = 'Welcome to my site.'
> >     output = _(sentence)
> >     return HttpResponse(output)
>
> > (The caveat with using variables or computed values, as in the previous two
> > examples, is that Django’s translation-string-detecting utility,
> > django-admin.py makemessages, won’t be able to find these strings. More on
> > makemessages later.)
> > It's a bit confusing, one one hand it says Translation works on variables,
> > on the other hand, it says makemessages won't be able to find these strings.
>
> Yes, it will work if you happen to have a translation, and yes, it
> doesn't say how to identify such strings for translation, because the
> value of the variable may not be known at the time makemessages is run
> (neither is it straightforward in cases where it could in theory be
> calculated).
>
> What kind of problem are you trying to solve?
>
> With kind regards,
> --
> Baurzhan Ismagulovhttp://www.kz-easy.com/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 June 16, 2010 22:59:26

Antoni A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


Try to use lazy translation.

El 16/06/2010 23:09, "Aaron" <waifun...@gmail.com> escribió:

Well what happened was I have a forms.py

which has

CONSTANT = _("Hello World")
x = {'var': CONSTANT }

and in the django.po, I do have a translation

msgid "Hello World"
msgstr "xxx"

But it doesn't show up on the website, all the other translations
work, so I am wondering what am I missing

-Aaron



On Jun 16, 1:35 pm, Baurzhan Ismagulov <i...@radix50.net> wrote:
> On Wed, Jun 16, 2010 at 01:00:3...
> Baurzhan Ismagulovhttp://www.kz-easy.com/--
You received this message because you are subscribed to the Google Groups
"Django users" group....

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 June 17, 2010 00:48:07

Aaron L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


Thanks, the lazy translation solves the problem.

-Aaron

On Wed, Jun 16, 2010 at 2:59 PM, Antoni Aloy <antoni.a...@gmail.com> wrote:

> Try to use lazy translation.
>
> El 16/06/2010 23:09, "Aaron" <waifun...@gmail.com> escribió:
>
>
> Well what happened was I have a forms.py
>
> which has
>
> CONSTANT = _("Hello World")
> x = {'var': CONSTANT }
>
> and in the django.po, I do have a translation
>
> msgid "Hello World"
> msgstr "xxx"
>
> But it doesn't show up on the website, all the other translations
> work, so I am wondering what am I missing
>
> -Aaron
>
>
>
> On Jun 16, 1:35 pm, Baurzhan Ismagulov <i...@radix50.net> wrote:
> > On Wed, Jun 16, 2010 at 01:00:3...
> > Baurzhan Ismagulovhttp://www.kz-easy.com/>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group....
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 June 17, 2010 00:50:19

Aaron L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

i18n variable string translation


Another problem I am facing is it seems some pages are not being translated
until I hit certain page, after that everything is fine. I am not exactly
sure what the problem is but if you guys experience this problem, would
appreciate some insights.

-Aaron

On Wed, Jun 16, 2010 at 4:47 PM, Aaron Lee <waifun...@gmail.com> wrote:

> Thanks, the lazy translation solves the problem.
>
> -Aaron
>
>
> On Wed, Jun 16, 2010 at 2:59 PM, Antoni Aloy <antoni.a...@gmail.com>wrote:
>
>> Try to use lazy translation.
>>
>> El 16/06/2010 23:09, "Aaron" <waifun...@gmail.com> escribió:
>>
>>
>> Well what happened was I have a forms.py
>>
>> which has
>>
>> CONSTANT = _("Hello World")
>> x = {'var': CONSTANT }
>>
>> and in the django.po, I do have a translation
>>
>> msgid "Hello World"
>> msgstr "xxx"
>>
>> But it doesn't show up on the website, all the other translations
>> work, so I am wondering what am I missing
>>
>> -Aaron
>>
>>
>>
>> On Jun 16, 1:35 pm, Baurzhan Ismagulov <i...@radix50.net> wrote:
>> > On Wed, Jun 16, 2010 at 01:00:3...
>> > Baurzhan Ismagulovhttp://www.kz-easy.com/>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group....
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>>http://groups.google.com/group/django-users?hl=en.
>>
>
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 19th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support