Download the PHP package bayfrontmedia/translation without Composer

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

Translation

A PHP translation library utilizing multiple language storage options.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

Installation

Usage

NOTE: It is up to you to populate the translation data, no matter where it is stored. This library simply reads the existing data from its source.

Storage adapter

A Bayfront\Translation\ApadpterInterface must be passed to the Bayfront\Translation\Translate constructor. There are a variety of storage adapters available, each with their own required configuration.

Defined array

The defined array adapter allows you to use a predefined array containing all of your translations.

Local

The local adapter allows you to use local native PHP files containing all of your translation arrays.

The file structure from the root path should be:

For example, if the locale is set as en, the method say('dashboard.greeting') will search for the file /root_path/en/dashboard.php, and the array key greeting.

Example dashboard.php:

PDO

The PDO adapter allows you to use a \PDO instance for language retrieval from a database, and may throw a Bayfront\Translation\AdapterException exception in its constructor.

To create a compatible table, execute the following statement:

This table structure ensures only one row exists with a matching locale and id. The contents column should contain a JSON encoded array.

The PDO adapter will create/use a table named "translations" unless otherwise specified in the constructor.

Start using Translation

Once your adapter has been created, it can be used with Translation. In addition, a string defining the locale should be passed to the constructor.

The last argument is true by default. When true, if a translation is not found and $default = NULL, the original string is returned. If false, a Bayfront\Translation\TranslationException is thrown.

Public methods


getLocale

Description:

Get locale.

Parameters:

Returns:

Example:


setLocale

Description:

Set locale.

Parameters:

Returns:

Example:


getTranslations

Description:

Return array of all known translations.

Translations are only "known" once their ID has been used, or they have been added via the addTranslations method.

Parameters:

Returns:

Example:


addTranslations

Description:

Add translations to the known translations for the current request only.

Parameters:

Returns:

Example:


get

Description:

Return the translation for a given string.

The string format is: id.key. Keys are in array dot notation, so they can be as deeply nested as needed.

Replacement variables should be surrounded by {{ }} in the original string.

If a translation is not found and $default = NULL, either the original string is returned, or a TranslationException is thrown, depending on the setting chosen in the constructor.

Parameters:

Returns:

Throws:

Example:


say

Description:

Echos the translation for a given string.

Parameters:

Returns:

Throws:

Example:


replace

Description:

Replace case-sensitive values in a string.

Parameters:

Returns:

Example:


replaceAll

Description:

Replace multiple case-sensitive values in a string with a single replacement.

Parameters:

Returns:

Example:


All versions of translation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
bayfrontmedia/php-array-helpers Version ^2.0
ext-pdo Version *
ext-json 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 bayfrontmedia/translation contains the following files

Loading the files please wait ....