Polyglot.js is a lightweight internationalization library for JavaScript that runs in both browser and Node.js environments.
The library solves the problem of managing translated phrases and handling language-specific formatting in JavaScript applications. Rather than performing translation itself, Polyglot acts as a phrase manager that accepts pre-translated strings and provides two core features: interpolation to substitute variables into phrases, and pluralization rules that adapt text based on count and locale. Developers supply Polyglot with a phrases object mapping keys to translated strings, then call the translation method to retrieve and format those phrases at runtime.
Polyglot suits projects that already have translated content available and need a lightweight client-side or server-side mechanism to deliver it. The class-based design allows maintaining separate phrase sets for different locales simultaneously, which is particularly valuable in server environments like Express where concurrent requests may require different languages. The library is agnostic about translation backends, leaving the responsibility of obtaining translations to the developer. The interpolation syntax is customizable, and the tool handles the complexity of pluralization rules that vary across languages, where different locales have different numbers of plural forms and different word orderings.
The project maintains an active test suite that can be run with standard npm commands. Development activity shows consistent attention to code quality and documentation, with annotated source code available alongside the main repository documentation.