Oh, just to be clear, the hack involves putting the content into the template, and marking it for translation.
On Friday, April 19, 2013 1:57:44 PM UTC-7, Daniel Krol wrote: > > There isn't anything built into Django to translate the content of models. > This is because the GNU gettext system that Django uses for translation > stores the original->translation mappings in a "compiled" file which only > changes between restarts of the server. That means anything you dynamically > create in the database cannot be translated with this system, at least > without a sort of a hack. > > And the hack is this: If you have access to the data from the live > database from your development environment, you could theoretically dump it > (the actual full text verbatim, not just a variable containing the > content), to a dummy template file. Then, makemessages will pick up that > text and put it into the translation files. *then* you can translate it, > and say {% trans model_instance.field %}. Where I work, we've done this for > very small pieces of data (category names, of which there are less than > 10). It's manageable at this point. But with full blog posts, unless you > automate some sort of system, it's probably way too big a hack to be worth > it. (You'd have to make sure your spacing was 100% correct, too.) > > No, what I recommend is to create a model in the database that serves as > the translated version of all the specific models whose content you want to > translate. For instance, you want BlogPostTranslation, with an FK to > BlogPost, and also a locale. Then in your view, you select the appropriate > translation to show based on the locale in the request > (request.LANGUAGE_CODE). > > Since this is somewhat of a common concern, there are libraries out there > that facilitate this. I won't list them because I have no recommendations > on the matter (I have not tried any personally), your own Google search > will be as good as mine. But look for things along the line of "django > model translation". > > Hope this helps. > > On Tuesday, April 16, 2013 9:15:40 AM UTC-7, Cody Scott wrote: >> >> I want the end user of the site to be able to view the site in different >> languages. >> >> I have marked the static text in my templates for translation. I have not >> marked the verbose_names because they are used in the admin which the end >> user will not have access to. >> >> But I just realized that the actually content in the database needs to be >> translated. If it was a blog site the blog posts which are stored in the >> database would also need to be translated. >> >> How do I mark them for translation? >> >> How can I see the site in a different language. In the tutorial is says >> you can see the admin section in a different language how do I do that? >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.