PHPackages                             deepskylog/multilingual-language-list - 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. deepskylog/multilingual-language-list

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

deepskylog/multilingual-language-list
=====================================

Lookup Objects for Language Names and Codes

1.15.2(5y ago)1216MITPHPPHP ^7.2

Since Apr 30Pushed 5y agoCompare

[ Source](https://github.com/DeepskyLog/Multilingual-Language-List)[ Packagist](https://packagist.org/packages/deepskylog/multilingual-language-list)[ Docs](https://github.com/petercoles/multilingual-language-list)[ RSS](/packages/deepskylog-multilingual-language-list/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (3)Versions (9)Used By (0)

Multilingual Language Lists for Laravel
=======================================

[](#multilingual-language-lists-for-laravel)

[![SensioLabsInsight](https://camo.githubusercontent.com/322064bb7a0f168655b0b6e9b2540c5a6764b6bb0ddb93c179d2172f51fe9bb3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63316564626137382d646133392d343436352d623533622d3336326538663066386636622f6d696e692e706e67)](https://insight.sensiolabs.com/projects/c1edba78-da39-4465-b53b-362e8f0f8f6b)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/f62cd5b0d7b737c47268181ab278902ad81b77e51697f5036d2c2666ce4fade0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7065746572636f6c65732f4d756c74696c696e6775616c2d4c616e67756167652d4c6973742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/petercoles/Multilingual-Language-List/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/8b82c2dbb030f2a5f5d6ccef08d43c1b6836d231ba59e618954c25fb158e5a06/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7065746572636f6c65732f4d756c74696c696e6775616c2d4c616e67756167652d4c6973742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/petercoles/Multilingual-Language-List/?branch=master)[![Build Status](https://camo.githubusercontent.com/9c56107b1f1bcf20ff1d24a4c96b0544df7d02fe655a9cdabde71709045b4936/68747470733a2f2f7472617669732d63692e6f72672f7065746572636f6c65732f4d756c74696c696e6775616c2d4c616e67756167652d4c6973742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/petercoles/Multilingual-Language-List)[![License](https://camo.githubusercontent.com/e498eead712d82d9ee1af0a4850acd2e46ea48c48fb9ce5a3d2ab64f28f95b34/687474703a2f2f696d672e736869656c64732e696f2f3a6c6963656e73652d6d69742d626c75652e737667)](http://doge.mit-license.org)

Introduction
------------

[](#introduction)

Over the years, many of the projects I've worked on have resulted in multilingual sites. During that time the number of languages typically supported has increased and the sensitivty to the importance of dialectical differences has improved, which are good things.

The purpose of this package is to make managing language lists, such as those used in language pulldowns or form select fields easier to generate via a simple API that gives access to an industry-maintained list.

Data can be returned as a lookup array or an array of key-value pairs, where both the key and value labels can be set according to the needs of the software consuming them.

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

[](#installation)

At the command line run

```
composer require deepskylog/multilingual-language-list
```

If you're using Laravel 5.5 or later (and haven't disabled package discovery), you're done. Move on to the usage section below.

If you're using an older version of Laravel, then add the service provider to the providers entry in your config/app.php file

```
    'providers' => [
        // ...
        DeepskyLog\Languages\LanguagesServiceProvider::class,
        // ...
    ],
```

An optional facade is also available and can be enabled by adding the following to you config/app.php's aliases array

```
'Languages' => DeepskyLog\Languages\LanguagesFacade::class,
```

Usage
-----

[](#usage)

Once installed the package exposes two API methods: lookup() and keyValue(), each of which returns a list of countries ordered by the country name in the language being used.

### Lookup

[](#lookup)

The `lookup` method takes three optional parameters and returns a collection.

- $filter determines which languages are to be included in the response. It defaults to "major", which will cause a list of only those languages with a two letter code to be returned (e.g. fr - French). Other options are "minor" which will add languages with three letter codes (e.g. arw - Arawak) and "all", which is not recommended and will return every possible entry including some dialects (e.g. es\_MX - Mexican Spanish) and constructs (e.g. es\_419 - Latin American Spanish).
- $locale determines the language and dialect in which the response will be returned. Locales can be languages (e.g. fr - French), dialects (e.g. fr\_CA - Canadian French) and specials (e.g. bs\_Cryl\_BA - cryllic script for the dialect of Bosnian from Bosnia and Herzegovina or zh\_Hans\_HK - Simplified Chinese for the Hong Kong Dialect). They look rather like languages, but are more nuanced, i.e. there's a whole lot more of them.
- $flip to switch the key and value for the response array so that the language name becomes the key and the language code becomes the value.

The resulting collection will be cast to a json object by Laravel if returned as a response, or can be cast to an array if needed with the toArray() method.

#### Example: Default settigs

[](#example-default-settigs)

```
Languages::lookup();

// returns

{
  "ab": "Abkhazian",
  ...
  "zu": "Zulu"
}
```

#### Example: Limiting the languages displayed

[](#example-limiting-the-languages-displayed)

```
Languages::lookup(['en', 'fr', 'de']);

// returns

{
  "en": "English",
  "fr": "French",
  "de": "German"
}
```

#### Example: Changing the display language

[](#example-changing-the-display-language)

```
Languages::lookup(['en', 'fr', 'de'], 'fr');

// returns

{
  "de": "allemand",
  "en": "anglais",
  "fr": "français"
}
```

#### Example: Reverse lookups

[](#example-reverse-lookups)

```
Languages::lookup(['en', 'fr', 'de'], 'fr', true);

// returns

{
  "allemand": "de",
  "anglais": "en",
  "français": "fr"
}
```

#### Example: Non-latin character sets are supported too

[](#example-non-latin-character-sets-are-supported-too)

```
Languages::lookup(['en', 'fr', 'de', 'bs'], 'bs_Cyrl');

// returns

{
  "bs": "босански",
  "en": "енглески",
  "de": "немачки",
  "fr": "француски"
}
```

### keyValue

[](#keyvalue)

The `keyValue` method takes four optional parameters:

- $filter - default "major". See lookup section for full explanation
- $locale - default "en". See lookup section for full explanation
- $key - default "key"
- $value - default "value"

#### Example: Default settings

[](#example-default-settings)

```
Languages::keyValue();

// returns

[
  {"key": "ab", "value": "Abkhazian"},
  {"key": "aa", "value": "Afar"},
  ...
  {"key": "za", "value": "Zhuang"},
  {"key": "zu", "value": "Zulu"}
]
```

#### Example: Include "minor" languages

[](#example-include-minor-languages)

```
Languages::keyValue('minor');

// returns

[
  {"key": "ab", "value": "Abkhazian"},
  {"key": "ace", "value": "Achinese"},
  {"key": "ach", "value": "Acoli"},
  ...
  {"key": "gbz", "value": "Zoroastrian Dari"},
  {"key": "zu", "value": "Zulu"},
  {"key": "zun", "value": "Zuni"}
]
```

#### Example: The kitchen sink - custom list, in non-Latin language with custom indices

[](#example-the-kitchen-sink---custom-list-in-non-latin-language-with-custom-indices)

```
Languages::keyValue(['en', 'ja', 'zh'], 'zh', 'label', 'text');

// returns

[
  {"label": "ja", "text": "日文"},
  {"label": "en", "text": "英文"},
  {"label": "zh", "text": "中文"}
]
```

### Mixed Locales

[](#mixed-locales)

Sometimes you might want to display a list of languages where each language is expressed in its own language and writing system e.g. one list with French as français, Japanese as 日本語 and Russian as русский. If so, we've got you covered.

By using the special "mixed" locale as the second parameter and a custom array as the first, the languages in that custom array will each be rendered in their own localised form, in the order given in the first parameter.

#### Example: lookup

[](#example-lookup)

```
Languages::lookup(['en', 'fr', 'de', 'ja', 'ru', 'zh'], 'mixed');

// returns

{
  "en": "English",
  "fr": "français",
  "de": "Deutsch",
  "ja": "日本語",
  "ru": "русский",
  "zh": "中文",
}
```

#### Example: key-value

[](#example-key-value)

```
Languages::keyValue(['en', 'fr', 'de', 'ja', 'ru', 'zh'], 'mixed');

// returns

[
  {"key" => "en", "value" => "English"},
  {"key" => "fr", "value" => "français"},
  {"key" => "de", "value" => "Deutsch"},
  {"key" => "ja", "value" => "日本語"},
  {"key" => "ru", "value" => "русский"},
  {"key" => "zh", "value" => "中文"}
]
```

As seen above, the mixed locale parameter can be used for generating lookups or key-value objects. The $flip, $key and $value parameters continue to work for the relevant list type in the same way as shown in the earlier sections.

Issues
------

[](#issues)

This package was developed to meet a specific need and then generalised for wider use. If you have a use case not currently met, or see something that appears to not be working correctly, please raise an issue at the [github repo](https://github.com/petercoles/countries/issues).

License
-------

[](#license)

This package is licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% 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 ~228 days

Recently: every ~271 days

Total

8

Last Release

2067d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6.0

1.15PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/124a706a357822e63256d9491fda2cd660d17fd4cd26fe1332cb3f0c9d1c560c?d=identicon)[deepskywim](/maintainers/deepskywim)

---

Top Contributors

[![petercoles](https://avatars.githubusercontent.com/u/2947594?v=4)](https://github.com/petercoles "petercoles (31 commits)")[![WimDeMeester](https://avatars.githubusercontent.com/u/7261529?v=4)](https://github.com/WimDeMeester "WimDeMeester (1 commits)")

---

Tags

laravellanguage listslanguage lookuplanguage codes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/deepskylog-multilingual-language-list/health.svg)

```
[![Health](https://phpackages.com/badges/deepskylog-multilingual-language-list/health.svg)](https://phpackages.com/packages/deepskylog-multilingual-language-list)
```

###  Alternatives

[barryvdh/laravel-translation-manager

Manage Laravel Translations

1.7k3.6M17](/packages/barryvdh-laravel-translation-manager)[kkomelin/laravel-translatable-string-exporter

Translatable String Exporter for Laravel

3291.4M10](/packages/kkomelin-laravel-translatable-string-exporter)[petercoles/multilingual-language-list

Lookup Objects for Language Names and Codes

41309.3k](/packages/petercoles-multilingual-language-list)[vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains or route prefixes.

109554.8k3](/packages/vluzrmos-language-detector)[opgginc/codezero-laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

2770.1k1](/packages/opgginc-codezero-laravel-localized-routes)[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)

PHPackages © 2026

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