PHPackages                             mateodioev/multi-lang - 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. mateodioev/multi-lang

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

mateodioev/multi-lang
=====================

A simple PHP class to manage multi-language websites.

v0.4.0(1y ago)1821MITPHP

Since Mar 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Mateodioev/multi-lang)[ Packagist](https://packagist.org/packages/mateodioev/multi-lang)[ RSS](/packages/mateodioev-multi-lang/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (12)Used By (0)

Multi-lang
==========

[](#multi-lang)

A simple package to manage multi-language in your project.

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

[](#installation)

```
composer require mateodioev/multi-lang
```

Usage
-----

[](#usage)

- Create a directory to save your language files, for example `resources/lang`.
- Create a file for each language you want to support, for example `en.json` and `es.json`.

File `en.json`:

```
{
    "english_name": "English",
    "name": "English",
    "data": {
        "welcome": "Welcome {full_name} to our website",
        "goodbye": "Goodbye dear {full_name}"
    }
}
```

File `es.json`:

```
{
    "english_name": "Spanish",
    "name": "Español",
    "data": {
        "welcome": "Bienvenido {full_name} a nuestro sitio web",
        "goodbye": "Adiós querido {full_name}"
    }
}
```

- Configure the dir

```
use Mateodioev\MultiLang\Cache\InMemoryCache;
use Mateodioev\MultiLang\Lang;

$config = \Mateodioev\MultiLang\Config::instance()
    ->withCache(new InMemoryCache()) // Optional;
Lang::setup(
    dir: __DIR__ . '/resources/lang',
    config: $config
);
```

- Format the strings

```
// If the key does not exist it will return null
Lang::get('es')->data('welcome')?->format(['full_name' => 'Mateo']);
// Output: Bienvenido Mateo a nuestro sitio web
```

File format
-----------

[](#file-format)

- `english_name`: The name of the language in English.
- `name`: The name of the language in its own language.
- `data`: The key-value pairs of the language strings.
    - `key`: The key of the string.
    - `value`: The value of the string. You can use placeholders to replace them with values.

> WARNING: If the json file does not contain any of these keys or different data it will give an error.

Validate the files
------------------

[](#validate-the-files)

You can validate the files to check if they have the correct format.

> WARNING: Not use in production. This load and parse all the files

```
Lang::compareData();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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 ~24 days

Recently: every ~52 days

Total

10

Last Release

560d ago

Major Versions

v0.4.0 → v2.x-dev2024-11-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/77e3f2a5c4e98caf6e911141af3d18235c658500e8b9e0a95ec251a803a39676?d=identicon)[Mateodioev](/maintainers/Mateodioev)

---

Top Contributors

[![Mateodioev](https://avatars.githubusercontent.com/u/68271130?v=4)](https://github.com/Mateodioev "Mateodioev (18 commits)")

---

Tags

phpi18nlanguagel10ntranslatetranslationmulti-language

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mateodioev-multi-lang/health.svg)

```
[![Health](https://phpackages.com/badges/mateodioev-multi-lang/health.svg)](https://phpackages.com/packages/mateodioev-multi-lang)
```

###  Alternatives

[gettext/languages

gettext languages with plural rules

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

PHP-Unicode CLDR

1542.9M29](/packages/punic-punic)[fisharebest/localization

A lightweight localization database and translation tools, with data from the CLDR, IANA, ISO, etc.

3191.1k2](/packages/fisharebest-localization)[inpsyde/multilingual-press

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

2414.0k1](/packages/inpsyde-multilingual-press)[delfimov/translate

Easy to use i18n translation PHP class for multi-language websites

1777.1k](/packages/delfimov-translate)[delight-im/i18n

Internationalization and localization for PHP

625.2k3](/packages/delight-im-i18n)

PHPackages © 2026

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