Phpxforms documentation

Translator
in package

Load localization form file or database 2 translation modes - through "Define" or Translation class with global __()

Tags
author

DaVee

version
0.87dev
license

Lesser General Public License 2.1 or later; see http://www.gnu.org/licenses/lgpl-2.1.html

Table of Contents

Properties

$dir  : string
$mode  : string
$modeDefine  : bool
$current  : string
$db  : SQL
$missing  : array<string, string>|null
$words  : array<string, string>

Methods

__construct()  : mixed
__destruct()  : mixed
Add unknown phrases to lang pools
isTranslated()  : bool
Check if word is defined
translate()  : string
Translate word
chooseLoader()  : void
Choose translation method
createTranslator()  : void
initGlobal()  : void
init Global function
loadDB()  : void
Load words from database
loadFile()  : void
Load file with Define
loadGettext()  : void
Load GETTEXT language pack path: $directory/$locale/LC_$domain/$domain.mo
loadJson()  : void
Load json file

Properties

$dir

public static string $dir = 'locale/'

Directory

$mode

public string $mode = null

Current translator mode (db / gettext / json / define)

$modeDefine

public static bool $modeDefine = false

Dictionary mode

$db

protected SQL $db

Connection to db, keeps only if db and update are used

$missing

protected array<string, string>|null $missing = null

$words

protected array<string, string> $words = []

Methods

__construct()

public __construct(SQL $db, mixed $settings[, string|null $localeISO = null ][, bool $update = false ]) : mixed
Parameters
$db : SQL
$settings : mixed
$localeISO : string|null = null
$update : bool = false
Tags
throws
RuntimeException

__destruct()

Add unknown phrases to lang pools

public __destruct() : mixed
Tags
throws
RuntimeException

isTranslated()

Check if word is defined

public isTranslated(string $singular) : bool
Parameters
$singular : string
Return values
bool

translate()

Translate word

public translate(string $singular[, mixed $plural = null ][, mixed $number = null ]) : string
Parameters
$singular : string
$plural : mixed = null
$number : mixed = null
Return values
string

chooseLoader()

Choose translation method

protected chooseLoader(SQL $db, string $setting) : void
Parameters
$db : SQL
$setting : string

createTranslator()

protected createTranslator(array<string, string> $list) : void
Parameters
$list : array<string, string>

initGlobal()

init Global function

protected initGlobal() : void

loadDB()

Load words from database

protected loadDB(string $setting, SQL $db) : void
Parameters
$setting : string
$db : SQL
Tags
throws
RuntimeException

loadFile()

Load file with Define

protected loadFile(string $file) : void
Parameters
$file : string

loadGettext()

Load GETTEXT language pack path: $directory/$locale/LC_$domain/$domain.mo

protected loadGettext(string $locale[, string $domain = 'messages' ]) : void
Parameters
$locale : string
$domain : string = 'messages'

loadJson()

Load json file

protected loadJson(string $file) : void
Parameters
$file : string

        
On this page

Search results