Download the PHP package ryanj93/php-locale-kit without Composer

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

PHP Locale Kit

PHP Locale Kit is a simple library that allows to manage language packages based on SQLite3 database. It provide also utilities that allow to translate texts as well as detect their language supporting Google and Yandex as service provider. The package is shipped with a CLI utility that allows to create and translate language packages, for more information and documentation check the file called "cli.md".

Installation

Before installing the package, make sure that the sqlite3 extension is installed, usually this extension is shipped with your PHP installation. To install this package through Composer just run this command:

`

Usage: Package

The class "Package" allows to fetch the labels from the language package, before using it you need, of course, to set up the path to the package and the locale to use, the locale must be supported by the package, you can set a locale and allows to the library to switch to a fallback locale based on the language of the given locale code, for example, if you set "en-US" as locale but the package doesn't support it, the library will look for any locale matching with "en", unless the strict mode is enable, here you are an example:

``

You can get a list of all the supported locales by using the following method:

``

Now you are able to get the labels, you can use the following method passing an array containing the labels' IDs, the IDs can be represented as numbers or strings, according with the package, the labels will be returned as associative array having as key the label ID and as value its text, if a label were not found, it will be omitted, here's the example:

``

Of course you can fetch all the labels from the package using the following method:

``

Usage: Translator

The class "Translator" allows to translate and detect the language of texts, as of now, it support only Google and Yandex as service provider, in order to use it, you need to get an API key from the provider that you are going to use, by default, Yandex is used because it offers a free plan that allows to translate up to 10000000 chars per month, you can get a free API key from Yandex here, here you are the setup example:

``

Now you can translate one or more texts using this method:

``

Note that you can omit the original language, in this case it will be automatically detected by the provider. The translated texts will be returned as associative array having as key the original text and as value the translated one. In a similar way you can detect the language of one or more texts, here you are an example:

``

It will return an associative array having as key the original text and as value the code of the language detected. If you need to get a list of all the languages supported by the service provider you can use the following method:

``

Both the classes support data caching, you can set up cache using these methods:

``

Data caching is provided by the library "php-tiny-cacher", as you can see in the examples, the variable "$cache" is an instance of the class "PHPTinyCacher" that allows to store data using different options such as Redis, Memcached and file. You can find more information about it on its repository on GitHub.

If you like this project and think that is useful don't be scared and feel free to contribute reporting bugs, issues or suggestions or if you feel generous, you can send a donation here.

Are you looking for the Node.js version? Give a look here.


All versions of php-locale-kit with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
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 ryanj93/php-locale-kit contains the following files

Loading the files please wait ....