Re: [web2py] Re: Simultaneous multi-language system.
It works. Thanks Massimo. 2011/7/23 Massimo Di Pierro > There is a solution in trunk. Please check it: > http://code.google.com/p/web2py/issues/detail?id=342 > > > print T("hello") #defualt > print T("hello", language="it-it") #etc etc > > > On Jul 22, 4:52 am, jamarcer wrote: > > Hello: > > > > I have added a comment to the ticket: > > > > http://code.google.com/p/web2py/issues/detail?id=342 > > > > It is an approach to the issue, based in Anthony's proposal: a class > > that stores multiple T objects. > > > > I am demetrio's companion. We develop the same application, but we > > have different roles :), so I will test this approach, and other > > possible solutions. > > > > Regards. > > > > On 21 jul, 10:16, Daniel Gonzalez Zaballos > > wrote: > > > > > > > > > > > > > > > > > i'll start with the Anthony suggestion. > > > I've opened the ticket: > http://code.google.com/p/web2py/issues/detail?id=342 > > > > > Thank you to everybody > > > > > 2011/7/21 Massimo Di Pierro > > > > > > I think for now Anthony's proposal is the way to go. Open a ticket in > > > > google code and we can think of other options. > > > > > > On Jul 20, 5:53 pm, Anthony wrote: > > > > > I think there are a few possibilities. First, your MultiT function > could > > > > > work, but you'd have to use str(T(text)) instead of T(text). The > reason > > > > is > > > > > that T() returns a lazyT object, not the translated string (it > isn't > > > > > translated until rendering). You can force the translation by > calling the > > > > > lazyT.__str__ method via str(T(text)). > > > > > > > Another option is to define your own T() objects for each language > and > > > > force > > > > > them to use the specific language. For example: > > > > > > > In a model file: > > > > > from gluon.languages import translator > > > > > enT=translator(request) > > > > > enT.force('en-en') > > > > > esT=translator(request) > > > > > esT.force('es-es') > > > > > > > In a view: > > > > > {{=esT('House')}} / {{=enT('House')}} > > > > > > > It would probably be easy to abstract the above by defining a class > that > > > > > stores multiple T objects and lets you easily add additional ones. > > > > > > > A third option might be to create a special multi-language > translation > > > > file. > > > > > For example, you could create a file called es-en.py, which could > include > > > > > translations such as: > > > > > > > 'House': 'Casa / House' > > > > > > > Hope that helps. > > > > > > > Anthony > > > > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > > > > > Hi everyone, i don't know if "Simultaneous multi-language system" > is > > > > > > the correct way to say what i need... i'll explain myself. > > > > > > > > I'm developing an application that by request of our customer, > needs > > > > > > to have 2 languages at the same time. For example, if this app > were in > > > > > > spanish and english, in the navigator should appear something > like: > > > > > > > > Casa / House > > > > > > > > In the view we want to do something like this > > > > > > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > > > > > > But i don't know if web2py can permit to do this or something > like > > > > > > that. > > > > > > > > I was thinking of writing a function like this: > > > > > > > > def MultiT(text,separator=" / "): > > > > > > T.force("es-es") > > > > > > ret_text = T(text) > > > > > > T.force("en-en") > > > > > > ret_text += separator + T(text) > > > > > > return ret_text > > > > > > > > But it does not work. Also, do not know how this affects the > system > > > > > > when updating the language files with the strings to translate > (now > > > > > > the files are updated automatically when pressing the "update > > > > > > languages" button in admin, and I guess that it would make it on > run > > > > > > time. > > > > > > > > Any sugestions? > > > > > > > > Best regards > > > > > > Daniel >
[web2py] Re: Simultaneous multi-language system.
There is a solution in trunk. Please check it: http://code.google.com/p/web2py/issues/detail?id=342 print T("hello") #defualt print T("hello", language="it-it") #etc etc On Jul 22, 4:52 am, jamarcer wrote: > Hello: > > I have added a comment to the ticket: > > http://code.google.com/p/web2py/issues/detail?id=342 > > It is an approach to the issue, based in Anthony's proposal: a class > that stores multiple T objects. > > I am demetrio's companion. We develop the same application, but we > have different roles :), so I will test this approach, and other > possible solutions. > > Regards. > > On 21 jul, 10:16, Daniel Gonzalez Zaballos > wrote: > > > > > > > > > i'll start with the Anthony suggestion. > > I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342 > > > Thank you to everybody > > > 2011/7/21 Massimo Di Pierro > > > > I think for now Anthony's proposal is the way to go. Open a ticket in > > > google code and we can think of other options. > > > > On Jul 20, 5:53 pm, Anthony wrote: > > > > I think there are a few possibilities. First, your MultiT function could > > > > work, but you'd have to use str(T(text)) instead of T(text). The reason > > > is > > > > that T() returns a lazyT object, not the translated string (it isn't > > > > translated until rendering). You can force the translation by calling > > > > the > > > > lazyT.__str__ method via str(T(text)). > > > > > Another option is to define your own T() objects for each language and > > > force > > > > them to use the specific language. For example: > > > > > In a model file: > > > > from gluon.languages import translator > > > > enT=translator(request) > > > > enT.force('en-en') > > > > esT=translator(request) > > > > esT.force('es-es') > > > > > In a view: > > > > {{=esT('House')}} / {{=enT('House')}} > > > > > It would probably be easy to abstract the above by defining a class that > > > > stores multiple T objects and lets you easily add additional ones. > > > > > A third option might be to create a special multi-language translation > > > file. > > > > For example, you could create a file called es-en.py, which could > > > > include > > > > translations such as: > > > > > 'House': 'Casa / House' > > > > > Hope that helps. > > > > > Anthony > > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > > > > Hi everyone, i don't know if "Simultaneous multi-language system" is > > > > > the correct way to say what i need... i'll explain myself. > > > > > > I'm developing an application that by request of our customer, needs > > > > > to have 2 languages at the same time. For example, if this app were in > > > > > spanish and english, in the navigator should appear something like: > > > > > > Casa / House > > > > > > In the view we want to do something like this > > > > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > > > > But i don't know if web2py can permit to do this or something like > > > > > that. > > > > > > I was thinking of writing a function like this: > > > > > > def MultiT(text,separator=" / "): > > > > > T.force("es-es") > > > > > ret_text = T(text) > > > > > T.force("en-en") > > > > > ret_text += separator + T(text) > > > > > return ret_text > > > > > > But it does not work. Also, do not know how this affects the system > > > > > when updating the language files with the strings to translate (now > > > > > the files are updated automatically when pressing the "update > > > > > languages" button in admin, and I guess that it would make it on run > > > > > time. > > > > > > Any sugestions? > > > > > > Best regards > > > > > Daniel
[web2py] Re: Simultaneous multi-language system.
Hello: I have added a comment to the ticket: http://code.google.com/p/web2py/issues/detail?id=342 It is an approach to the issue, based in Anthony's proposal: a class that stores multiple T objects. I am demetrio's companion. We develop the same application, but we have different roles :), so I will test this approach, and other possible solutions. Regards. On 21 jul, 10:16, Daniel Gonzalez Zaballos wrote: > i'll start with the Anthony suggestion. > I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342 > > Thank you to everybody > > 2011/7/21 Massimo Di Pierro > > > > > > > > > I think for now Anthony's proposal is the way to go. Open a ticket in > > google code and we can think of other options. > > > On Jul 20, 5:53 pm, Anthony wrote: > > > I think there are a few possibilities. First, your MultiT function could > > > work, but you'd have to use str(T(text)) instead of T(text). The reason > > is > > > that T() returns a lazyT object, not the translated string (it isn't > > > translated until rendering). You can force the translation by calling the > > > lazyT.__str__ method via str(T(text)). > > > > Another option is to define your own T() objects for each language and > > force > > > them to use the specific language. For example: > > > > In a model file: > > > from gluon.languages import translator > > > enT=translator(request) > > > enT.force('en-en') > > > esT=translator(request) > > > esT.force('es-es') > > > > In a view: > > > {{=esT('House')}} / {{=enT('House')}} > > > > It would probably be easy to abstract the above by defining a class that > > > stores multiple T objects and lets you easily add additional ones. > > > > A third option might be to create a special multi-language translation > > file. > > > For example, you could create a file called es-en.py, which could include > > > translations such as: > > > > 'House': 'Casa / House' > > > > Hope that helps. > > > > Anthony > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > > > Hi everyone, i don't know if "Simultaneous multi-language system" is > > > > the correct way to say what i need... i'll explain myself. > > > > > I'm developing an application that by request of our customer, needs > > > > to have 2 languages at the same time. For example, if this app were in > > > > spanish and english, in the navigator should appear something like: > > > > > Casa / House > > > > > In the view we want to do something like this > > > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > > > But i don't know if web2py can permit to do this or something like > > > > that. > > > > > I was thinking of writing a function like this: > > > > > def MultiT(text,separator=" / "): > > > > T.force("es-es") > > > > ret_text = T(text) > > > > T.force("en-en") > > > > ret_text += separator + T(text) > > > > return ret_text > > > > > But it does not work. Also, do not know how this affects the system > > > > when updating the language files with the strings to translate (now > > > > the files are updated automatically when pressing the "update > > > > languages" button in admin, and I guess that it would make it on run > > > > time. > > > > > Any sugestions? > > > > > Best regards > > > > Daniel
[web2py] Re: Simultaneous multi-language system.
Hello: I have added a comment to the ticket, explaining an approach to this issue. It is based on Anthony's proposal, as demetrio said :). I am demetrio's companion, so I will test this approach, or others possible solutions. Regards. Link to ticket: http://code.google.com/p/web2py/issues/detail?id=342 On 21 jul, 10:16, Daniel Gonzalez Zaballos wrote: > i'll start with the Anthony suggestion. > I've opened the ticket:http://code.google.com/p/web2py/issues/detail?id=342 > > Thank you to everybody > > 2011/7/21 Massimo Di Pierro > > > > > > > > > I think for now Anthony's proposal is the way to go. Open a ticket in > > google code and we can think of other options. > > > On Jul 20, 5:53 pm, Anthony wrote: > > > I think there are a few possibilities. First, your MultiT function could > > > work, but you'd have to use str(T(text)) instead of T(text). The reason > > is > > > that T() returns a lazyT object, not the translated string (it isn't > > > translated until rendering). You can force the translation by calling the > > > lazyT.__str__ method via str(T(text)). > > > > Another option is to define your own T() objects for each language and > > force > > > them to use the specific language. For example: > > > > In a model file: > > > from gluon.languages import translator > > > enT=translator(request) > > > enT.force('en-en') > > > esT=translator(request) > > > esT.force('es-es') > > > > In a view: > > > {{=esT('House')}} / {{=enT('House')}} > > > > It would probably be easy to abstract the above by defining a class that > > > stores multiple T objects and lets you easily add additional ones. > > > > A third option might be to create a special multi-language translation > > file. > > > For example, you could create a file called es-en.py, which could include > > > translations such as: > > > > 'House': 'Casa / House' > > > > Hope that helps. > > > > Anthony > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > > > Hi everyone, i don't know if "Simultaneous multi-language system" is > > > > the correct way to say what i need... i'll explain myself. > > > > > I'm developing an application that by request of our customer, needs > > > > to have 2 languages at the same time. For example, if this app were in > > > > spanish and english, in the navigator should appear something like: > > > > > Casa / House > > > > > In the view we want to do something like this > > > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > > > But i don't know if web2py can permit to do this or something like > > > > that. > > > > > I was thinking of writing a function like this: > > > > > def MultiT(text,separator=" / "): > > > > T.force("es-es") > > > > ret_text = T(text) > > > > T.force("en-en") > > > > ret_text += separator + T(text) > > > > return ret_text > > > > > But it does not work. Also, do not know how this affects the system > > > > when updating the language files with the strings to translate (now > > > > the files are updated automatically when pressing the "update > > > > languages" button in admin, and I guess that it would make it on run > > > > time. > > > > > Any sugestions? > > > > > Best regards > > > > Daniel
Re: [web2py] Re: Simultaneous multi-language system.
i'll start with the Anthony suggestion. I've opened the ticket: http://code.google.com/p/web2py/issues/detail?id=342 Thank you to everybody 2011/7/21 Massimo Di Pierro > I think for now Anthony's proposal is the way to go. Open a ticket in > google code and we can think of other options. > > On Jul 20, 5:53 pm, Anthony wrote: > > I think there are a few possibilities. First, your MultiT function could > > work, but you'd have to use str(T(text)) instead of T(text). The reason > is > > that T() returns a lazyT object, not the translated string (it isn't > > translated until rendering). You can force the translation by calling the > > lazyT.__str__ method via str(T(text)). > > > > Another option is to define your own T() objects for each language and > force > > them to use the specific language. For example: > > > > In a model file: > > from gluon.languages import translator > > enT=translator(request) > > enT.force('en-en') > > esT=translator(request) > > esT.force('es-es') > > > > In a view: > > {{=esT('House')}} / {{=enT('House')}} > > > > It would probably be easy to abstract the above by defining a class that > > stores multiple T objects and lets you easily add additional ones. > > > > A third option might be to create a special multi-language translation > file. > > For example, you could create a file called es-en.py, which could include > > translations such as: > > > > 'House': 'Casa / House' > > > > Hope that helps. > > > > Anthony > > > > > > > > > > > > > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > > Hi everyone, i don't know if "Simultaneous multi-language system" is > > > the correct way to say what i need... i'll explain myself. > > > > > I'm developing an application that by request of our customer, needs > > > to have 2 languages at the same time. For example, if this app were in > > > spanish and english, in the navigator should appear something like: > > > > > Casa / House > > > > > In the view we want to do something like this > > > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > > > But i don't know if web2py can permit to do this or something like > > > that. > > > > > I was thinking of writing a function like this: > > > > > def MultiT(text,separator=" / "): > > > T.force("es-es") > > > ret_text = T(text) > > > T.force("en-en") > > > ret_text += separator + T(text) > > > return ret_text > > > > > But it does not work. Also, do not know how this affects the system > > > when updating the language files with the strings to translate (now > > > the files are updated automatically when pressing the "update > > > languages" button in admin, and I guess that it would make it on run > > > time. > > > > > Any sugestions? > > > > > Best regards > > > Daniel >
[web2py] Re: Simultaneous multi-language system.
I think for now Anthony's proposal is the way to go. Open a ticket in google code and we can think of other options. On Jul 20, 5:53 pm, Anthony wrote: > I think there are a few possibilities. First, your MultiT function could > work, but you'd have to use str(T(text)) instead of T(text). The reason is > that T() returns a lazyT object, not the translated string (it isn't > translated until rendering). You can force the translation by calling the > lazyT.__str__ method via str(T(text)). > > Another option is to define your own T() objects for each language and force > them to use the specific language. For example: > > In a model file: > from gluon.languages import translator > enT=translator(request) > enT.force('en-en') > esT=translator(request) > esT.force('es-es') > > In a view: > {{=esT('House')}} / {{=enT('House')}} > > It would probably be easy to abstract the above by defining a class that > stores multiple T objects and lets you easily add additional ones. > > A third option might be to create a special multi-language translation file. > For example, you could create a file called es-en.py, which could include > translations such as: > > 'House': 'Casa / House' > > Hope that helps. > > Anthony > > > > > > > > On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > > Hi everyone, i don't know if "Simultaneous multi-language system" is > > the correct way to say what i need... i'll explain myself. > > > I'm developing an application that by request of our customer, needs > > to have 2 languages at the same time. For example, if this app were in > > spanish and english, in the navigator should appear something like: > > > Casa / House > > > In the view we want to do something like this > > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > > But i don't know if web2py can permit to do this or something like > > that. > > > I was thinking of writing a function like this: > > > def MultiT(text,separator=" / "): > > T.force("es-es") > > ret_text = T(text) > > T.force("en-en") > > ret_text += separator + T(text) > > return ret_text > > > But it does not work. Also, do not know how this affects the system > > when updating the language files with the strings to translate (now > > the files are updated automatically when pressing the "update > > languages" button in admin, and I guess that it would make it on run > > time. > > > Any sugestions? > > > Best regards > > Daniel
[web2py] Re: Simultaneous multi-language system.
I think there are a few possibilities. First, your MultiT function could work, but you'd have to use str(T(text)) instead of T(text). The reason is that T() returns a lazyT object, not the translated string (it isn't translated until rendering). You can force the translation by calling the lazyT.__str__ method via str(T(text)). Another option is to define your own T() objects for each language and force them to use the specific language. For example: In a model file: from gluon.languages import translator enT=translator(request) enT.force('en-en') esT=translator(request) esT.force('es-es') In a view: {{=esT('House')}} / {{=enT('House')}} It would probably be easy to abstract the above by defining a class that stores multiple T objects and lets you easily add additional ones. A third option might be to create a special multi-language translation file. For example, you could create a file called es-en.py, which could include translations such as: 'House': 'Casa / House' Hope that helps. Anthony On Wednesday, July 13, 2011 1:22:23 PM UTC-4, demetrio wrote: > Hi everyone, i don't know if "Simultaneous multi-language system" is > the correct way to say what i need... i'll explain myself. > > I'm developing an application that by request of our customer, needs > to have 2 languages at the same time. For example, if this app were in > spanish and english, in the navigator should appear something like: > > Casa / House > > In the view we want to do something like this > > {{=T("House", "es-es")}} / {{=T("House", "en-en")}} > > But i don't know if web2py can permit to do this or something like > that. > > I was thinking of writing a function like this: > > def MultiT(text,separator=" / "): > T.force("es-es") > ret_text = T(text) > T.force("en-en") > ret_text += separator + T(text) > return ret_text > > But it does not work. Also, do not know how this affects the system > when updating the language files with the strings to translate (now > the files are updated automatically when pressing the "update > languages" button in admin, and I guess that it would make it on run > time. > > Any sugestions? > > Best regards > Daniel
Re: [web2py] Re: Simultaneous multi-language system.
The thing is that in Spain, there are some bilingual regions with their own language besides the official language. Sometimes they require that an app be in the main language (spanish) and their specifical language and the capatility to switch between them, and rarely (this case), have both simultaneosly. If in the future, we sell the same app to a customer in a different region with its own language, we will need to revise all the code to find the literals and traduce them, and worse, have to maintain different versions of the same application with the only difference of the language. That's one of the reasons why we are looking for an optimal solution, like a way to extend the T() object. Thanks for your time. Best regards Daniel 2011/7/20 Christopher Steel > On the one hand If you only want to display two languages at the same time > at all times then translations are not required. > > If on the other hand you want people to be able to switch between languages > like this http://voiceofaccess.org , then translations are required but > displaying both languages at the same time is not required because people > can switch languages on the fly. > > > C. > >
[web2py] Re: Simultaneous multi-language system.
On the one hand If you only want to display two languages at the same time at all times then translations are not required. If on the other hand you want people to be able to switch between languages like this http://voiceofaccess.org , then translations are required but displaying both languages at the same time is not required because people can switch languages on the fly. C.
[web2py] Re: Simultaneous multi-language system.
Wow, that's a weird request. I suspect it is going to be easiest just to program the two variations without T().