\Geekwright\PoPoInitSmarty

PoInitPHP provides 'msginit' like logic which can take a Smarty template file, recognize gettext like function tokens, and capture the translatable strings in a PoFile object.

The Smarty functions are expected to be in the format: funcname(msgid="message" msgid_plural="plural message" msgctxt="context") The specifics of the function ('funcname') and the argument names ('msgid', 'msgid_plural', and 'msgctxt') can be specified.

A properly initialized Smarty v3 object is required.

Summary

Methods
Properties
Constants
getPoFile()
setPoFile()
getGettextTags()
setGettextTags()
addGettextTags()
getNgettextTags()
setNgettextTags()
addNgettextTags()
getPgettextTags()
setPgettextTags()
addPgettextTags()
msginitFile()
msginitString()
escapeForPo()
checkPhpFormatFlag()
__construct()
getMsgctxtArgNames()
setMsgctxtArgNames()
addMsgctxtArgNames()
getMsgidArgNames()
setMsgidArgNames()
addMsgidArgNames()
getMsgidPluralArgNames()
setMsgidPluralArgNames()
addMsgidPluralArgNames()
No public properties found
No constants found
No protected methods found
$poFile
$gettextTags
$pgettextTags
$ngettextTags
$smarty
$msgidArgNames
$msgidPluralArgNames
$msgctxtArgNames
N/A
No private methods found
No private properties found
N/A

Properties

$poFile

$poFile : \Geekwright\Po\PoFile

Type

PoFile — object to be used in msginit

$gettextTags

$gettextTags : string[]

Type

string[] — tags for gettext constructs, i.e. tag($msgid)

$pgettextTags

$pgettextTags : string[]

Type

string[] — tags for pgettext constructs, i.e. tag($msgctxt, $msgid)

$ngettextTags

$ngettextTags : string[]

Type

string[] — tags for ngettext constructs, i.e. tag($msgid, $msgid_plural)

$smarty

$smarty : \Smarty

Type

\Smarty — Smarty 3 object

$msgidArgNames

$msgidArgNames : string[]

Type

string[] — names of Smarty function arguments for msgid

$msgidPluralArgNames

$msgidPluralArgNames : string[]

Type

string[] — names of Smarty function arguments for msgid_plural

$msgctxtArgNames

$msgctxtArgNames : string[]

Type

string[] — names of Smarty function argments for msgctxt

Methods

getPoFile()

getPoFile() : \Geekwright\Po\PoFile

Get the PoFile object used in msginit process

Returns

\Geekwright\Po\PoFile —

setPoFile()

setPoFile(\Geekwright\Po\PoFile  $poFile) : void

Set the PoFile object to use in msginit process

Parameters

\Geekwright\Po\PoFile $poFile

a PoFile object

getGettextTags()

getGettextTags() : string[]

Get tags used for gettext like functions

Returns

string[] —

setGettextTags()

setGettextTags(string[]  $tags) : void

Set tags used for gettext like functions

Parameters

string[] $tags

array of tags to set

addGettextTags()

addGettextTags(string|string[]  $tags) : void

Add tags used for gettext like functions

Parameters

string|string[] $tags

tag, or array of tags to add

getNgettextTags()

getNgettextTags() : string[]

Get tags used for ngettext like functions

Returns

string[] —

setNgettextTags()

setNgettextTags(string[]  $tags) : void

setNgettextTags - set tags used for ngettext like functions

Parameters

string[] $tags

array of tags to set

addNgettextTags()

addNgettextTags(string|string[]  $tags) : void

Add tags used for ngettext like functions

Parameters

string|string[] $tags

tag, or array of tags to add

getPgettextTags()

getPgettextTags() : string[]

Get tags used for pgettext like functions

Returns

string[] —

setPgettextTags()

setPgettextTags(string[]  $tags) : void

Set tags used for pgettext like functions

Parameters

string[] $tags

array of tags to set

addPgettextTags()

addPgettextTags(string|string[]  $tags) : void

Add tags used for pgettext like functions

Parameters

string|string[] $tags

tag, or array of tags to add

msginitFile()

msginitFile(string  $filename) : \Geekwright\Po\PoFile

Inspect the supplied source file, capture gettext references as a PoFile object

Parameters

string $filename

name of source file

Throws

\Geekwright\Po\Exceptions\FileNotReadableException

Returns

\Geekwright\Po\PoFile —

msginitString()

msginitString(string  $source, string  $refname) : \Geekwright\Po\PoFile

Inspect the supplied source, capture gettext references as a PoFile object.

Parameters

string $source

php source code

string $refname

source identification used for PO reference comments

Returns

\Geekwright\Po\PoFile —

escapeForPo()

escapeForPo(string  $string) : string

Prepare a string from tokenized output for use in a po file. Remove any surrounding quotes, escape control characters and double quotes.

Parameters

string $string

raw string (T_STRING) identified by php token_get_all

Returns

string —

checkPhpFormatFlag()

checkPhpFormatFlag(\Geekwright\Po\PoEntry  $entry) : void

Check the supplied entry for sprintf directives and set php-format flag if found

Parameters

\Geekwright\Po\PoEntry $entry

entry to check

__construct()

__construct(\Smarty  $smarty, \Geekwright\Po\PoFile|null  $poFile = null) : mixed

Set the Smarty and PoObjects to use in the Init process

Parameters

\Smarty $smarty

a fully initialize Smarty 3 instance

\Geekwright\Po\PoFile|null $poFile

a PoFile object to be used in msginit

Returns

mixed —

getMsgctxtArgNames()

getMsgctxtArgNames() : string[]

getMsgctxtArgNames - get argument name(s) used for the msgctxt

Returns

string[] —

setMsgctxtArgNames()

setMsgctxtArgNames(string[]  $argNames) : void

Set argument name(s) used for the msgctxt

Parameters

string[] $argNames

array of argument names to set

addMsgctxtArgNames()

addMsgctxtArgNames(string|string[]  $argNames) : void

Add argument name(s) used for the msgctxt

Parameters

string|string[] $argNames

argument name(s) to add

getMsgidArgNames()

getMsgidArgNames() : string[]

Get argument name(s) used for the msgid

Returns

string[] —

setMsgidArgNames()

setMsgidArgNames(string[]  $argNames) : void

Set argument name(s) used for the msgid

Parameters

string[] $argNames

array of argument names to set

addMsgidArgNames()

addMsgidArgNames(string|string[]  $argNames) : void

Add argument name(s) used for the msgid

Parameters

string|string[] $argNames

argument name(s) to add

getMsgidPluralArgNames()

getMsgidPluralArgNames() : string[]

Get argument name(s) used for the msgid_plural

Returns

string[] —

setMsgidPluralArgNames()

setMsgidPluralArgNames(string[]  $argNames) : void

Set argument name(s) used for the msgid_plural

Parameters

string[] $argNames

array of argument names to set

addMsgidPluralArgNames()

addMsgidPluralArgNames(string|string[]  $argNames) : void

Add argument name(s) used for the msgid_plural

Parameters

string|string[] $argNames

argument name(s) to add