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

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

slick/i18n
==========

Internationalization and string translation package Slick Framework

v1.3.1(8y ago)02.5k1MITPHP

Since Jan 5Pushed 8y ago2 watchersCompare

[ Source](https://github.com/slickframework/i18n)[ Packagist](https://packagist.org/packages/slick/i18n)[ Docs](https://github.com/slickframework/tempalte)[ RSS](/packages/slick-i18n/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (5)Versions (6)Used By (1)

Slick I18n package
==================

[](#slick-i18n-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/da83772b180c7a1a8c40af0bb2f344f9cbc9381e2b28597fab4976515f493be4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c69636b2f6931386e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slick/i18n)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/963c780f4dc77f26a5f111b953fdaceb31f1d4f263f369bb1b92e8952b64b57b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f736c69636b6672616d65776f726b2f6931386e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/slickframework/i18n)[![Quality Score](https://camo.githubusercontent.com/e96f9b7f904c7d0d0148b83dd1cf14827a27993cc016bd2730f8aaf2d82e3011/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c69636b6672616d65776f726b2f6931386e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slickframework/i18n)[![Total Downloads](https://camo.githubusercontent.com/bcaf9e45dcebd3c5981174aa998d131b80741583d163f4595673cb70038221e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c69636b2f6931386e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slickframework/i18n)

Slick I18n is a simple translation and internationalization package. It depends on Zend/I18n which is a complete translation suite that supports all major formats and includes popular features like plural translations and text domains.

This package is compliant with PSR-2 code standards and PSR-4 autoload standards. It also applies the [semantic version 2.0.0](http://semver.org) specification.

Install
-------

[](#install)

Via Composer

```
$ composer require slick/i18n
```

Usage
-----

[](#usage)

### Messages file

[](#messages-file)

Create a messages file:

```
/**
 * pt_PT messages file
 */

return [
    '' => array(
            'plural_forms' => 'nplurals=2; plural=n!=1;'
        ),
    'Hello world' => 'Olá mundo',
    'User' => ['Utilizador', 'Utilizadores'],
    'Users' => ''
];
```

save this file in `./i18n/pt_PT/messages.php`.

### Language negotiation and setup

[](#language-negotiation-and-setup)

Now lets get our translator:

```
use Slick\I18n\Language;
use Slick\I18n\Translation;
use Slick\I18n\Translator;

/**
 * Set locale based on the browser accept language
 */
$locale = 'en_US';
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
    $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
}

$translation = new Translation(new Language($locale), __DIR__.'/i18n');
$translator = new Translator($translation);

setlocale(LC_ALL, $locale);
```

The code above is using the browser's language to set the locale for our translator object. From now on just use the translation methods on the strings you want to translate.

### Message translation

[](#message-translation)

```
echo $translator->translate('Hello world');  // will output 'Olá mundo'
```

### Plural translation

[](#plural-translation)

```
echo $translator->translatePlural('User', 'Users', 2);  // will output 'Utilizadores'
```

### Using in your classes

[](#using-in-your-classes)

You can add translation functionality to your classes by using the `TranslateMethods` trait and injecting the translator.

```
use Slick\I18n\TranslateMethods;
use Slick\I18n\TranslationCapableInterface;
use Slick\I18n\TranslatotInterface;

class MyClass implements TranslationCapableInterface
{

    use TranslateMethods;

    public function __construct(TranslatotInterface $translator)
    {
        $this->tranlator = $translator;
    }

    public function getUsers()
    {
        return $this->translatePlural('User', 'Users', $this->getUserCount());
    }
}

```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [All Contributors](https://github.com/slickframework/i18n/graphs/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~228 days

Total

4

Last Release

3147d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/101112?v=4)[fsilva](/maintainers/fsilva)[@fsilva](https://github.com/fsilva)

---

Top Contributors

[![silvamfilipe](https://avatars.githubusercontent.com/u/5720969?v=4)](https://github.com/silvamfilipe "silvamfilipe (14 commits)")

---

Tags

i18ntranslationslick

###  Code Quality

TestsBehat

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[jenssegers/date

A date library to help you work with dates in different languages

1.8k11.5M84](/packages/jenssegers-date)[gettext/gettext

PHP gettext manager

70232.6M118](/packages/gettext-gettext)[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9683.4M13](/packages/fightbulc-moment)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

44311.1M75](/packages/jms-translation-bundle)[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4482.8M19](/packages/lexik-translation-bundle)[sonata-project/translation-bundle

SonataTranslationBundle

781.7M11](/packages/sonata-project-translation-bundle)

PHPackages © 2026

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