PHPackages                             multlang/multlang - 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. multlang/multlang

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

multlang/multlang
=================

PHP - Multi-Language Support

v1.0.4(8y ago)06Apache-2.0

Since Jun 9Pushed 6y agoCompare

[ Source](https://github.com/strausmann/MultLang)[ Packagist](https://packagist.org/packages/multlang/multlang)[ RSS](/packages/multlang-multlang/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (5)Used By (0)

MultLang - PHP Multi-Language Support [![Build Status](https://camo.githubusercontent.com/be977d56ae34a3a3e3ad27d4d77fd946559017a6f8648e824824bd0127fce0f5/68747470733a2f2f7472617669732d63692e6f72672f53746566616e5363686f6d61636b65722f4d756c744c616e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/StefanSchomacker/MultLang)
================================================================================================================================================================================================================================================================================================================================================

[](#multlang---php-multi-language-support-)

Overview
--------

[](#overview)

- All strings are saved in XML files
- Automatic language detection: Methods:
    - [header](#header)
    - [cookie](#cookie)
    - [rewrite](#rewrite)
- Simple string access

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

[](#installation)

It's very simple to include this library in your project.

### Composer

[](#composer)

add this to your `composer.json` and run `composer install`:

```
{
"repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/StefanSchomacker/MultLang"
        }
    ],
    "require": {
        "multlang/multlang": "dev-master"
    }
}
```

### Download Zip

[](#download-zip)

### Clone Git

[](#clone-git)

```
git clone https://github.com/StefanSchomacker/MultLang.git
```

Getting Started
---------------

[](#getting-started)

### Usage

[](#usage)

Just create a config object once and call the load function in your PHP Script.

You can also view the example [here](https://github.com/StefanSchomacker/MultLang/tree/master/example).

***index.php:***

```

```

***/dictionary/default.xml:***

```

    This is a sample text in english

```

***/dictionary/german.xml:***

```

    Das ist ein deutscher Beispieltext

```

### Configuration

[](#configuration)

Edit config values if needed:

constdefault valuedescriptionDOCUMENT\_ROOT`dirname(__DIR__) . DIRECTORY_SEPARATOR`Path to document rootPATH\_TO\_DICTIONARIES`DOCUMENT_ROOT . DIRECTORY_SEPARATOR . 'dictionary' . DIRECTORY_SEPARATOR`Path to dictionary folder. Folder contains all XML filesDEFAULT\_LANGUAGE`en`Default language in ISO 639-1 format. The constant will be used, if language cannot be determinedDEFAULT\_DICTIONARY`default.xml`This XML file will be used, if other files are not available. This file should contain all string items.LANGUAGE\_DETECTION`cookie`This defines the method to detect the language. Choose between **['header'](#header)**, **['cookie'](#cookie)** and **['rewrite'](#rewrite)**.COOKIE\_NAME`language`Default key for the cookie.SUPPORTED\_LANGUAGES`array(DEFAULT_LANGUAGE => DEFAULT_DICTIONARY)`Contains all supported languages.
 Example: `"de" => "german.xml",`Example:

```

```

Language detection methods
--------------------------

[](#language-detection-methods)

### header

[](#header)

This will try to read `$_SERVER['HTTP_ACCEPT_LANGUAGE']`. If this fails, `DEFAULT_LANGUAGE` will be returned.

### cookie

[](#cookie)

This will try to read a cookie with the key `COOKIE_NAME`. If no cookie is set, it will use the [header](#header) method and set the new cookie.

### rewrite

[](#rewrite)

This will try to read `$_SERVER['REQUEST_URI']` and split it to identify the language. If no argument is set, it will use the [header](#header) method
You can use a URL structure like **example.com/`en`/index.php**

Details
-------

[](#details)

- The used language format is ISO 639-1. For more information see [https://en.wikipedia.org/wiki/ISO\_639-1](https://en.wikipedia.org/wiki/ISO_639-1)
- If the requested string is not available in the XML file, the script will try to search in the `DEFAULT_DICTIONARY` (default.xml) file. An empty string will be returned if nothing matches.

Improvements
------------

[](#improvements)

Feel free to create a new [Issue](https://github.com/StefanSchomacker/MultLang/issues) or a [Pull request](https://github.com/StefanSchomacker/MultLang/pulls)

License
-------

[](#license)

```
Copyright 2019 Stefan Schomacker

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

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

Total

2

Last Release

3112d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bf273e1a56dfb307036fa63958f4e4244f28ba9e1389c757d80fccccc1c62fb?d=identicon)[strausmann](/maintainers/strausmann)

---

Top Contributors

[![StefanSchomacker](https://avatars.githubusercontent.com/u/14841528?v=4)](https://github.com/StefanSchomacker "StefanSchomacker (52 commits)")

### Embed Badge

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

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

###  Alternatives

[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)[inpsyde/multilingual-press

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

2414.0k1](/packages/inpsyde-multilingual-press)[statikbe/laravel-chained-translator

The Laravel Chained Translator can combine several translators that can override each others translations.

36149.4k6](/packages/statikbe-laravel-chained-translator)

PHPackages © 2026

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