Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-18 Thread Barry via Python-list
> On 17 Aug 2023, at 15:01, c.buhtz--- via Python-list > wrote: > > I want to display one string in its original source (untranslated) version > and in its translated version site by site without duplicating the string in > the python source code? > It wouldn't be a big deal if it is only on

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Greg Ewing via Python-list
On 17/08/23 7:10 pm, c.bu...@posteo.jp wrote: def foobar(translate):     if not translate:     # I try to mask the global _() builtins-function     def _(txt):     return txt     return _('Hello') This causes _ to become a local that is left undefined on one branch of the

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Mirko via Python-list
Am 17.08.23 um 21:17 schrieb c.buhtz--- via Python-list: Hello Mirko, thanks for reply. Am 17.08.2023 18:19 schrieb Mirko via Python-list: You could solve it by defining _() locally like so: def foobar(translate):     _ = gettext.gettext I see no way to do that. It is not the "class based A

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread c.buhtz--- via Python-list
Hello Mirko, thanks for reply. Am 17.08.2023 18:19 schrieb Mirko via Python-list: You could solve it by defining _() locally like so: def foobar(translate): _ = gettext.gettext I see no way to do that. It is not the "class based API" of gettext installing _() into the builtins namespace

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Dieter Maurer via Python-list
c.bu...@posteo.jp wrote at 2023-8-17 07:10 +: >I want to display one string in its original source (untranslated) >version and in its translated version site by site without duplicating >the string in the python source code? You could try to translate into an unknown language: this should give

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Richard Damon via Python-list
> On Aug 17, 2023, at 10:02 AM, c.buhtz--- via Python-list > wrote: > > X-Post: https://stackoverflow.com/q/76913082/4865723 > > I want to display one string in its original source (untranslated) version > and in its translated version site by site without duplicating the string in > the pyt

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Dieter Maurer via Python-list
c.bu...@posteo.jp wrote at 2023-8-17 07:10 +: >I want to display one string in its original source (untranslated) >version and in its translated version site by site without duplicating >the string in the python source code? Is it an option for you to replace the `gettext` binding by `zope.i18

Re: GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread Mirko via Python-list
Am 17.08.23 um 09:10 schrieb c.buhtz--- via Python-list:     UnboundLocalError: local variable '_' referenced before assignment This is a common gotcha: https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value You could solve it by

GNU gettext: Print string translated and untranslated at the same time

2023-08-17 Thread c.buhtz--- via Python-list
X-Post: https://stackoverflow.com/q/76913082/4865723 I want to display one string in its original source (untranslated) version and in its translated version site by site without duplicating the string in the python source code? It wouldn't be a big deal if it is only one word. print('The