How to override frontend language by url parameter?

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

How to override frontend language by url parameter?

Post by gba » Mon Jan 25, 2021 3:28 pm

Hi all!

I am creating a component, which is creating a raw output in frontend.
Translating texts by choosing the frontend language works fine.
Now I want to be able to override the admins language setting by adding 'lang=xx-XX' to the URL.
How can I make Joomla use that language code for translating texts instead of the one configured by the admin?
Important: All texts need to be translated using the language code from the URL, not just the texts in my component's code.

Thank you very much in advance for any useful hint!

Kind regards,
Gerald

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30881
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: How to override frontend language by url parameter?

Post by Per Yngve Berg » Mon Jan 25, 2021 4:00 pm

The user select in it's profile what language shall be used in administrator or select when loggin in.

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: How to override frontend language by url parameter?

Post by gba » Mon Jan 25, 2021 5:04 pm

Hi!

Thank you for your reply.

I meant following:
Using such a URL call ...

Code: Select all

https://mydomain.com/index.php/option=com_mycomponent&view=myview&format=raw&lang=xx-XX
... Joomla should use the xx-XX translation files instead of the language configured by the admin or the frontend user.
How can I achieve that?

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: How to override frontend language by url parameter?

Post by gba » Thu Apr 08, 2021 3:36 pm

???

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2887
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: How to override frontend language by url parameter?

Post by SharkyKZ » Thu Apr 08, 2021 5:09 pm

Not possible out of the box. You'd need to write a plugin.

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: How to override frontend language by url parameter?

Post by gba » Mon Apr 12, 2021 2:54 pm

Hi!

Thank you for that hint.
How could I override the frontend language by url parameter using an own plugin?

Kind regards,
Gerald

sozzled
I've been banned!
Posts: 13639
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to override frontend language by url parameter?

Post by sozzled » Mon Apr 12, 2021 6:32 pm

My suggestion is to purchase a book on writing plugins for Joomla. The best resource, that I'm aware of, for writing J! plugins is Programming Joomla! Plugins by Jisse Reitsma, Yireo Education, 2014 (if you can still find a copy in print). Good luck with that. :)

Alternatively you might be able to find a freelance software developer to write a plugin for you. 8)

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: How to override frontend language by url parameter?

Post by gba » Tue Apr 13, 2021 11:14 am

Hello!

Thank you for your hints, too.

As my requests seem to have led to misunderstandings, I try to clear up / consolidate:
Originally I asked for a hint how to achieve the goal described in the initial post of this thread using native Joomla functions.
Then I was told by SharkyKZ, that Joomla does not provide with such a function natively and that I would have need to write a plugin for that purpose.
As it might be noticable in my posts I do know how to write Joomla extensions (including plugins) and I am actually willing to do that.

All I am trying to find out is:
Which lever do I have to move in Joomla (using a plugin) to enable the system to override the frontend language by using an URL parameter in a component call?

I would be very grateful for any help in finding that "lever".
Thank you all very much in advance!

Kind regards,
Gerald

gba
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Tue Jun 03, 2014 3:37 pm

Re: How to override frontend language by url parameter?

Post by gba » Thu Oct 14, 2021 9:58 am

Your help still is very much appreciated :)


Locked

Return to “Joomla! 3.x Coding”