Orpheus

_loader.php

Initernationalization library Translation plugin using ini files Require declaration of constants: LANG_FOLDER, DEFAULT_LOCALE.

Tags
author

Florent HAZARD f.hazard@sowapps.com

Table of Contents

Functions

t()  : string
Translate a key
tn()  : string|null
Translate a key allowing null value (if not found)
_t()  : void
Display t()
parseNumber()  : float
Convert a localized string number into a programming one
sanitizeNumber()  : float
formatCurrency()  : string
Format money by currency and using a number formatter
formatNumber()  : string
Format a number using locale

Functions

t()

Translate a key

t(string $key[, string|array<string|int, mixed>|null $domain = 'global' ][, array<string|int, mixed> $parameters = [] ]) : string
Parameters
$key : string

The Key to translate, prefer to use an internal language (English CamelCase).

$domain : string|array<string|int, mixed>|null = 'global'

The domain to apply the Key. Default value is 'global'.

$parameters : array<string|int, mixed> = []

The values array to replace in text. Could be used as second parameter.

Return values
string

The translated human text.

This function try to translate the given key, in case of failure, it just returns the Key. It tries to replace $values in text by key using #key# format using str_replace() but if $values is a list of values, it uses sprintf(). $values allows 3 formats:

  • array('key1'=>'value1', 'key2'=>'value2'...)
  • array(array('key1', 'key2'...), array('value1', 'value2'...))
  • array('value1', 'value2'...) This function is variadic, you can specify values with more scalar arguments.

Examples: t('untranslatedString', 'aDomain'), t('My already translated string'), t('untranslatedString', 'global', array('key1'=>'val1')), t('untranslatedString', 'global', 'val1', 60)

tn()

Translate a key allowing null value (if not found)

tn(string $key[, string|array<string|int, mixed>|null $domain = 'global' ][, array<string|int, mixed> $parameters = [] ]) : string|null
Parameters
$key : string
$domain : string|array<string|int, mixed>|null = 'global'
$parameters : array<string|int, mixed> = []
Return values
string|null

_t()

Display t()

_t(string $key[, string|array<string|int, mixed> $domain = 'global' ][, array<string|int, mixed> $parameters = [] ]) : void
Parameters
$key : string

The Key to translate, prefer to use an internal language (English CamelCase).

$domain : string|array<string|int, mixed> = 'global'

The domain to apply the Key. Default value is 'global'.

$parameters : array<string|int, mixed> = []
Tags
see
t()
deprecated

Use echo t()

parseNumber()

Convert a localized string number into a programming one

parseNumber(string $value) : float
Parameters
$value : string
Return values
float

sanitizeNumber()

sanitizeNumber(string $value) : float
Parameters
$value : string
Tags
deprecated

Use parseNumber()

Return values
float

formatCurrency()

Format money by currency and using a number formatter

formatCurrency(float $value, string $currency[, bool|int $decimals = true ]) : string
Parameters
$value : float
$currency : string
$decimals : bool|int = true

Decimals or true for 2, false for 0

Return values
string

formatNumber()

Format a number using locale

formatNumber(int|float $value[, int $decimals = 0 ]) : string
Parameters
$value : int|float
$decimals : int = 0
Return values
string

							
On this page

Search results