PHPackages                             luism-s/multilingualslim - 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. luism-s/multilingualslim

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

luism-s/multilingualslim
========================

Multilanguage support for Slim micro-framework 3

1.1.3(7y ago)43261MITPHP

Since Sep 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/luism-s/slim-3-multilingual)[ Packagist](https://packagist.org/packages/luism-s/multilingualslim)[ Docs](https://github.com/luism-s/slim-3-multilingual)[ RSS](/packages/luism-s-multilingualslim/feed)WikiDiscussions master Synced 3w ago

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

Slim 3 Multilingual
===================

[](#slim-3-multilingual)

Extension to the [Slim PHP micro-framework](http://www.slimframework.com/) version 3 to enable language based routing, i.e. i18n and l10n.

Dependencies
------------

[](#dependencies)

- [Slim/Slim](https://github.com/slimphp/Slim) (v3)

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

[](#installation)

By terminal:

```
composer require luism-s/multilingualslim
```

Usage
-----

[](#usage)

The `$container` is used as an interface between the Middleware and the Routes. The multilinguage middleware injects the following variables into the `$container`: `default_language`, `available_languages` and `language`. The first two are variables set by the developer, and the last is set by the middleware itself and indicates the requested language.

```
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';

$default_language = 'pt';
$available_languages = ['pt', 'en'];

$app = new \Slim\App();
$container = $app->getContainer();

$app->add( new \MultilingualSlim\LanguageMiddleware($available_languages, $default_language, $container) );

$app->get('/', function (Request $request, Response $response) {
    // This works with '/', '/pt' and '/en',
    // and prints 'Hello' in each language.
    if ($this->language === 'pt') {
        return $response->write("Olá Mundo");
    } elseif($this->language === 'en') {
        return $response->write("Hello World");
    }
});

$app->run();
```

You can also use a library to render templates such as php-view. For example:

```
$container['renderer'] = new \Slim\Views\PhpRenderer("../views/");

$app->get('/home', function (Request $request, Response $response) {
    // This works with '/home', '/pt/home' and '/en/home',
    // and returns the template views/base.php.
    // It also passes the chosen language as an argument accessible from the chosen template.
    return $this->renderer->render($response, "base.php", [
        "language" => $this->language
    ]);
});
```

Acknowledgements
----------------

[](#acknowledgements)

This project is largely influenced by [SimoTod/slim-multilanguage](https://github.com/SimoTod/slim-multilanguage), which follows the same philosophy but is made for the version 2 of Slim.

TODO
----

[](#todo)

Develop functions to do things such as testing for default language, get current language, compare language, and maybe more.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

2838d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15a765ab869d16b81b0f7c5782e1fef2b9ff8c59f793ec742e5ed0440acc6d68?d=identicon)[dasilvaluis](/maintainers/dasilvaluis)

---

Tags

i10ni18nlanguagemiddlewaremultilanguagemultilanguage-supportmultilingualphpphp-frameworkroutingslimi18nl10nslimmultilingualmultilanguage

### Embed Badge

![Health badge](/badges/luism-s-multilingualslim/health.svg)

```
[![Health](https://phpackages.com/badges/luism-s-multilingualslim/health.svg)](https://phpackages.com/packages/luism-s-multilingualslim)
```

###  Alternatives

[moment/moment

Parse, validate, manipulate, and display dates in JavaScript.

48.0k2.1M40](/packages/moment-moment)[symfony/intl

Provides access to the localization data of the ICU library

2.6k208.8M1.3k](/packages/symfony-intl)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

42411.0M74](/packages/jms-translation-bundle)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[gettext/languages

gettext languages with plural rules

7532.0M12](/packages/gettext-languages)[aplus/language

Aplus Framework Language Library

2371.7M15](/packages/aplus-language)

PHPackages © 2026

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