Skip to content
/ i18n Public

Internationalization framework. Translate each type of request content with special translation method. Handle raw, HTML/XML DOM, JSON translations, AJAX request, e.t.c.

Notifications You must be signed in to change notification settings

NovemBit/i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NovemBit i18n - Internationalization framework library

Table of Contents

Arrays

  • Full name: \NovemBit\i18n\system\helpers\Arrays

arrayWalkWithRoute

Recursive array walk with callback and route

Arrays::arrayWalkWithRoute( array &$arr, callable $callback, \NovemBit\i18n\system\helpers\Strings $route = '', \NovemBit\i18n\system\helpers\Strings $separator = '>' ): void
  • This method is static. Parameters:
Parameter Type Description
$arr array Main array
$callback callable Callback function with 3 params (key/val/route)
$route \NovemBit\i18n\system\helpers\Strings Parent route
$separator \NovemBit\i18n\system\helpers\Strings Route separator

arrayMergeRecursiveDistinct

array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does. I.e., with array_merge_recursive, this happens (documented behavior):

Arrays::arrayMergeRecursiveDistinct( array &$array1, array &$array2 ): array

array_merge_recursive(array('key' => 'org value'), array('key' => 'new value')); => array('key' => array('org value', 'new value'));

array_merge_recursive_distinct does not change the datatypes of the values in the arrays. Matching keys' values in the second array overwrite those in the first array, as is the case with array_merge, i.e.:

array_merge_recursive_distinct(array('key' => 'org value'), array('key' => 'new value')); => array('key' => array('new value'));

Parameters are passed by reference, though only for performance reasons. They're not altered by this function.

  • This method is static. Parameters:
Parameter Type Description
$array1 array
$array2 array

DataMapper

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\models\DataMapper

See Also:

getDB

DataMapper::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

DB

DB component

Its simple but provides very useful functionality Module class

  • Full name: \NovemBit\i18n\system\component\DB
  • Parent class: \NovemBit\i18n\system\Component

See Also:

__construct

Component constructor.

DB::__construct( array $config = array(), null|\NovemBit\i18n\system\Component &$context = null )

Parameters:

Parameter Type Description
$config array Configuration array
$context null|\NovemBit\i18n\system\Component Context (parent) Component

commonInit

{@inheritdoc} Init method of component.

DB::commonInit(  ): void

Setting default connection of DB


isCli

Check if script running on CLI

DB::isCli(  ): boolean

getLogger

DB::getLogger(  ): \Psr\Log\LoggerInterface

setLogger

DB::setLogger( \Psr\Log\LoggerInterface $logger )

Parameters:

Parameter Type Description
$logger \Psr\Log\LoggerInterface

getRuntimeDir

DB::getRuntimeDir(  ): string

setRuntimeDir

DB::setRuntimeDir( string $runtime_dir )

Parameters:

Parameter Type Description
$runtime_dir string

setCachePool

DB::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )

Parameters:

Parameter Type Description
$cache_pool \Psr\SimpleCache\CacheInterface

getCachePool

DB::getCachePool(  ): \Psr\SimpleCache\CacheInterface

defaultConfig

DB::defaultConfig(  )
  • This method is static.

getConnection

Get connection of DB

DB::getConnection(  ): \yii\db\Connection

setConnection

Set connection of DB

DB::setConnection( \yii\db\Connection $_connection ): void

Parameters:

Parameter Type Description
$_connection \yii\db\Connection Yii2 db connection

DB

DB component

Its simple but provides very useful functionality Module class

  • Full name: \NovemBit\i18n\component\db\DB
  • Parent class: \NovemBit\i18n\system\Component

See Also:

__construct

Component constructor.

DB::__construct( array $config = array(), null|\NovemBit\i18n\system\Component &$context = null )

Parameters:

Parameter Type Description
$config array Configuration array
$context null|\NovemBit\i18n\system\Component Context (parent) Component

commonInit

{@inheritdoc} Init method of component.

DB::commonInit(  ): void

Setting default connection of DB


isCli

Check if script running on CLI

DB::isCli(  ): boolean

getLogger

DB::getLogger(  ): \Psr\Log\LoggerInterface

setLogger

DB::setLogger( \Psr\Log\LoggerInterface $logger )

Parameters:

Parameter Type Description
$logger \Psr\Log\LoggerInterface

getRuntimeDir

DB::getRuntimeDir(  ): string

setRuntimeDir

DB::setRuntimeDir( string $runtime_dir )

Parameters:

Parameter Type Description
$runtime_dir string

setCachePool

DB::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )

Parameters:

Parameter Type Description
$cache_pool \Psr\SimpleCache\CacheInterface

getCachePool

DB::getCachePool(  ): \Psr\SimpleCache\CacheInterface

defaultConfig

DB::defaultConfig(  )
  • This method is static.

getConnection

Get connection of DB

DB::getConnection(  ): \Doctrine\DBAL\Connection

getConnectionParams

Connection params getter

DB::getConnectionParams(  ): array

Dummy

Dummy method of translation

  • Full name: \NovemBit\i18n\component\translation\method\Dummy
  • Parent class: \NovemBit\i18n\component\translation\method\Method

See Also:

Exception

System Exception class

  • Full name: \NovemBit\i18n\system\exception\Exception
  • Parent class:
  • This class implements: \NovemBit\i18n\system\exception\FriendlyExceptionInterface

See Also:

Google

Google Translate method of translation

  • Full name: \NovemBit\i18n\component\translation\method\Google
  • Parent class: \NovemBit\i18n\component\translation\method\Method

See Also:

mainInit

{@inheritdoc}

Google::mainInit(  ): void

HTML

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\type\models\HTML
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

HTML::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

HTML::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

HTML::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

HTML

HTML type for translation component

  • Full name: \NovemBit\i18n\component\translation\type\HTML
  • Parent class: \NovemBit\i18n\component\translation\type\XML
  • This class implements: \NovemBit\i18n\component\translation\type\interfaces\HTML

See Also:

defaultConfig

{@inheritDoc}

HTML::defaultConfig(  ): array
  • This method is static.

getParserType

HTML::getParserType(  ): integer

setParserType

HTML::setParserType( integer $parser_type )

Parameters:

Parameter Type Description
$parser_type integer

buildToTranslateFields

HTML::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

replaceTranslatedFields

HTML::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

getHelperAttributes

{@inheritDoc}

HTML::getHelperAttributes(  ): boolean

setHelperAttributes

{@inheritDoc}

HTML::setHelperAttributes( boolean $status ): void

Parameters:

Parameter Type Description
$status boolean If true then
                html translation including additional attributes |

addBeforeParseCallback

HTML::addBeforeParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

addAfterParseCallback

HTML::addAfterParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

getBeforeParseCallbacks

HTML::getBeforeParseCallbacks(  ): array

getAfterParseCallbacks

HTML::getAfterParseCallbacks(  ): array

HTMLFragment

HTML type for translation component

  • Full name: \NovemBit\i18n\component\translation\type\HTMLFragment
  • Parent class: \NovemBit\i18n\component\translation\type\HTML
  • This class implements: \NovemBit\i18n\component\translation\type\interfaces\HTMLFragment

See Also:

defaultConfig

{@inheritDoc}

HTMLFragment::defaultConfig(  ): array
  • This method is static.

getParserType

HTMLFragment::getParserType(  ): integer

setParserType

HTMLFragment::setParserType( integer $parser_type )

Parameters:

Parameter Type Description
$parser_type integer

buildToTranslateFields

HTMLFragment::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

replaceTranslatedFields

HTMLFragment::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

getHelperAttributes

{@inheritDoc}

HTMLFragment::getHelperAttributes(  ): boolean

setHelperAttributes

{@inheritDoc}

HTMLFragment::setHelperAttributes( boolean $status ): void

Parameters:

Parameter Type Description
$status boolean If true then
                html translation including additional attributes |

addBeforeParseCallback

HTMLFragment::addBeforeParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

addAfterParseCallback

HTMLFragment::addAfterParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

getBeforeParseCallbacks

HTMLFragment::getBeforeParseCallbacks(  ): array

getAfterParseCallbacks

HTMLFragment::getAfterParseCallbacks(  ): array

JSON

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\type\models\JSON
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

JSON::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

JSON::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

JSON::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

LanguageException

Language Component Exception file

  • Full name: \NovemBit\i18n\component\languages\exceptions\LanguageException
  • Parent class: \NovemBit\i18n\system\exception\Exception

See Also:

Method

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\method\models\Method
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

Method::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

Method::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

Method::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

MethodException

Language Component Exception file

  • Full name: \NovemBit\i18n\component\translation\method\exceptions\MethodException
  • Parent class: \NovemBit\i18n\system\exception\Exception

See Also:

Module

Module class Main instance of i18n library. Should be used for any external connection Provides component system. There have some required components, DBAL (RDMS) configurations, Request handlers, Translation abstraction layer,

Its simple but provides very useful functionality Module class

  • Full name: \NovemBit\i18n\Module
  • Parent class: \NovemBit\i18n\system\Component

See Also:

__construct

Component constructor.

Module::__construct( array $config = array(), null|\NovemBit\i18n\system\Component &$context = null )

Parameters:

Parameter Type Description
$config array Configuration array
$context null|\NovemBit\i18n\system\Component Context (parent) Component

commonLateInit

Module::commonLateInit(  ): void

Load Yii framework container to use some libraries that not Allowed to use standalone


mainInit

Component init method Non CLI Running after child component initialization

Module::mainInit(  ): void

isCli

Check if script running on CLI

Module::isCli(  ): boolean

getLogger

Module::getLogger(  ): \Psr\Log\LoggerInterface

setLogger

Module::setLogger( \Psr\Log\LoggerInterface $logger )

Parameters:

Parameter Type Description
$logger \Psr\Log\LoggerInterface

getRuntimeDir

Module::getRuntimeDir(  ): string

setRuntimeDir

Module::setRuntimeDir( string $runtime_dir )

Parameters:

Parameter Type Description
$runtime_dir string

setCachePool

Module::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )

Parameters:

Parameter Type Description
$cache_pool \Psr\SimpleCache\CacheInterface

getCachePool

Module::getCachePool(  ): \Psr\SimpleCache\CacheInterface

defaultConfig

Default component configuration

Module::defaultConfig(  ): array
  • This method is static.

start

Start request translation

Module::start(  ): void

instance

Creating module main instance

Module::instance( null|array $config = null ): self
  • This method is static. Parameters:
Parameter Type Description
$config null|array Main configuration array

RequestException

Request Exception class

  • Full name: \NovemBit\i18n\component\request\exceptions\RequestException
  • Parent class: \NovemBit\i18n\system\exception\Exception

See Also:

Rest

Rest component

Its simple but provides very useful functionality Module class

  • Full name: \NovemBit\i18n\component\rest\Rest
  • Parent class: \NovemBit\i18n\system\Component
  • This class implements: \NovemBit\i18n\component\rest\interfaces\Rest

See Also:

__construct

Component constructor.

Rest::__construct( array $config = array(), null|\NovemBit\i18n\system\Component &$context = null )

Parameters:

Parameter Type Description
$config array Configuration array
$context null|\NovemBit\i18n\system\Component Context (parent) Component

isCli

Check if script running on CLI

Rest::isCli(  ): boolean

getLogger

Rest::getLogger(  ): \Psr\Log\LoggerInterface

setLogger

Rest::setLogger( \Psr\Log\LoggerInterface $logger )

Parameters:

Parameter Type Description
$logger \Psr\Log\LoggerInterface

getRuntimeDir

Rest::getRuntimeDir(  ): string

setRuntimeDir

Rest::setRuntimeDir( string $runtime_dir )

Parameters:

Parameter Type Description
$runtime_dir string

setCachePool

Rest::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )

Parameters:

Parameter Type Description
$cache_pool \Psr\SimpleCache\CacheInterface

getCachePool

Rest::getCachePool(  ): \Psr\SimpleCache\CacheInterface

defaultConfig

Rest::defaultConfig(  )
  • This method is static.

start

Start rest request

Rest::start(  ): void

actionTranslate

Translate Action method

Rest::actionTranslate(  ): array|integer

actionIndex

Index Action method

Rest::actionIndex(  ): array

actionRestrict

Restrict Action method

Rest::actionRestrict(  ): array

Rest

Rest Translate method of translation

  • Full name: \NovemBit\i18n\component\translation\method\Rest
  • Parent class: \NovemBit\i18n\component\translation\method\Method

See Also:

getLanguagesConfig

Get languages configuration from main module instance $config

Rest::getLanguagesConfig(  ): array

Strings

  • Full name: \NovemBit\i18n\system\helpers\Strings

getStringsDifference

Get string difference

Strings::getStringsDifference( string $before, string $after, string|null &$prefix = null, string|null &$suffix = null ): void
  • This method is static. Parameters:
Parameter Type Description
$before string Initial type of string
$after string Final type of string
$prefix string|null Referenced variable to receive difference prefix
$suffix string|null Referenced variable to receive difference suffix

Text

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\type\models\Text
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

Text::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

Text::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

Text::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

Translation

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\models\Translation
  • Parent class: \NovemBit\i18n\models\DataMapper
  • This class implements: \NovemBit\i18n\component\translation\models\interfaces\Translation

See Also:

getDB

Translation::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

get

Main method to get translations from DB

Translation::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

Translation::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

TranslationException

Request Exception class

  • Full name: \NovemBit\i18n\component\translation\exceptions\TranslationException
  • Parent class: \NovemBit\i18n\system\exception\Exception

See Also:

URL

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\type\models\URL
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

URL::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

URL::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

URL::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.

rules

{@inheritdoc}

URL::rules(  ): array

URL

Helper class for some actions with URLs

  • Full name: \NovemBit\i18n\system\helpers\URL

See Also:

addQueryVars

Adding query parameters to URL

URL::addQueryVars( string $url, string $name, string $value ): string
  • This method is static. Parameters:
Parameter Type Description
$url string Initial url
$name string Parameter name (key)
$value string Value of parameter

removeQueryVars

Remove Query parameter from URL

URL::removeQueryVars( string $url, string $paramName ): string
  • This method is static. Parameters:
Parameter Type Description
$url string Initial url
$paramName string Parameter name (key)

buildUrl

Build url from parts Same as reversed parse_url

URL::buildUrl( array $parts ): string
  • This method is static. Parameters:
Parameter Type Description
$parts array Parts of url

XML

HTML type for translation component

  • Full name: \NovemBit\i18n\component\translation\type\XML
  • Parent class: \NovemBit\i18n\component\translation\type\Type

See Also:

defaultConfig

{@inheritDoc}

XML::defaultConfig(  ): array
  • This method is static.

getParserType

XML::getParserType(  ): integer

setParserType

XML::setParserType( integer $parser_type )

Parameters:

Parameter Type Description
$parser_type integer

buildToTranslateFields

XML::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

replaceTranslatedFields

XML::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )

Parameters:

Parameter Type Description
$node \DOMNode
$params array
$data array

getHelperAttributes

{@inheritDoc}

XML::getHelperAttributes(  ): boolean

setHelperAttributes

{@inheritDoc}

XML::setHelperAttributes( boolean $status ): void

Parameters:

Parameter Type Description
$status boolean If true then
                html translation including additional attributes |

addBeforeParseCallback

XML::addBeforeParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

addAfterParseCallback

XML::addAfterParseCallback( callable $callback )

Parameters:

Parameter Type Description
$callback callable

getBeforeParseCallbacks

XML::getBeforeParseCallbacks(  ): array

getAfterParseCallbacks

XML::getAfterParseCallbacks(  ): array

XML

ActiveRecord class. Child of Yii ActiveRecord library

  • Full name: \NovemBit\i18n\component\translation\type\models\XML
  • Parent class: \NovemBit\i18n\component\translation\models\Translation

See Also:

get

Main method to get translations from DB

XML::get( array $texts, string $from_language, array $to_languages, boolean $reverse = false ): array
  • This method is static. Parameters:
Parameter Type Description
$texts array Texts array to translate
$from_language string From language
$to_languages array To languages list
$reverse boolean Use translate column as source (ReTranslate)

saveTranslations

Main method to save translations in DB

XML::saveTranslations( string $from_language, array $translations, integer $level, boolean $overwrite = false, array &$result = array() ): void
  • This method is static. Parameters:
Parameter Type Description
$from_language string From language
$translations array Translations of texts
$level integer Level of translation
$overwrite boolean Overwrite or not
$result array

getDB

XML::getDB(  ): \Doctrine\DBAL\Connection
  • This method is static.


This document was automatically generated from source code comments on 2019-12-03 using phpDocumentor and cvuorinen/phpdoc-markdown-public

About

Internationalization framework. Translate each type of request content with special translation method. Handle raw, HTML/XML DOM, JSON translations, AJAX request, e.t.c.

Resources

Stars

Watchers

Forks

Packages

No packages published