Search code examples
phpgettextphp-gettext

PHPs gettext with directory of languages without textdomain


I want to use PHPs gettext() to translate my application automatically. But for me, it's real overkill having locales/de_DE/LC_ALL/$app_name.mo. I would need somnthing like only locales/de_DE.mo, like WordPress does it. How could I configure gettext to use it like this?


Solution

  • Short answer is: you can't.

    Long answer: Wordpress doesn't rely on gettext. It uses the same po/mo input files, but mimics gettext behavior with its own classes and functions, basically storing translations in a global array.

    You can see this looking at the source code of /wp-includes/l10n.php and every class inside of wp-includes/pomo