📝i18n
The module provides a simple way to management different languages.
Last updated
The module provides a simple way to management different languages.
Last updated
REDIS_HOST
Host of the redis.
REDIS_PASSWORD
Port of the redis.
REDIS_PORT
Password of the redis.
Write .env
file with environment variable. Below has an example:
This is an important module in the system and contains a detailed section.
To use this module, you need to inject it into the desired service.
Before use you do added new locale and define properties from language.
It is recommended to create a new location and set the properties in the root module (main.ts).
Injecting the module into our service.
You will need to inject the following interfaces.
IConfigurationService
IValidatorRegexpService
IStringExService
IRedisService
IDebugService
IPropStringService
private _locale
static
Current locale.
private _locales
static
All locales.
private _path
static
The path folder for locales files.
private _driver
static
The driver used for store data (fs or redis).
_setDefaultOptions
private
Set default options.
_initialize
private
Initialize the module and create the locales files.
_redisPrefix
private
Get the prefix for redis.
_compress
private
Compress and decompress data.
_decompress
private
Decompress data from string to object.
_redisSerializeKey
private
Serialize key for redis.
_redisSave
private
Save data in redis.
_redisGet
private
Get data from redis.
_redisDelete
private
Delete data from redis.
_writeRelativeLocalePath
private
Write the path folder for locales files.
_relativeLocalePath
private
Get the path folder for locales files.
_fileLocaleExists
private
Check if the file locale exists.
_writeFileLocale
private
Write the file locale.
_readFileLocale
private
Read the file locale.
_definePropFileLocale
private
Define a property in a locale.
_removePropFileLocale
private
Remove a property in a locale.
_extractParserKeys
private
Extract parser keys from text.
_removeParserOptions
private
Remove parser options from text.
_isNoCascade
private
Check if the value is no cascade.
_getCascadeMatchValue
private
Get the cascade match value.
_getCascadeValue
private
Get the cascade value.
_isTrim
private
Check if the value is trim.
_isUppercase
private
Check if the value is uppercase.
_isLowercase
private
Check if the value is lowercase.
_isSpace
private
Check if the value is space.
_getSpaceValue
private
Get the space value.
_isRepeat
private
Check if the value is repeat.
_getRepeatValue
private
Get the repeat value.
_parserText
private
Parser text with params.
_removeLocaleStore
private
Remove a locale from store.
setPath
public
Define path folder for locales files.
setDriver
public
Define driver used for store data.
addLocale
public
Add the current locale.
getPath
public
Returns the path folder for locales files.
getDriver
public
Returns the driver used for store data.
getLocale
public
Get the current locale.
getLocales
public
Get all locales.
resetLocales
public
Reset all locales.
removeLocale
public
Remove a locale.
defineLocale
public
Set the current locale.
defineProperty
public
Define a property in a locale.
removeProperty
public
Remove a property in a locale.
translate
public
Translate a phrase in the current locale.