Download the PHP package whitecube/lingua without Composer

On this page you can find all versions of the php package whitecube/lingua. 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 lingua

Lingua - Language Codes Converter

Travis Test Coverage GitHub release Packagist GitHub issues GitHub pull requests license

This package will convert languages from and to some common formats (ISO codes, W3C standards, PHP localization strings), including human-readable strings.

Installation

composer require whitecube/lingua

Content

The package currently supports over 220 languages. Most living languages are included, with country codes, names and possible alphabet sets (Latin, Cyrillic, Arabic, ...).

Available input and output formats are:

  1. name: The english name of the language (most of the time).
  2. native: The autonym of the language.
  3. ISO-639-1: The official two-letter code for the language. Some languages do not have this code.
  4. ISO-639-2t: An official three-letter code for terminology applications (ISO 639-2/T) for the language.
  5. ISO-639-2b: An official three-letter code for bibliographic applications (ISO 639-2/B) for the language.
  6. ISO-639-3: The official three-letter code. This is also the most common terminology and therefore the most complete language representation. In most cases, this is the same format as ISO-639-2t, except for macrolanguages.
  7. W3C: A valid string as described by the BCP 47 specification (used in the W3C's language attributes recommendations).
  8. PHP: A string with the appropriate format for PHP's setlocale(). This does not check if the locale is available on your server.

Note on macrolanguages: The ISO-639-3 output will also indicate the amount of sub-languages represented with the same ISO code.

Usage

The Lingua converter works in two stages: first you'll need to instantiate it by providing the original format, than you can convert this string as many times as you want to any of the available formats.

Note: you can instanciate some languages with their deprecated ISO code. For example, you can instanciate Hebrew with the ISO 639_1 code "iw" instead of "he".

Setters

Formatting

Default formatting

Lingua instances can be automatically transformed to strings without calling any formatting method.

The default format is set to w3c, this means you can use Lingua instances as strings and the toW3C() method will be called out of the box.

You can change this default behavior by calling the static setFormat method. Available formats are: name, native, iso-639-1, iso-639-2t, iso-639-2b, iso-639-3, w3c and php.

Additionally it is also possible to specify a desired format during the instantiation of Lingua. This will always ignore the default formatting, even if you just called the static setFormat method.

This behavior is also possible with the static create methods. You can specify the desired formatting as second parameter.

Registering custom languages

Sometimes you'll want to add new languages to the built-in languages repository in order to recognize them later on. Of course, if said languages should be added to the package, you should consider contributing to this repo. In the meantime you can also add them from your code thanks to the LanguagesRepository::register() method.

This will not modify the ./languages.php file! Registered languages are only stored in memory.

Contributing

Your help is precious in order to make this package more accurate! You can contribute on two levels.

Working on core features

In order to add new features, only well-documented and tested pull-requests will be accepted.

Please open or comment existing issues on this repository in order to report bugs. If you're sure about what you're doing, you can send a pull-request.

Maintaining the languages repository

There are currently some languages marked with a // TODO comment in the ./languages.php file. This means we probably didn't find enough information about these languages. You know how to fill the gaps? Please let us know! You can open an issue, make a pull-request or contact us on any available platform.

And of course you can also add new languages to the repository, but only if you're sure about the terminology.

Please beware that changing some existing values in the languages.php file can result in some PHPUnit test failures, so make sure to run the tests and update them accordingly before submitting your changes.

Thank you!

💖 Sponsorships

If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.


All versions of lingua with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
ext-mbstring Version *
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 whitecube/lingua contains the following files

Loading the files please wait ....