Download the PHP package iqomp/locale without Composer

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

iqomp/locale

Simple module text translation. This module catch all translation text from all installed composer module with special rule, and make them globally available to use. The purpose of this module is to make it possible each composer module bring their own translation text, and overwrite by application without editing module translation data.

The cache of language is generated during composer update. You can call composer update anytime after updating translation file.

Installation

Configuration

If your composer module has translation, add config as below on the composer.json file of the module:

The extra key should be iqomp/locale, with string value pointing to a folder in module main directory.

All php file inside the folder will be taken and combine with one application make and make them usable globally.

The file name will be used as translation domain.

The extra->iqomp/locale from application composer.json will also loaded.

Translation File

Each translation file should return array of the translation, where the filename is the translation domain, array key is translation key, and the value is translation result with format ICU MessageFormat.

Usage

Use class Iqomp\Locale\Locale to translate the text as below:

Directory Structure

Each translation should follow directory structure as below:

Method

static addLocaleDir(string $path): void

Add custom locale folder to include in translation on the fly. This method make it possible to include dynamic dir in translation database. But it's not recommended as each translation in the folder will not be cached. If your application has translation, add the folder to your application composer.json instead.

static encode(string $text, array $map=[], string $domain=null): string

Encode translation to use on formatter. The map arguments is array key-value pair where key is translation param, and value is the value to use that accept prefix $ to get the value from formatted object.

static fetchTranslation(): void

Re-fetch all translation from cache or from additional locale dir with current active language.

static getAllLanguages(): array

Get all usable language defined by module or application, from cache and additional locale dir.

static getCacheDir(): string

Get currently used translation cache.

static getLanguage(): ?string

Get current used translation language.

static setLanguage(): void

Set active language. This method accept multiple argument that will test for existential of language. If you never call this method, the language will be taken from request header HTTP_ACCEPT_LANGUAGE.

static translate(string $text, array $params=[], string $domain=null): string

Translate the text. If domain is null, it will use random domain.

Formatter

If you're using iqomp/formatter for your object formatter, this module add new format type to use to translate encoded locale map.

Save the encoded locale with encode function above:

Then use the locale format type to translate the encoded translation to current locale request.

Unit Test

Run below script to run unit test:

Linter

Run below script to run psr-12 linter:


All versions of locale with dependencies

PHP Build Version
Package Version
Requires composer-plugin-api Version ^2.0
ext-gettext Version *
ext-intl 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 iqomp/locale contains the following files

Loading the files please wait ....