Getting the current language in Aimeos

Help for integrating the Laravel package
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!
Amir
Posts: 13
Joined: 15 Feb 2020, 16:30

Getting the current language in Aimeos

Post by Amir » 22 Feb 2020, 17:46

I want to check the current language to switch the HTML rendering from Left To Right to Right To Left. I've checked it using

Code: Select all

 dir="{{ Lang::locale() === "en" ? "ltr" : "rtl" }}"
but it always displays ltr. How to achieve that?

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: Getting the current language in Aimeos

Post by aimeos » 24 Feb 2020, 08:44

You can use

Code: Select all

App::isLocale('en')
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Amir
Posts: 13
Joined: 15 Feb 2020, 16:30

Re: Getting the current language in Aimeos

Post by Amir » 24 Feb 2020, 12:33

the code

Code: Select all

App::isLocale('en')
returns 1 which will always display one direction only, I'm using the select/locale switcher from aimeos.

And I tried setting the locale in the service provider to get it to work and it does, but the product language are independent from the global locale I've set.

User avatar
aimeos
Administrator
Posts: 7881
Joined: 01 Jan 1970, 00:00

Re: Getting the current language in Aimeos

Post by aimeos » 24 Feb 2020, 13:56

Aimeos is using the "locale" parameter and you can set it in a custom middleware to that value so it's available in the App facade:
https://dev.to/fadilxcoder/adding-multi ... ravel-4ech
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply