Language Mapping

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
pla
Posts: 14
Joined: 06 Nov 2024, 11:05

Language Mapping

Post by pla » 13 May 2026, 13:12

Hello again,

I have a question regarding mapping a TYPO3 language/locale to an AIMEOS language.

I am using TYPO3 13.4.23 and AIMEOS:
- aimeos/aimeos-core: 2024.10.15
- aimeos/aimeos-typo3: 24.10.5
- aimeos/ai-typo3: 2024.10.5
- aimeos/ai-client-html: 2024.10.7

I have a shop with multiple languages AND multiple countries. And here I want to set a different translation for e.g. de_DE and de_AT or de_CH due to local country regulations and slightly different wordings. In CH they do not have the letter "ß" for example.

The Problem is, that AIMEOS does not think in locales but in languages only. So there is only ONE language "de" which is automatically mapped from the sites language setting I guess.

Is it possible to override the AIMEOS language with any configuration? I have search in this forum and in for the keyword "locale" in the code but there is just too much.

My not so perfect solution would be using an existing language I don't need or create some which doesn't exist to use them. But therefore I need a possibility to change the context initialization of AIMEOS.

I also tried to add a language de_de and so on but AIMEOS tells me quick that this isn't possible and awrong language id.

Any help on that?

Thanks and greetings
Pla

pla
Posts: 14
Joined: 06 Nov 2024, 11:05

Re: Language Mapping (SOLVED)

Post by pla » 14 May 2026, 11:01

I found the code which obviously wasn't that hard. But like always when one coded the whole day it's getting harder to concentrate.

After sleeping a night it's getting easier like so often.

For all those who have the same problem:

In the package aimeos/aimeos-typo3 there is the class Aimeos\Aimeos\Base\Locale where the locale is getting loaded from the TYPO3 sites config.

This class or the static method ::get() is called in the Base class Aimeos\Aimeos\Base::locale() where you have two possibilities to override the AIMEOS Locale class:

Code: Select all

        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend'])) {
            if (($name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale_frontend']) instanceof \Closure) {
                return $name($context, $request);
            }
        }

        $name = 'Aimeos\Aimeos\Base\Locale';

        if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'])) {
            $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_locale'];
        }
So you can and have to override the whole locale initialization if you want an alternative language than the TYPO3 language.

In the method Aimeos\Aimeos\Base\Locale::get() there is this part which reads the TYPO3 sites config locale if no url param "locale" is given.

Code: Select all

                $name = $config->get('typo3/param/name/language', 'locale');
                if ($request->hasArgument($name) === true) {
                    $lang = $request->getArgument($name);
                } else {
                    $lang = str_replace('-', '_', $request->getAttribute('language')?->getLocale() ?? $lang );
                }
So I now have to override the class Aimeos\Aimeos\Base\Locale and define it in the above mentioned TYPO3_CONF_VARS to make my own configuration rules.

Post Reply