PHPackages                             gokhankurtulus/multilanguage - 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. gokhankurtulus/multilanguage

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

gokhankurtulus/multilanguage
============================

A simple PHP library for multi-language projects.

1.0.0(2y ago)0111MITPHPPHP ^8.0 || ^8.1 || ^8.2

Since Dec 31Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (1)

MultiLanguage
=============

[](#multilanguage)

[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/d4b5fa4adf514144779a7864904c5e15236c0e798635240c7f6ce9a455657b80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c75652e737667)](https://camo.githubusercontent.com/d4b5fa4adf514144779a7864904c5e15236c0e798635240c7f6ce9a455657b80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d626c75652e737667)[![Release](https://camo.githubusercontent.com/e1d8077be80c811b9a481c88bd249c20b591743298117c0fb83b91ebd07ab425/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f676f6b68616e6b757274756c75732f6d756c74696c616e67756167652e737667)](https://camo.githubusercontent.com/e1d8077be80c811b9a481c88bd249c20b591743298117c0fb83b91ebd07ab425/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f676f6b68616e6b757274756c75732f6d756c74696c616e67756167652e737667)

A simple PHP library for multi-language projects.

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

[](#installation)

You can install the library using Composer. Run the following command:

```
composer require gokhankurtulus/multilanguage
```

Usage
-----

[](#usage)

You need to create a directory first and create the desired languages in this directory in JSON format. Example JSON files are provided below.

Example Hierarchy

```
project
   ├── Lang
   │    ├── de.json
   │    ├── en.json
   │    └── tr.json
   └── index.php

```

en.json

```
{
  "Hello": "Hello #name# $lastname$",
  "Homepage": "Homepage"
}
```

tr.json

```
{
  "Hello": "Selam #name# $lastname$",
  "Homepage": "Anasayfa"
}
```

de.json

```
{
  "Hello": "Hallo #name# $lastname$",
  "Homepage": "Startseite"
}
```

index.php

```
use MultiLanguage\MultiLanguage;

MultiLanguage::setDirectoryPath(__DIR__ . DIRECTORY_SEPARATOR . "Lang");
MultiLanguage::setAllowedLanguages(["en", "tr", "de"]);
MultiLanguage::setDefaultLanguage("en");
MultiLanguage::setCurrentLanguage("tr");

// Output will be "Homepage" because $lang parameter is set to 'en'.
// If $lang is null or empty tries to get current language
// if current is not defined then tries to get default language
// if both not defined and $lang is not given throws an LanguageException
echo MultiLanguage::translate('Homepage', 'en');

// Output will be "Anasayfa" because current language is 'tr'.
echo MultiLanguage::translate('Homepage');

// Output will be "Hallo John Doe".
// Specify unique keys in the language file then you can manipulate them.
// In this example, if your key is located many places in string it will change all of them.
echo MultiLanguage::translate('Hello', 'de', ['#name#' => 'John', '$lastname$' => 'Doe']);
```

### Public Methods

[](#public-methods)

```
MultiLanguage::translate(string  $text, ?string $lang = null, array $replacement = []);

MultiLanguage::getDirectoryPath();
MultiLanguage::setDirectoryPath(string $directoryPath, bool $force = false);

MultiLanguage::getAllowedLanguages();
MultiLanguage::setAllowedLanguages(array $languages);
MultiLanguage::isAllowedLanguage(string $lang);

MultiLanguage::getDefaultLanguage();
MultiLanguage::setDefaultLanguage(string $lang);

MultiLanguage::getCurrentLanguage();
MultiLanguage::setCurrentLanguage(string $lang);
```

License
-------

[](#license)

MultiLanguage is open-source software released under the [MIT License](LICENSE). Feel free to modify and use it in your projects.

Contributions
-------------

[](#contributions)

Contributions to MultiLanguage are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request on the [GitHub repository](https://github.com/gokhankurtulus/multilanguage).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

867d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7a8dc07ce25345005f0d5c4e7eb9b9dc7348c25f9fe09375dcfe6950404f7e06?d=identicon)[gokhankurtulus](/maintainers/gokhankurtulus)

---

Top Contributors

[![gokhankurtulus](https://avatars.githubusercontent.com/u/43145716?v=4)](https://github.com/gokhankurtulus "gokhankurtulus (6 commits)")

---

Tags

multi-languagemultilanguagemulti-language

### Embed Badge

![Health badge](/badges/gokhankurtulus-multilanguage/health.svg)

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

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[delfimov/translate

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

1777.1k](/packages/delfimov-translate)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

3812.2k](/packages/erag-laravel-lang-sync-inertia)[orkhanahmadov/spreadsheet-translations

Spreadsheet translations for Laravel

225.9k](/packages/orkhanahmadov-spreadsheet-translations)

PHPackages © 2026

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