Admin Translation uses page language instead of backend locale

When I use

echo $this->translate('Textabschnitt', [], 'admin');

shouldn’t pimcore use the current backend language to translate the text “Textabschnitt”?

Currently, pimcore always uses the current page language (“Navigation & Properties” / “Language”). However, I like to use the admin translation, because I want to the user to see the text in the language he choose in his profile settings.

Is there a way to do this?

why are you using Admin Translations for frontend pages anyway?

I use them to translate options of a select editable, as it is encouraged by the documentation: https://pimcore.com/docs/6.x/Development_Documentation/Multi_Language_i18n/Admin_Translations.html

However, in that example pimcore does not use the backend language but the page language instead.

That does make sense.

Sorry, I don’t think there is a solution, how do you wanna get a backend user language when you’re not in the context of the backend…

If you are doing some sort of Iframe thing in the backend, you have access to the pimcore user, if not, you don’t

Thank you for your reply.

One solution could be to pass the backend language as the fourth parameter:

echo $this->translate('Textabschnitt', [], 'admin', $currentBackendLanguage);

However, I did not find a way to get the current backend language.

there is a fourth parameter for the language, so that works.