Question

<TL;DR> It's used for internationalization in the GTK+, GIMP's GUI Toolkit. The link to the documentation is: N_() </TL;DR>


I'm working on Python-Fu and frequently see strings surrounded by N_(), as in: N_("Some random string").

Yet in another plug-in, the N_() wont be there and "Some random string" works just fine.

So what gives? I've searched around but didn't really find anything on this. A little help from a python expert would be greatly appreciated as I'm fairly new to it. Thanks!

<< Edit >>

This is a python plug-in registration function call for GIMP 2.8. It is required in each plugin and it registers the plugin with the GUI, showing up in the menuing system where you dictate in the 12th argument.

This is not to be confused with an earlier version of GIMP's parameter order, or Script-Fu, which is based on Scheme and so is unfortunately ugly as sin.

register(
    "omnicyde_btn_metal_ring",
    N_("Badass Glossy Metal Ring Button"),
    "This is going to be so incredibly sweet",
    "Omnicyde",
    "Omnicyde",
    "2014",
    "_BtnMetalRing",
    "",
    [],
    [],
    btn_metal_ring,
    menu="<Toolbox>/Omnicyde/Buttons",
    domain=("gimp20-python", gimp.locale_directory)
)

So, in some plugins there will be a N_() wrapping a string, and in some there won't for the same string in the argument list. Both versions work..

I figured it was a python core construct or something, as I'm kinda new to it. Then again, I'm new to Python-Fu as well. It's equally possible this is some GIMP thing, or even Python-Fu..

Was it helpful?

Solution

It is as hinted in the comments. N_ is an i10n macro defined in gi18n.h. gi18n uses the gettext library.

http://opensource.apple.com/source/ChatServer/ChatServer-37.1/libraries/glib-2.4.5/glib/gi18n.h

As for the gettext_noop you can see its uses at http://www.gnu.org/software/gettext/manual/html_node/Special-cases.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top