Download the PHP package sroehrl/php-i18n-translate without Composer

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

PHP i18n translate

Straight forward. Convenient. Fast.

Build Coverage php vegan Maintainability

Installation

composer require sroehrl/php-i18n-translate

Quick start:

1. In Code

Outputs:

2. In HTML

main.html

Outputs:

Table of Contents

Initialization

$t = new I18nTranslate(string $locale = null, string $clientTimezone = null)

You can initialize either with or without a ISO-locale (e.g. 'en-US'). If no value is provided, the class first tries to set the locale by the ACCEPT_LANGUAGE header and if that fails defaults to "en-US". If you don't pass a $clientTimeZone (e.g. 'Europe/Paris'), then a guess is made based on the locale. This can potentially lead to time offsets in countries with multiple timezones.

TIPS:

Timezones: There are several "timezone-guessing" mechanisms around. Using JavaScript is usually the most reliable way.

Settings: When dealing with internationalization, setting your server & database to UTC is a battle-tested approach.

Setting up translations

Whether you read your translations from a database or a file: gettext is not required, and you are expected to run the method setTranslations for every language you support.

$t->setDebug(true)

Will output a missing key message when a translation isn't set, rather than the following default behavior. This can be useful while developing/translating.

About locale-translations: The decision to ignore the country-specification on the locale on translations is intended. While formatting reacts to the differences of country localisation, translations do not. Example en-US vs. en-EN: the date formatting will react to these differences, but translations like 'color' <=> 'colour' are not supported.

Time, Date, Currencies & Numbers

This package includes a formatter for currencies, numbers and dates. If you want to use its functionality outside of an HTML template, you can initialize it yourself.

The following converters are at your disposal:

In most scenarios the templating attributes will be sufficient to handle your needs:

For a better understanding of how to pass values to your HTML, read here

Time & Date formats

This package uses the Intl-extension for PHP but has a fallback mechanisms. If you do not have Intl installed, localized transformation does not work.

Date & Time inputs are interpreted either as UNIX timestamps or strings supported by PHP's strtotime function.

Date & Time formats accepts strings in the format of ISO8601 date format So not PHP's date notation

I kindly ask contributors to find an appropriate list. Until then, this dated Zend list is the best I could find: formats

Default fallback formats:

Metric Imperial
date dd.MM.Y MM/dd/Y
time HH:mm hh:mm A z

Numbers and currencies work with or without the Intl-extension, but might not conform to the ISO 8601 standard without the Intl-extension.

The examples at Quick Start should help.

Using i18nTranslate with version 2+ of the neoan3-apps/template engine.

Under the hood this package interprets html-files with the help of neoan3-apps/template. It is therefore already available to you once you installed this package. The following setup allows the template engine to run PRIOR to translations, making dynamic formats and values possible:

test.html

Example-output:

Placeholders & Dynamic values

Placeholders are written embraced by [% ans %] (e.g. [% my-var %]). They enable dynamic values within a translation.

... or when using template values:

Attributes as functions

When using the attributes within t-tags as functions, they can be referenced as follows:

CONTRIBUTION

rules


All versions of php-i18n-translate with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
ext-dom Version *
neoan3-apps/template Version ^2.0
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 sroehrl/php-i18n-translate contains the following files

Loading the files please wait ...