An Internationalization Framework for PHP.

4.3.3 2025-04-15 19:18 UTC

README

FBT

FBT for PHP

Latest Version on Packagist MIT Licensed Test Status Code Style Status Total Downloads

FBT is an internationalization framework for PHP designed to be not just powerful and flexible, but also simple and intuitive. It helps with the following:

  • Organizing your source text for translation
  • Composing grammatically correct translatable UI
  • Eliminating verbose boilerplate for generating UI

This library is based on the JavaScript implementation of Facebook's FBT.

FBT intro

FBT plurals

FBT enum

FBT pronouns

πŸ“– Requirements

  • PHP 7.0 or higher
  • Composer is required for installation

πŸ“¦ Installing

$ composer require richarddobron/fbt:^4

✨ Features

  • Parameters and interpolation
  • Implicit parameters
  • Auto-parameterization
  • Plurals
  • Enumerations
  • Pronouns
  • Number formatting
  • Phrase extracting
  • Inline translating

πŸš€ Getting started

See the Getting Started guide for more.

πŸ“‘ Version Guidance

Version Released Status Repo PHP Version
3.x 2022-02-18 Maintained v3 >= 7.0
4.x 2022-04-09 Latest v4 >= 7.2

πŸ”Œ Official integrations

The following integrations are fully supported and maintained:

βš™οΈ How FBT works

FBT works by transforming your <fbt> and fbt(...) constructs via Simple HTML DOM Parser. It serves to extract strings from source and lookup translated payloads generated during execution. FBT creates tables of all possible variations for each fbt phrase and accesses them at runtime.

πŸ“• Full documentation

βœ… TODO

  • Add driver-agnostic support for multiple database systems.
  • Add integrations for Symfony, CakePHP, Zend Framework, ...
  • ...

🀝 Contributing

We welcome contributions! If you'd like to help improve this project, feel free to open an issue or submit a pull request.

πŸ“œ License

FBT is MIT licensed, as found in the LICENSE file.