Hi,

> I have a Menu app that takes data from the database and renders it
> into a template. I was wondering if I can translate the output from
> the database. There are only a few entries.
> Can I add the text that the menu will render that is stored in the db
> and add it to the .po file?
> How can I do it?

I am assuming that you mean "how can I add the language translations
from the DB to the .po file dynamically?". That's complicated by the
fact that adding to the .po file is not enough -- you will need to
compile the .po file and restart the Django application. Translations
get loaded only once when the application/server process starts up.

If your menu doesn't change at all, you could just add the
translations to the .po file manually :)

Otherwise, something simple like the following will allow you to get
dynamic translations:

In your view that renders the menu, grab the value of
request.LANGUAGE_CODE and fetch your menu items from the DB based on
that language code. Then, send the menu items to your template. You
will need to include LocaleMiddleware for this to work as described
here:

http://www.djangoproject.com/documentation/i18n/

If you're not rendering your menus through a view, let us know how
you're doing it and there's probably a way to use the above solution
with it (middleware, templatetags, ...)

-Rajesh D


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to