gettext .po Files in Vite — Without a Translation SaaS

Most React i18n tutorials push JSON files scattered in components or a paid translation management system. For a solo portfolio with four languages, that is overkill. I use gettext .po catalogs — the same format PHP and Linux tools have used for decades — compiled at bundle time with a tiny custom Vite plugin.

A poLoader() plugin in vite.config.ts intercepts .po imports and transforms them into plain JSON objects. No runtime parser, no extra NPM dependency. Each .po file becomes a module you import like any other asset.

Keys are the English source strings (msgid). Values are the translations (msgstr). Translators can edit .po files in any editor or Poedit without touching React code.

← Rafael González Albes