Let's say we have a table

db.define_table('thing',
                Field('name'),
                Field('description', 'text'),                Field('age', 
'integer'))


and we need to translate this to X amount of different languages and there 
could be potentially huge amount of these objects in database. How I should 
handle internalization/translations of these objects? Not all fields need 
to be translated, for example in that case age is language neutral 
information.

I know I could mark these with T and do something like {{=T(thing.name)}} in 
views for example. But it means that translation files are growing huge and 
managing translations isn't so easy. Also I'm not able to search objects 
from database based on translated information, for example if I want to 
find all things which have keywords x, y and z in their description and I 
want to use Germany as a search language. At least I've understood this so.


Other approach would be to take care of internalization in database level, 
either with "multiple column approach" or "multiple table approach" 
described very well in here: 
https://www.sofokus.com/en/localizing-dynamic-content-in-web-apps/
Multiple column approach is not really an option for X amount of languages 
but multiple table approach would work. The problem is that number of 
models get multiplied almost by two if content is in separate model and 
also controllers gets more complex, especially because I need fallback to 
default language in case of there is no translation. And inserting new data 
to database is more complex too since we need to add data to more than one 
table at time.

I'm wondering, is there any ready-made standard solution for this problem 
which would make this all easy to implement and manage in web2py? This is 
very standard need so for sure I'm not the first one to implement something 
like this. In Django, they have Parler 
(https://pypi.python.org/pypi/django-parler) for example which solves this 
problem very well and it's easy to use.

I think ideal solution is something where I wouldn't need care about 
internalization in views. So I could iterate over all things in views 
normally as I would do just in case of single language and names and 
descriptions would be in language user wants, or with fallback language if 
translation is not found. For example:

{{for thing in things:}}
    <p>{{=thing.name}}</p>
    <p>{{=thing.description}}</p>
    <p>{{=thing.age}}</p>
{{pass}}


Also managing translations should be easy. Interface presented in picture below 
would work very well (from 
https://www.sofokus.com/en/localizing-dynamic-content-in-web-apps/)

<https://lh3.googleusercontent.com/-upMarCVdDZo/WB3KACGi6xI/AAAAAAAAIkU/asGemx5qA8Yj6zucXLYrZWRPPuUoJ8AMACLcB/s1600/django_model_translation.png>

Any help is appreciated! I'm sure many of you have done this before so I'm 
willing to hear how you solve this. Also, is there any plans to implement 
something similar like Django Parler for web2py?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to