PHPackages                             atk4/i18n - 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. atk4/i18n

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

atk4/i18n
=========

Symfony Translation component Interface for Atk4

v1.0.0(5y ago)47.5k1MITPHPPHP &gt;=7.3.0CI passing

Since Apr 4Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/atk4/i18n)[ Packagist](https://packagist.org/packages/atk4/i18n)[ Docs](https://github.com/atk4/i18n)[ RSS](/packages/atk4-i18n/feed)WikiDiscussions develop Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Translation service for Atk4\\Ui
================================

[](#translation-service-for-atk4ui)

Interface for Symfony\\Translation component for Agile Toolkit Ui.

[![sample](images/sample.png)](images/sample.png)

Installation
------------

[](#installation)

```
composer require atk4/i18n

```

Usage
-----

[](#usage)

### Initialisation

[](#initialisation)

The translator need initializing.

```
use Atk4\I18n\Service;

Service::init($locale, $formatter, $cachePath, $cacheOptions, $clearCache);

```

#### string $locale

[](#string-locale)

The default locale use by the Symfony Translator.

#### MessageFormatterInterface $formatter

[](#messageformatterinterface-formatter)

\[optional\] - You can supply your own formatter which comply to MessageFormatterInterface from Symfony. When null, the symfony translation component will create one by default.

#### string $cachePath

[](#string-cachepath)

\[optional\] - This will cache translation resources files at specify location. It is recomand to use for production as it will speed up resource loading.

```
$cahePath = 'dir/to/caches'

```

#### array $cacheOptions

[](#array-cacheoptions)

\[optional\] - Will generate caches files according to this option. A good usage would be to specify caches for a translation version.

```
$caheOptions = ['version' => '1.0.0']

```

#### bool $clearCache

[](#bool-clearcache)

\[optional\] - Will clear caches files and regenerates resource file. For use in development.

### Adding Resources files

[](#adding-resources-files)

Once translator has been initialized, add your translation resource files to it.

```
Service::addResource($path, $locale, $format);

```

#### string $path

[](#string-path)

The path to the directory where your resource files are located. In order to load correctly, this directory must be organized per locale.

```
├── languages
│   ├── en
│   │   ├── messages.en.php
│   │   └── messages+intl-icu.en.php
│   ├── en_US
│   │   ├── messages.en_US.php
│   │   └── messages+intl-icu.en_US.php
│   ├── fr
│   │   ├── messages.fr.php
│   │   └── messages+intl-icu.fr.php
│   ├── fr_FR
│   │   ├── messages.fr_FR.php
│   │   └── messages+intl-icu.fr_FR.php

```

By specifing the languages path, the service will automatically load all resources within the specified locale directory and file type format.

##### Important:

[](#important)

Resource files name must follow this convention:

- default message: \[domain\].\[locale\].\[format\]
- ICU message: \[domain\]+intl-icu.\[locale\].\[format\]

#### string $locale

[](#string-locale-1)

The locale directory to load file from.

#### string $format

[](#string-format)

The file format to load that is located inside the specified locale directory.

The service support file of type: php, yaml, po, csv, json, xlf, ini, mo, qt.

### The shortcut function \_t().

[](#the-shortcut-function-_t)

The service expose a shortcut function in order to translate messages directly.

```
use function Atk4\I18n\Resource\_t;

echo _t($id, $param, $domain, $locale)

```

#### string $id

[](#string-id)

The id of the resource to translate.

#### array $param

[](#array-param)

\[optional\] - The parameter needed for translating the resource. Usually need for ICU message format.

#### string $domain

[](#string-domain)

\[optional\] - The domain name. Default is 'messages'.

#### string $locale

[](#string-locale-2)

\[optional\] - The locale name. Default is the one use in the service init method.

### The Translatable message T::class.

[](#the-translatable-message-tclass)

You may define certain messages to translate at a later stage using the translatable message `T::class`.

```
use Atk4\I18n\T;

// create translatable msg instance.
$msg = T::from($id, $param, $domain)
//...

// output $msg in specified locale when need.
echo $msg->in('fr_FR');

```

### Fallback locales

[](#fallback-locales)

The symfony\\translation component support fallback strategy for unavailable locale resources.

```
Service::addFallbackLocales(array $locales)

```

More information
----------------

[](#more-information)

- [The Symfony\\Translation component.](https://symfony.com/index.php/doc/current/translation.html)
- [The ICU message format](https://symfony.com/index.php/doc/current/translation/message_format.html)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance55

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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

Unknown

Total

1

Last Release

1907d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/426ad318d07e7685454f7e449a9d0c9f005b83aef0777558d97d854ff9c28a5a?d=identicon)[romaninsh](/maintainers/romaninsh)

---

Top Contributors

[![ibelar](https://avatars.githubusercontent.com/u/2204478?v=4)](https://github.com/ibelar "ibelar (7 commits)")[![mvorisek](https://avatars.githubusercontent.com/u/2228672?v=4)](https://github.com/mvorisek "mvorisek (2 commits)")

---

Tags

internationalizationi18ntranslationatk4agile ui

### Embed Badge

![Health badge](/badges/atk4-i18n/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[a2lix/translation-form-bundle

Translate your doctrine objects easily with some helpers

3387.1M38](/packages/a2lix-translation-form-bundle)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

42411.0M74](/packages/jms-translation-bundle)[contributte/translation

Symfony/Translation integration for Nette Framework.

771.8M49](/packages/contributte-translation)[symfony/crowdin-translation-provider

Symfony Crowdin Translation Provider Bridge

13534.4k1](/packages/symfony-crowdin-translation-provider)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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