Download the PHP package samsonos/php_i18n without Composer

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

Internalization(i18n) module for SamsonPHP framework

Module gives uses special global functions to give localization features for a web-application

Module default locale is empty string , its value is stored at constant. This gives ability to use any locale as default without specifying it.

Setting supported locales

For adding localization support to your web-application special global function must be called:

Where parameters are:

Usually this function is called in web-application starter script before , for example :

Switching locales

To switch system to another supported locale(defined by ) you should add locale prefix to url, for example if we have domain we must redirect user to for switching system to localized version. This url suffix is ignored by all SamsonPHP components and actually is invisible in URL dispatcher and in all other components. The only module who handles this suffix is (this module).

If you specify not supported locale suffix (you did not specified it in before SamsonPHP is started), URL dispatcher will handle it as regular module controller request.

Using localized views

When you switch to other supported locale then default locale, automatic system view rendering mechanism is changed. First of all system searches necessary view in localized view path, using default settings, system view path is . localized view path in this case is , where .

So if you want to have separate view files for different locales you can create two view files with the same names, for example we have english view file located at :

And russian view file located at :

Also we have regular simple controller file located at :

And default view template file located at who renders current module:

And if you try to visit URL you will get rendered instead of .

The logic is: If system does not find localized view it will use regular view.

Dictionary localization

If we don't want to create separate views for every supported locale, as they match each other in HTML markup and only differs in some words you can use dictionary localization logic.

For using global dictionary for your web-application , using default settings, you have to create special dictionary file located in with generic special function defined:

Where parameters are:

We use function to avoid bugs when compressing web-application to a snapshot via samsonos/php_compressor

Using dictionary in views

To use dictionary created above in a view view file you should use special global function

Where parameters are:

So if we have view file(or template view file) localized string output will be:

And we don't need to create separate view files for localization.

Automatic dictionary file generation

You can use special controller to perform automatic creation of dictionary file. By default this file will be located at .

When you enter URL system automatically scans all your views/controllers/models for pattern matching function and build key value lists for every locale. So you do not have to create this dictionary manually, you add translation function to your views/controllers/modules and when finished call which will create dictionary file for you, what is left to do is fill in the translation for generated keys.

Don't worry to call several times, it won't rewrite your existing dictionary file, it will analyze it and add only new keys for translation

Generic rendering of supported locales list

We have added generic controller action for this module to simplify of rendering locale switcher in your web-application. In your template view file (or simple view file), for example you can use:

This controller action will render unordered list of supported locales and special CSS class for styling:

This is default LESS example to style this locale switcher file:

Creating multilingual alternate links

For creating alternate links, that shows, which languages you can get in your web-site, you can use following code:

Developed by SamsonOS


All versions of php_i18n with dependencies

PHP Build Version
Package Version
Requires samsonos/php_core Version 1.*
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 samsonos/php_i18n contains the following files

Loading the files please wait ....