Skip to content
DOCS

Keywords Settings

Keywords tell Poedit which functions in your code contain text to translate. This applies to gettext-based (PO) projects, where translatable text is marked directly in the code. During extraction, Poedit looks for these function names and pulls their string arguments into a PO file.

With gettext-based code, translatable text is passed to specific functions, such as gettext() or _(). In Poedit, keywords are the names of these functions and tell Poedit which pieces of text should be extracted for translation. With gettext-based code, these often look like:

_("Hello");
gettext("Hello");
ngettext("%d file deleted", "%d files deleted", count);
pgettext("Menu", "File");

Poedit cannot guess which functions in your code contain user-facing text. Keywords define this mapping: they tell Poedit which function names matter and which argument(s) contain the string.

If keywords are missing or wrong, Poedit may skip strings during extraction. This is common when:

  • your project uses custom wrapper functions
  • your framework uses different function names
  • plural forms or context arguments are in different positions

Adding or adjusting keywords makes sure all translatable text is found.

In many projects, you don’t need to change keywords manually. Poedit includes predefined keyword lists for supported languages and frameworks, which are added automatically when the option Also use default keywords for supported languages is enabled (the default).

You only need to adjust keywords if your project uses custom translation functions or a framework that Poedit doesn’t recognize out of the box. For example, when working with WordPress projects, Poedit automatically pre-fills WordPress-specific keywords. For a complete reference of the default gettext keywords per language, see the GNU gettext manual.

Some codebases use their own translation functions. For example:

tr("Save changes");
i18n("Login failed");

Poedit treats tr() and i18n() like any other function unless you tell it they represent translatable text.

To support functions like these, add them as keywords (this is what GNU gettext calls translation functions) in Translation → Properties… → Sources keywords.

By default, Poedit assumes that the first argument of a function contains the translatable string, but it is possible to further customize them.

Some translation functions take more than one string — for example plural forms or disambiguating context. Keywords use suffixes with argument positions to describe this:

  • funcname:1 — the first argument contains the string
  • funcname:1,2 — the first is singular, second is plural
  • funcname:1c,2 — the first is context, the second is the actual text

Keyword syntax follows the same format used by xgettext’s --keyword option (for example, :1, :1,2, :1c,2). For full details, see the GNU gettext manual.

Use caseKeywordExample code
Simple string__ or __:1_("Hello");
Plural formngettext:1,2ngettext("%d file deleted", "%d files deleted", count);
With contextpgettext:1c,2pgettext("Dialog title", "Save");
Custom helpertr:2tr(obj, "Connection lost");
  • If Poedit doesn’t extract a string, check whether the function name appears in the keywords list.
  • Make sure argument numbers match your function’s signature.
  • After adding a new keyword, re-scan using Translation → Update from Source Code so Poedit can pick up the changes.
  • Avoid removing pre-filled keywords unless you are sure those functions are not used.