How to translate Category name on adding new languages?
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!
How to translate Category name on adding new languages?
PHP: 8.2.7
Laravel Framework: 10.48.4
System: Debian GNU/Linux 12
Aimeos Laravel v2023.10
Hello!
The task is adding new locales. I removed DE and added two new locales (languages) into the app. I modified the language selection menu in the packages/ourpackage/templates/client/html/locale/select/language-body.php template file and everything works fine except domain data like Category.
For test I add a new Category in Admin Panel with Name parameter for two different languages. But when I switch the language in front-end of the shop Category name doesn't switch to selected language and stays on default value. When it was in demo stage (EN and DE) adding new translation for DE to Category worked fine. What I forgot to do?
Laravel Framework: 10.48.4
System: Debian GNU/Linux 12
Aimeos Laravel v2023.10
Hello!
The task is adding new locales. I removed DE and added two new locales (languages) into the app. I modified the language selection menu in the packages/ourpackage/templates/client/html/locale/select/language-body.php template file and everything works fine except domain data like Category.
For test I add a new Category in Admin Panel with Name parameter for two different languages. But when I switch the language in front-end of the shop Category name doesn't switch to selected language and stays on default value. When it was in demo stage (EN and DE) adding new translation for DE to Category worked fine. What I forgot to do?
Re: How to translate Category name on adding new languages?
I added new record into the mshop_locale table for one of the new languages and it works as expected. But what to do if a language (the third one in my case) that I want to add to the Name of Category is not listed in the Language field of Text option in the Admin Panel? Should I also add this language somewhere?
Re: How to translate Category name on adding new languages?
Yes. I found where to add new language - in the Locales menu of Admin Panel.
But when I add third language in the Admin Panel for the Category - it still doesn't work.
But when I add third language in the Admin Panel for the Category - it still doesn't work.
Re: How to translate Category name on adding new languages?
Please Help!
I added three translates for Categories: EN, RU, AZ. Two of them work normal. I see translation in the front-end. But third one (AZ) doesn't work. Default value (EN) comes on it's place. All information of Name parameters of Category in Admin Panel are identical.
In the language switch template I get correct locale value in first two cases. In Aimeos\Base\View\Standard `values` field the `contextLanguage` value is appropriate selected locale. But in AZ case it takes the "en" value. Here is template code:
All languages work except AZ.
I added three translates for Categories: EN, RU, AZ. Two of them work normal. I see translation in the front-end. But third one (AZ) doesn't work. Default value (EN) comes on it's place. All information of Name parameters of Category in Admin Panel are identical.
In the language switch template I get correct locale value in first two cases. In Aimeos\Base\View\Standard `values` field the `contextLanguage` value is appropriate selected locale. But in AZ case it takes the "en" value. Here is template code:
Code: Select all
$enc = $this->encoder();
$locale = app()->getLocale();
$defaultLocale = config('app.locale', 'en');
$languages = config('app.language.list', ['en' => 'English']);
$selectedLanguageId = $locale ?? $defaultLocale;
setcookie('user_language', $selectedLanguageId, time() + (config('session.cookie_validity.default', 86400 * 30)), "/");
app()->setLocale($locale);
$languagesMenuText = $languages[$locale] ?? 'English';
?>
[code]<div class="language-currency lang-curr-border-2">
<span>Language:</span>
<div class="lang-curr-dropdown">
<ul>
<li>
<a class="language-click" href="#"><?= $enc->attr($languagesMenuText) ?> <i class="ion-chevron-down"></i></a>
<ul class="language-dropdown">
<?php
foreach ($languages as $lang => $text) : ?>
<li class="select-item <?= ($lang === $selectedLanguageId ? 'active' : '') ?>">
<a href="<?= $enc->attr($this->url(
$this->request()->getTarget(),
$this->param('controller'),
$this->param('action'),
array_merge($this->get('selectParams', []), [
'locale' => $lang
]),
[],
)) ?>">
<?= $enc->html($text, $enc::TRUST) ?>
</a>
</li>
<?php endforeach ?>
</ul>
</li>
</ul>
</div>
</div>
Re: How to translate Category name on adding new languages?
I solved the problem after I put things in order in the Locales list in the Admin Panel and made its values according to the mshop_locale table.
This topic helped:
laravel-package-f18/how-to-change-defau ... t2389.html
This topic helped:
laravel-package-f18/how-to-change-defau ... t2389.html