Documentation

BladeOneLang

Trait BladeOneLang It adds the next tags <code> select: @ _e('hello') @ _n('Product','Products',$n) @ _ef('hello %s',$user) </code>

Tags
version
1.1

2019-08-09

link
https://github.com/EFTEC/BladeOne
copyright

2017 Jorge Patricio Castro Castillo MIT License. Don't delete this comment, its part of the license.

deprecated

Note: It is not needing anymore (BladeOne already includes the same functionalities). It is keep for compatibility purpose.

Table of Contents

$dictionary  : array<string|int, mixed>
$missingLog  : string
_e()  : string
Tries to translate the word if its in the array defined by BladeOneLang::$dictionary If the operation fails then, it returns the original expression without translation.
_ef()  : string
Its the same than @_e, however it parses the text (using sprintf).
_n()  : string
if num is more than one then it returns the phrase in plural, otherwise the phrase in singular.
compile_e()  : string
Used for @_e directive.
compile_ef()  : string
Used for @_ef directive.
compile_n()  : string
Used for @_n directive.
missingTranslation()  : mixed
Log a missing translation into the file $this->missingLog.<br> If the file is not defined, then it doesn't write the log.

Properties

$dictionary

public static array<string|int, mixed> $dictionary = []

Hold dictionary of translations

$missingLog

public string $missingLog = ''

The path to the missing translations log file. If empty then every missing key is not saved.

Methods

_e()

Tries to translate the word if its in the array defined by BladeOneLang::$dictionary If the operation fails then, it returns the original expression without translation.

public _e( $phrase) : string
Parameters
$phrase :
Return values
string

_ef()

Its the same than @_e, however it parses the text (using sprintf).

public _ef( $phrase) : string

If the operation fails then, it returns the original expression without translation.

Parameters
$phrase :
Return values
string

_n()

if num is more than one then it returns the phrase in plural, otherwise the phrase in singular.

public _n(string $phrase, string $phrases, int $num) : string

Note: the translation should be as follow: $msg['Person']='Person' $msg=['Person']['p']='People'

Parameters
$phrase : string
$phrases : string
$num : int
Return values
string

compile_e()

Used for @_e directive.

protected compile_e( $expression) : string
Parameters
$expression :
Return values
string

compile_ef()

Used for @_ef directive.

protected compile_ef( $expression) : string
Parameters
$expression :
Return values
string

compile_n()

Used for @_n directive.

protected compile_n( $expression) : string
Parameters
$expression :
Return values
string

missingTranslation()

Log a missing translation into the file $this->missingLog.<br> If the file is not defined, then it doesn't write the log.

private missingTranslation(string $txt) : mixed
Parameters
$txt : string

Message to write on.

Return values
mixed

Search results