Download the PHP package petercoles/multilingual-language-list without Composer

On this page you can find all versions of the php package petercoles/multilingual-language-list. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package multilingual-language-list

Multilingual Language Lists for Laravel

SensioLabsInsight Scrutinizer Code Quality Code Coverage Build Status License

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 sensitivity 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

At the command line run

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

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

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

The method takes three optional parameters and returns a collection.

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: Limiting the languages displayed

Example: Changing the display language

Example: Reverse lookups

Example: Non-latin character sets are supported too

keyValue

The method takes four optional parameters:

Example: Default settings

Example: Include "minor" languages

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

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: key-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.

Example: Find all possible mixed language candidates

Each locale file contains (currently) almost 600 language names expressed in that locale. However, the presence of a language in each locale file does not mean that the inverse is true, i.e. many of the languages do not have a locale file, though some have many locale files. That probably needs an example.

In addition to basic English locale file en.php, there are locale files for many variants of English (over 100 in fact). Each of those contains the English names for almost 600 languages, with slight variations where they have different names in different parts of the world. The first language in each of these locales is Abkhazian. However there is no locale file for Abkhazian so we don't know what "English" is in Abkhazian, or even how the Abkhazian language refers to itself, so it's not possible to include it in a list of mixed languages.

The list of languages that can be used will change over time, and could change each time the data is updated. Here's how you can generate a list of the currently feasible candidates.

Firstly obtain an array of the major languages (there is no locale data available for "minor" languages)

Then lookup these languages using the "parameter" which will filter out languages for which there is no locale file.

A word of caution however, generating this requires a lot of filesystem reads, so I recommend that you not call this every time you want to use the list and instead use Laravel's outstanding Caching system to persist the results for use in your live system.

If you don't personally read all 184 (current) candidate languages and want a list that you can understand (e.g. to remove obscure or irrelevant ones), simply feed the keys for the list back into the lookup method and specify the language of your choice:

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.

Contributions

Contributions are welcome, but will generally need tests. I recommend raising an issue first so that proposed changes or enhancements can be discussed before development starts.

License

This package is licensed under the MIT license.


All versions of multilingual-language-list with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
illuminate/support Version ~5|~6|~7|~8|~9|~10|~11
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package petercoles/multilingual-language-list contains the following files

Loading the files please wait ....