Internationalization
Last updated
Was this helpful?
Last updated
Was this helpful?
Internationalization of a theme works pretty much the same way as it does for default WordPress themes. Follow the guide in the to setup i18n for your theme.
Twig has its own i18n extension that gives you {% trans %}
tags to define translatable blocks, but there’s no need to use it.
Wordpress Bundle add all the translation functions used in WordPress:
__()
_x()
_n()
_nx()
_n_noop()
_nx_noop()
translate()
translate_nooped_plural()
The functions _e()
and _ex()
are also supported, but you probably won’t need them in Twig, because {{ }}
already echoes the output.
To generate .pot
, .po
and .mo
files, you need a tool that supports parsing Twig files to detect all your translations. While there are a lot of tools that can parse PHP files, the solution that works best for Twig files is .
fully supports Twig file parsing (Pro version only) with the following functions: __(), _x(), _n(), _nx()
.