novembit / i18n
Standalone i18n.
Requires
- php: >=7.1
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-pdo: *
- ext-simplexml: *
- cache/cache: *
- doctrine/dbal: *
- google/cloud-translate: *
- masterminds/html5: ^2.7
- monolog/monolog: *
- psr/cache: *
- psr/log: *
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-04 15:35:18 UTC
README
Table of Contents
- Arrays
- DataMapper
- DB
- DB
- Dummy
- Exception
- HTML
- HTML
- HTMLFragment
- JSON
- LanguageException
- Method
- MethodException
- Module
- RequestException
- Rest
- Rest
- Strings
- Text
- Translation
- TranslationException
- URL
- URL
- XML
- XML
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:
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:
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:
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:
getRuntimeDir
DB::getRuntimeDir( ): string
setRuntimeDir
DB::setRuntimeDir( string $runtime_dir )
Parameters:
setCachePool
DB::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )
Parameters:
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:
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:
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:
getRuntimeDir
DB::getRuntimeDir( ): string
setRuntimeDir
DB::setRuntimeDir( string $runtime_dir )
Parameters:
setCachePool
DB::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )
Parameters:
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 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:
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:
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:
buildToTranslateFields
HTML::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )
Parameters:
replaceTranslatedFields
HTML::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )
Parameters:
getHelperAttributes
{@inheritDoc}
HTML::getHelperAttributes( ): boolean
setHelperAttributes
{@inheritDoc}
HTML::setHelperAttributes( boolean $status ): void
Parameters:
html translation including additional attributes |
addBeforeParseCallback
HTML::addBeforeParseCallback( callable $callback )
Parameters:
addAfterParseCallback
HTML::addAfterParseCallback( callable $callback )
Parameters:
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:
buildToTranslateFields
HTMLFragment::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )
Parameters:
replaceTranslatedFields
HTMLFragment::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )
Parameters:
getHelperAttributes
{@inheritDoc}
HTMLFragment::getHelperAttributes( ): boolean
setHelperAttributes
{@inheritDoc}
HTMLFragment::setHelperAttributes( boolean $status ): void
Parameters:
html translation including additional attributes |
addBeforeParseCallback
HTMLFragment::addBeforeParseCallback( callable $callback )
Parameters:
addAfterParseCallback
HTMLFragment::addAfterParseCallback( callable $callback )
Parameters:
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:
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:
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:
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:
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:
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:
getRuntimeDir
Module::getRuntimeDir( ): string
setRuntimeDir
Module::setRuntimeDir( string $runtime_dir )
Parameters:
setCachePool
Module::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )
Parameters:
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:
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:
isCli
Check if script running on CLI
Rest::isCli( ): boolean
getLogger
Rest::getLogger( ): \Psr\Log\LoggerInterface
setLogger
Rest::setLogger( \Psr\Log\LoggerInterface $logger )
Parameters:
getRuntimeDir
Rest::getRuntimeDir( ): string
setRuntimeDir
Rest::setRuntimeDir( string $runtime_dir )
Parameters:
setCachePool
Rest::setCachePool( \Psr\SimpleCache\CacheInterface $cache_pool )
Parameters:
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:
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:
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:
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:
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:
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:
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:
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:
removeQueryVars
Remove Query parameter from URL
URL::removeQueryVars( string $url, string $paramName ): string
- This method is static. Parameters:
buildUrl
Build url from parts Same as reversed parse_url
URL::buildUrl( array $parts ): string
- This method is static. Parameters:
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:
buildToTranslateFields
XML::buildToTranslateFields( \DOMNode &$node, array $params, array &$data )
Parameters:
replaceTranslatedFields
XML::replaceTranslatedFields( \DOMNode &$node, array $params, array &$data )
Parameters:
getHelperAttributes
{@inheritDoc}
XML::getHelperAttributes( ): boolean
setHelperAttributes
{@inheritDoc}
XML::setHelperAttributes( boolean $status ): void
Parameters:
html translation including additional attributes |
addBeforeParseCallback
XML::addBeforeParseCallback( callable $callback )
Parameters:
addAfterParseCallback
XML::addAfterParseCallback( callable $callback )
Parameters:
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:
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:
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