Using localization strings within PHP


I would like to access translation keys from .php files. Is that possible? I know in templates (.tpl) I can use

translate key=“some.translation.key”

Any idea how to access those keys from the PHP code as well?

Regards, Primož

Hi @primozs,

In the PHP code, you can use…

$translation = __('some.translation.key');

You’ll need to make sure that the appropriate locale file has been loaded first. You can do that with e.g…


There are examples of this in plugins/reports/articles/

Alec Smecher
Public Knowledge Project Team