Translate functionality
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 40
- Joined: 02 Dec 2021, 17:18
Translate functionality
What is the difference between
and
aitrans( 'Top', $params = [], $domain = 'client', $locale = null )
When to use which method?
TIA
Code: Select all
$this->translate( 'admin', 'Basic' )
aitrans( 'Top', $params = [], $domain = 'client', $locale = null )
When to use which method?
TIA
Re: Translate functionality
"aitrans()" is a helper method you can use in Blade templates to access Aimeos translations, "$this->translate()" is a view helper only available in Aimeos views.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 40
- Joined: 02 Dec 2021, 17:18
Re: Translate functionality
What to pass for the parameters of the aitrans() function
$params...
$domain...
$locale...
can I get a information on what these parameters indicate and how to pass language key in this function call ?
TIA
Code: Select all
aitrans( 'Top', $params = [], $domain = 'client', $locale = null )
$params...
$domain...
$locale...
can I get a information on what these parameters indicate and how to pass language key in this function call ?
TIA
Re: Translate functionality
The documentation for aitrans() is available here:
https://aimeos.org/docs/latest/laravel/ ... anslations
The parameters are:
- $singular : Text to translate
- $params : Array of values if $singular contains sprintf() placeholders (e.g. %1$s)
- $domain : Translation domain (same as first parameter for $this->translate())
- $locale : Language code if different from the one for the page
For your example:
With placeholders:
With different domain:
Output French translation in e.g. a page with English texts:
https://aimeos.org/docs/latest/laravel/ ... anslations
The parameters are:
- $singular : Text to translate
- $params : Array of values if $singular contains sprintf() placeholders (e.g. %1$s)
- $domain : Translation domain (same as first parameter for $this->translate())
- $locale : Language code if different from the one for the page
For your example:
Code: Select all
aitrans('Top')
Code: Select all
aitrans('%1$s results found', [10])
Code: Select all
aitrans('price:default', [], 'client/ext')
Code: Select all
aitrans('Top', [], 'client', 'fr)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 40
- Joined: 02 Dec 2021, 17:18
Re: Translate functionality
Thank you for the detailed explaination
I didn't got the value 'client' - a third parameter
is it a index present in shop.php ?
how these values can be access from aitrans() function
Please let me know...
TIA
I didn't got the value 'client' - a third parameter
is it a index present in shop.php ?
Code: Select all
'client' => [
'en'=>[
'header'=>[
'key1'=>'value2',
'key2'=>'value2',
],
'footer'=>[
'key3'=>'value3',
'key4'=>'value4',
]
],
'fr'=>[
'header'=>[
'key1'=>'value2',
'key2'=>'value2',
],
'footer'=>[
'key3'=>'value3',
'key4'=>'value4',
]
],
'de'=>[
'header'=>[
'key1'=>'value2',
'key2'=>'value2',
],
'footer'=>[
'key3'=>'value3',
'key4'=>'value4',
]
]
]
Please let me know...
TIA
Re: Translate functionality
Yes, the third parameter matches e.g. the
key in your ./config/shop.php
Code: Select all
'i18n' => ['client' => []]
// or
'i18n' => ['client/ext' => []]
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 40
- Joined: 02 Dec 2021, 17:18
Re: Translate functionality
How to maintain separate files for multiple language keys, as I have huge set of translative sentences/words, as we do in Laravel, separate folder for each languages.
Is it possible in Aimeos ? how we can access from either $translate or aitrans() functions ?
Is it possible in Aimeos ? how we can access from either $translate or aitrans() functions ?
Re: Translate functionality
For a large list of translations, use the Gettext files instead where you have one file per language in an optimized binary format:
https://aimeos.org/docs/latest/developer/translations/
https://aimeos.org/docs/latest/developer/translations/
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star