Download the PHP package phpfui/translation without Composer

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

PHPFUI/Translation Tests Latest Packagist release

A simple, fast, and memory efficient translation system for PHP.

Why another translation system? Simply for speed and reduced memory usage. Just under 500 lines of code including comments, this translation system does not have high overhead like other existing systems. Since PHP is an interpreted scripting language, speed and memory usage matter. This library attempts to solve both issues.

Supported Features

Chunked Translation Support

Chunks allow you to break up translations so all translations don't end up in memory at the same time. This is particularly useful for large projects.

Chunks are defined by any translation that starts with a period (.). These are chunked translations:

.save
.cancel
.messages.notFound
.messages.saved
.titles.firstName
.titles.lastName
.person.address.city
.person.address.state
.person.address.postalcode

The first two examples are called base chunks stored in the baseChunks.php file in the locale root directory. All base chunks are always loaded even if not requested, so they should only contain frequently used translations that would normally get loaded. The third through sixth chunks allow you to only load those chunks when required. If your page does not need titles, then the .titles chunk will not be loaded. The entire level of a chunk will be loaded at the same time. So in the last three examples, the .person.address chunk will load when .person.address.city (or state, or postalcode) is accessed.

Any translation that does not start with a period (.) is considered a native language translation and is stored in the native.php file in local root directory. All native chunks are loaded when any native chunk is loaded, except for the base locale, where they are never loaded as an optimization. This means a base locale native translation will never be listed as missing.

File Structure

You must specify a translation directory. Each locale you support will have its own directory within your translation directory. Consult the Tests/translations directory for examples.

Locale Support

Locales can be named anything your file system supports. The locale is the name of the directory in the base translation directory.

Generally you set the base locale, which is the language of your native translations (if you are using them). Then you set the user's locale. Those can be the same.

Reserved Locales for Debugging

Fallback Locale Support

Too keep things as simple as possible, this library does not support falling back to a base locale if a translation is missing. This can be accomplished by preprocessing each locale. Any missing translation can be filled in with a translation from another locale. This library does not provide any support for managing translation files, as that is best left up to the developers if something custom is required. Use the var_export function to write translation files if you automate the process. This will insure your translations are parseable by PHP.

Usage

Parameters

You can pass parameters to substitute in the translation by passing an associate array as the second parameter:

Parameters in the translations should start with a colon (:). A simple str_replace is used to translation the variables, so beware :name and :names will probably not be replaced in the way you might expect. It is best to use unique names where possible.

Pluralization

This library supports pluralization via different sections separated by the vertical bar (|) character. If you need '|' in your text use the HTML entity |

The count variable (:count in the translated text) is used for determining the number of items to pluralize for. It is not required to use :count in the translation, but you can if you desire.

Full Class Documentation

PHPFUI/InstaDoc

License

PHPFUI/Translation is distributed under the MIT License.

PHP Versions

This library only supports modern versions of PHP which still receive security updates. While we would love to support PHP from the late Ming Dynasty, the advantages of modern PHP versions far out weigh quaint notions of backward compatibility. Time to upgrade.


All versions of translation with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4 <8.4
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 phpfui/translation contains the following files

Loading the files please wait ....