germanfr germanfr - 1 year ago 103
Linux Question

String with underscore Javascript meaning

I've seen in some places that strings are surrounded by _() like

_('some string')

For example in a desktop program with these imports:

const Applet = imports.ui.applet;
const St =;
const Gdk =;
const Gtk =;
const Keymap = Gdk.Keymap.get_default();
const Caribou =;
const PopupMenu = imports.ui.popupMenu;
const Lang = imports.lang;
const Gio =;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;

What is the use of that function?

Answer Source

I'll answer myself based on comments I got. (I already knew _ is not anything special but a normal function name, that wasn't the question).

Based on those imports, it seems to be part of a system library. Concretely this:

const Lang = imports.lang;

It is used to translate strings into other languages automatically. For example:

_('Hello') //Hola
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download