Download the PHP package gettext-bilal-azzam/gettext without Composer

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

Gettext

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Monthly Downloads License

SensioLabsInsight

Created by Oscar Otero http://oscarotero.com [email protected] (MIT License)

Gettext is a PHP (>=5.4) library to import/export/edit gettext from PO, MO, PHP, JS files, etc.

Installation

With composer (recomended):

If you don't use composer in your project, you have to download and place this package in a directory of your project. You need to install also gettext/languages. Then, include the autoloaders of both projects in any place of your php code:

Classes and functions

This package contains the following classes:

Usage example

If you want use this translations in your php templates without using the gettext extension:

To use this translations with the gettext extension:

The benefits of using the functions provided by this library (__() instead _() or gettext()) are:

Translation

The Gettext\Translation class stores all information about a translation: the original text, the translated text, source references, comments, etc.

Translations

The Gettext\Translations class stores a collection of translations:

Extractors

The extrators allows to fetch gettext values from any source. For example, to scan a .po file:

The better way to use extractors is using the magic methods of Gettext\Translations:

The available extractors are the following:

Name Description Example
Blade Scans a Blade template (For laravel users). example
Csv Gets the messages from csv. example
CsvDictionary Gets the messages from csv (without plurals and context). example
Jed Gets the messages from a json compatible with Jed. example
JsCode Scans javascript code looking for all gettext functions (the same than PhpCode but for javascript). You can use the javascript gettext-translator library example
Json Gets the messages from json compatible with gettext-translator. example
JsonDictionary Gets the messages from a json (without plurals and context). example
Mo Gets the messages from MO. example
PhpArray Gets the messages from a php file that returns an array. example
PhpCode Scans php code looking for all gettext functions (see translator_functions.php). example
Po Gets the messages from PO. example
Twig To scan a Twig template. example
Xliff Gets the messages from xliff (2.0). example
Yaml Gets the messages from yaml. example
YamlDictionary Gets the messages from a yaml (without plurals and context). example
VueJs Gets the messages from a VueJs template. example

Generators

The generators export a Gettext\Translations instance to any format (po, mo, array, etc).

Like extractors, the better way to use generators is using the magic methods of Gettext\Translations:

The available generators are the following:

Name Description Example
Csv Exports to csv. example
CsvDictionary Exports to csv (without plurals and context). example
Json Exports to json, compatible with gettext-translator. example
JsonDictionary Exports to json (without plurals and context). example
Mo Exports to Mo. example
PhpArray Exports to php code that returns an array. example
Po Exports to Po. example
Jed Exports to json format compatible with Jed. example
Xliff Exports to xliff (2.0). example
Yaml Exports to yaml. example
YamlDictionary Exports to yaml (without plurals and context). example

Translator

The class Gettext\Translator implements the gettext functions in php. Useful if you don't have the native gettext extension for php or want to avoid problems with it. You can load the translations from a php array file or using a Gettext\Translations instance:

GettextTranslator

The class Gettext\GettextTranslator uses the gettext extension. It's useful because combines the performance of using real gettext functions but with the same API than Translator class, so you can switch to one or other translator deppending of the environment without change code of your app.

Global functions

To ease the use of translations in your php templates, you can use the provided functions:

You can scan the php files containing these functions and extract the values with the PhpCode extractor:

Merge translations

To work with different translations you may want merge them in an unique file. There are two ways to do this:

The simplest way is adding new translations:

A more advanced way is merge two Translations instances:

The second argument of mergeWith defines how the merge will be done. Use the Gettext\Merge constants to configure the merging:

Constant Description
Merge::ADD Adds the translations from $translations2 that are missing
Merge::REMOVE Removes the translations missing in $translations2
Merge::HEADERS_ADD Adds the headers from $translations2 that are missing
Merge::HEADERS_REMOVE Removes the headers missing in $translations2
Merge::HEADERS_OVERRIDE Overrides the headers with the values of $translations2
Merge::LANGUAGE_OVERRIDE Set the language defined in $translations2
Merge::DOMAIN_OVERRIDE Set the domain defined in $translations2
Merge::TRANSLATION_OVERRIDE Override the translation and plural translations with the value of $translation2
Merge::COMMENTS_OURS Use only the comments of $translation1
Merge::COMMENTS_THEIRS Use only the comments of $translation2
Merge::EXTRACTED_COMMENTS_OURS Use only the extracted comments of $translation1
Merge::EXTRACTED_COMMENTS_THEIRS Use only the extracted comments of $translation2
Merge::FLAGS_OURS Use only the flags of $translation1
Merge::FLAGS_THEIRS Use only the flags of $translation2
Merge::REFERENCES_OURS Use only the references of $translation1
Merge::REFERENCES_THEIRS Use only the references of $translation2

Example:

Note, if the second argument is not defined, the default value is Merge::DEFAULTS that's equivalent to Merge::ADD | Merge::HEADERS_ADD.

Use from CLI

There's a Robo task to use this library from the command line interface: https://github.com/oscarotero/GettextRobo

Use in the browser

If you want to use your translations in the browser, there's a javascript translator: https://github.com/oscarotero/gettext-translator

Third party packages

Twig integration:

Framework integration:

add your package

Contributors

Thanks to all contributors specially to @mlocati.

Donations

If this library is useful for you, consider to donate to the author.

Buy me a beer :beer:

Thanks in advance!


All versions of gettext with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
gettext/languages Version ^2.3
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 gettext-bilal-azzam/gettext contains the following files

Loading the files please wait ....