uhm. 
a) T() just translates at the "view" level, i.e. when those are actually 
serialized ... passing over a module containing "choices" wouldn't ACTUALLY 
translate them .
b) admin's management for T() strings is less than optimal with thousands 
of elements, and if in the need of a top-class "translation" subsystem I'd 
either build a better interface for it or use a different library 
alltogether (or even cook my own, as it's just a dict lookup anyway)
c) code to find all translations is 
there https://github.com/web2py/web2py/blob/master/gluon/languages.py#L949 
... it **seems** to scout app's modules. In **THAT** case, simply porting 
the module over the app's path will fetch all translations (you can then 
move out/delete the module, if you have it system-wide). I don't see a way 
for web2py to execute each and every code-path in your app to find all 
your's translations.

On Sunday, August 7, 2016 at 10:09:03 PM UTC+2, Jimbo wrote:
>
> Hi,
>
> I have several dictionaries which needs translation, where would you 
> recommended I store these?
>
> I currently have them in model-files and they typically looks something 
> like this:
>
> choices = collections.OrderedDict((
>     ('1', T('Choice 1')),
>     ('2', T('Choice 2')),
>     ...
> ))
>
>
> Then I use them in string-Fields with the IS_IN_SET validator.
>
> Since models are evaluated at every request it seems like a waste to have 
> these files with 'static' data being parsed all the time. For example, I 
> currently have around 2000 lines consisting of similar lists representing 
> different choices (country names, etc.).
> Therefore it seems natural (to me) to move them into modules and translate 
> them when needed using "current.T" or alternatively to translate them "once 
> and for all" (don't know if this is possible).
>
> However, if I define the dict in a module it seems like these strings are 
> only added to the "language list" when they are first evaluated by some 
> function, see this related question 
> <https://groups.google.com/forum/#!searchin/web2py/translation$20modules%7Csort:relevance/web2py/XXDhtjjMhXQ/s2hJCVY_eycJ>
> In this case, how do I go about generating the full list of all the 
> translation strings without manually triggering the translation for each of 
> them?
>
> Maybe I'm going about this the wrong way so would like to hear how other 
> people structure their translation resources.
>
> Thanks
> // Jim
>

-- 
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