Mercurial/Python - What Does The Underscore Function Do?

后端 未结 2 1579
无人及你
无人及你 2020-12-11 17:41

In Mercurial, many of the extensions wrap their help/syntax string in a call to an underscore function, like so:

 _(\'[OPTION] [QUEUE]\')

T

2条回答
  •  星月不相逢
    2020-12-11 18:27

    Look on line 45:

    from mercurial.i18n import _
    

    This is the usual abbreviation in the internationalization package gettext, and possibly other packages too, for the function that returns a translation of its argument to the language the program is currently running in. It's abbreviated to _ for convenience, since it's used for just about every message displayed to the user.

    Looks like Mercurial wraps it in their own module. ("i18n" stands for "internationalization" because there are 18 letters in between "i" and "n".)

提交回复
热议问题