PHPackages                             vades/php-language - 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. vades/php-language

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

vades/php-language
==================

PHP Language class - This class detects the language (from url, session, cookie and browser) and then sets a current one

217PHP

Since Mar 23Pushed 7y agoCompare

[ Source](https://github.com/vades/php-language)[ Packagist](https://packagist.org/packages/vades/php-language)[ RSS](/packages/vades-php-language/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Language switch PHP class
=========================

[](#language-switch-php-class)

This class detects the language (from url, session, cookie and browser) and then sets a current one

Usage

1. Download --

Git: `https://github.com/vades/php-language.git`

Composer: `{"require": {"vades/php-language": "dev-master"} }`

2. Include class and config into your code --

`require_once '../src/Vades/Language/LanguageSwitch.php';`

`$cfg = require_once '../src/Vades/Language/config.php';';`

`use \Vades\Language\LanguageSwitch;`

OR autoload with Composer

`require 'vendor/autoload.php';`

3. Set values in config file config.php --

Default language: `'default' => 'en'`

Supported languages: `'supported' => array('en','de','fr','es','it')`

4. Initialize the LanguageSwitch -- &lt;?php

    ```
             $switch = new LanguageSwitch(array(
                 'default' => $cfg['default'],
                 'supported' => $cfg['supported'],
                 'url' => $lang_from_url ,
                 'session' => $lang_from_session,
                 'cookie' => $lang_from_ucookie,
                 'browser' => substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)
             ));

      ?>

    ```
5. Use it with method chaining --

    ```

    ```
6. Code snippet --

    ```

    ```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1451741?v=4)[Martin Vach](/maintainers/vades)[@vades](https://github.com/vades)

---

Top Contributors

[![vades](https://avatars.githubusercontent.com/u/1451741?v=4)](https://github.com/vades "vades (9 commits)")

### Embed Badge

![Health badge](/badges/vades-php-language/health.svg)

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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