Language settings contains configurations like setting main or default locale. Here we can also specify language directory where all translations are located. Language setting is located at
locale section we can define
main is main locale for the application. If translation does not found in main locale then
default locale. IF translation does not found in both of these locale then exception is thrown.
|main||Main locale from which translation will be fetched.|
|default||If the translation does not found in main locale then translation fetched from below mentioned locale. If default locale is not valid or does not contains translation then exception is thrown.|
We can store translations into files or db and this can be specified in
type setting. Value of
type can be
file. Based on this setting its related setting also need to be configured.
When we store translations into files, below settings need to be configured in
file section. We can store translations into JSON or PHP file.
|type||Type of file JSON or PHP|
|path||Path where translations are stored.|
For translations which are stored in database below settings need to be configured in
|connection||Database connection name. Keep it
|table||Applicable only when
|cacheExpiry||Cache expiry for translations loaded form database. Set it to
Its good to have cache enabled for translations stored in database because it will prevent frequent query to db.
Whenever translations are updated and we have caching enabled, we need to clear cache so that application gets updated translations. We can get cache key by calling below method.
$cachKey = Nishchay::getLang() ->getLoader() ->getCacheKey('english', 'english');
We might need to create MD5 of cacheKey, if
hash = true to set in cache config. Here first parameter of
locale and second is
NOTE: Root namesapce should be same as locale name.
Notes are visible to you only and its for your use only. Its good to note a point of what you read.