PHPackages                             g4/translate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. g4/translate

ActiveLibrary[Localization &amp; i18n](/categories/localization)

g4/translate
============

g4 i18n php library

1.0.0(2y ago)030.4k2MITPHPPHP &gt;=8.3

Since Aug 21Pushed 2y ago11 watchersCompare

[ Source](https://github.com/g4code/translate)[ Packagist](https://packagist.org/packages/g4/translate)[ RSS](/packages/g4-translate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (20)Used By (0)

Translate
=========

[](#translate)

- Configuration of the gettext extension
- Utlity tool to generate .mo files
- Utility tool for extracting template strings

Install
-------

[](#install)

> Using Composer and Packagist

```
composer require g4/translate
```

Resources
---------

[](#resources)

- Twig The i18n Extension
- PHP gettext extension

Requirements
------------

[](#requirements)

- "twig/twig"
- "twig/extensions"

Usage
-----

[](#usage)

Set locale early in the program before rendering any internationalized template.

```
use G4\Translate\Locale\Locale;
use G4\Translate\Locale\Options;

$options = new Options();
$options
    ->setDomain('myDomain')
    ->setLocale('en_US')
    ->setPath('/path/to/locale/files');
(new Locale($options))->set();
```

### Command line interface

[](#command-line-interface)

Convert .po files to .mo

```
./vendor/bin/translate --path /path/to/locale/files
```

where --path is path to your locale folder

Extract template strings

```
./vendor/bin/translate-extract -t /path/to/templates -w /path/to/tmp -g /path/to/locale/files -d myDomain
```

where:

- -t is path to folder that contains templates
- -w is path to temp folder
- -g is path to folder where myDomain.po file with strings will be generated
- -d domain name

Development
-----------

[](#development)

### Install dependencies

[](#install-dependencies)

```
$ make install

```

### Run tests

[](#run-tests)

```
$ make test

```

License
-------

[](#license)

(The MIT License) see LICENSE file for details...

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 67.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~183 days

Recently: every ~588 days

Total

18

Last Release

808d ago

Major Versions

0.8.1 → 1.0.02024-03-01

PHP version history (2 changes)0.0.1PHP &gt;=5.4

1.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/12ceafbc629c3019d7cd78dfec322d694f44e0df8741bc6044f4acbf99964ff8?d=identicon)[g4code](/maintainers/g4code)

---

Top Contributors

[![gomboc](https://avatars.githubusercontent.com/u/1145653?v=4)](https://github.com/gomboc "gomboc (23 commits)")[![zeljkosbgd](https://avatars.githubusercontent.com/u/4016203?v=4)](https://github.com/zeljkosbgd "zeljkosbgd (4 commits)")[![mirko-bukilic](https://avatars.githubusercontent.com/u/76707321?v=4)](https://github.com/mirko-bukilic "mirko-bukilic (2 commits)")[![ppavlovic](https://avatars.githubusercontent.com/u/2664974?v=4)](https://github.com/ppavlovic "ppavlovic (2 commits)")[![sanjamedic](https://avatars.githubusercontent.com/u/13198949?v=4)](https://github.com/sanjamedic "sanjamedic (2 commits)")[![ivankoni](https://avatars.githubusercontent.com/u/570997?v=4)](https://github.com/ivankoni "ivankoni (1 commits)")

---

Tags

i18ntranslatelanguages

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/g4-translate/health.svg)

```
[![Health](https://phpackages.com/badges/g4-translate/health.svg)](https://phpackages.com/packages/g4-translate)
```

###  Alternatives

[gettext/languages

gettext languages with plural rules

7530.3M11](/packages/gettext-languages)[punic/punic

PHP-Unicode CLDR

1542.9M29](/packages/punic-punic)[optimistdigital/nova-translatable

A laravel-translatable extension for Laravel Nova.

202427.4k5](/packages/optimistdigital-nova-translatable)[outl1ne/nova-translatable

A laravel-translatable extension for Laravel Nova.

203416.9k8](/packages/outl1ne-nova-translatable)[loco/loco

Loco SDK for PHP, including REST API client

19626.8k4](/packages/loco-loco)[skillshare/formatphp

Internationalize PHP apps. This library provides an API to format dates, numbers, and strings, including pluralization and handling translations.

8029.6k](/packages/skillshare-formatphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
