3 ms·
I have personally never seen this before. I'd be wary to use it, since it breaks the "_ is a throwaway" idiom, as well as the REPL "_ is the results of the last
by falcolas 13y ago
I have personally never seen this before. I'd be wary to use it, since it breaks the "_ is a throwaway" idiom, as well as the REPL "_ is the results of the last expression" function.
Aliasing it to "t" or "txl" seems like a saner way, if I'm honest.
- Walkman 13y agoyou never use gettext in REPL :) and it's common to use '_' as gettext. Less typing, more readable strings. If you don't believe me, you should believe Alex Martelli [1], a random Python developer [2] or just read Official Python documentation [3] which recommends assignign gettext.gettext to '_'... [1]: http://stackoverflow.com/a/2745537/720077 http://stackoverflow.com/a/2745537/720077 http://stackoverflow.com/a/1739541/720077 http://stackoverflow.com/a/1739541/720077 [2]: http://stackoverflow.com/a/5893946/720077 http://stackoverflow.com/a/5893946/720077 [3]: http://docs.python.org/2/library/gettext.html http://docs.python.org/2/library/gettext.html
- thruflo 13y agoThis has been established practise in Zope, Plone et al for many years. http://developer.plone.org/i18n/internationalisation.html#marking-translatable-strings-in-python http://developer.plone.org/i18n/internationalisation.html#ma...
- dalke 13y agoIt's standard Python practice since Martin von Löwis's work in support for internationalization, which he presented at the IPC6 Python conference in 1997. Quoting from http://www.python.org/workshops/1997-10/proceedings/loewis.html http://www.python.org/workshops/1997-10/proceedings/loewis.h... : > Here are several ways of producing the message catalogs. This is the one suggested by the GNU gettext documentation. First, all translatable message strings in the source code must be marked. In order to disturb readability as little as possible, the wrapper function around each string should be called _ (underscore). This use of the underscore usually does not interfere with its meaning in the interactive mode. A gettextized module would then begin with import intl _=intl.gettext