Advertisement

Problem with default language in Joomla\CMS\Language\Text Topic is solved

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

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
Phalaphun
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Mar 23, 2025 11:02 pm

Problem with default language in Joomla\CMS\Language\Text

Post by Phalaphun » Sun Mar 23, 2025 11:16 pm

I am developing a component for joomla 5 for a site with three languages ru-RU zh-CN en-GB. The component is 100% translated into ru-RU.

I want the translation at the beginning to check the current language of the user, and if the translation is not found, then take ru-RU.

Now, if there is no translation zh-CN, it takes the translation en-GB.

I suspect that the problem is in the default at Text:

object(Joomla\CMS\Language\Language)#699 (23) {
["debug":protected]=
bool(false)

["default":protected]=
string(5) "en-GB"
...}

However, I was never able to change this parameter through the admin. Site language, admin language and plugin language are defaulted to ru-RU. What am I missing ?

Translated with *** URL Removed *** (free version)
Last edited by imanickam on Mon Mar 24, 2025 3:49 am, edited 1 time in total.
Reason: Removed the URL that showed a translation site. Please do not repeat this in the future. Moved the topic from the forum Language - Joomla! 5.x to the forum Joomla! 5.x Coding.

Advertisement
User avatar
ceford
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3162
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Problem with default language in Joomla\CMS\Language\Text

Post by ceford » Mon Mar 24, 2025 6:13 pm

Just a thought: go to System / Content Languages. What order are the languages in? Might a change of order give you what you want?

Phalaphun
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Mar 23, 2025 11:02 pm

Re: Problem with default language in Joomla\CMS\Language\Text

Post by Phalaphun » Mon Mar 24, 2025 11:40 pm

ceford wrote: Mon Mar 24, 2025 6:13 pm Just a thought: go to System / Content Languages. What order are the languages in? Might a change of order give you what you want?
Hello, unfortunately your idea didn't work for me.
I can always write my own wrapper for the class, but I would still like to make my own idea using the available methods (if there are any).

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 45111
Joined: Sat Apr 05, 2008 9:58 pm

Re: Problem with default language in Joomla\CMS\Language\Text

Post by Webdongle » Tue Mar 25, 2025 1:37 am

A few thoughts
Default language of your browser?
Default menu items?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Phalaphun
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Mar 23, 2025 11:02 pm

Re: Problem with default language in Joomla\CMS\Language\Text

Post by Phalaphun » Tue Mar 25, 2025 1:43 am

Webdongle wrote: Tue Mar 25, 2025 1:37 am A few thoughts
Default language of your browser?
Default menu items?
ru-RU
If I understood your second question correctly: it's featured articles, languages - all

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 45111
Joined: Sat Apr 05, 2008 9:58 pm

Re: Problem with default language in Joomla\CMS\Language\Text

Post by Webdongle » Tue Mar 25, 2025 9:41 am

Hmmm
With multi lingual sites should there be no general Home menu item, just one for each language?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

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

Re: Problem with default language in Joomla\CMS\Language\Text

Post by SharkyKZ » Tue Mar 25, 2025 9:47 am

en-GB is the default language of the CMS as a whole. It comes with en-GB language pack which can't be uninstalled. If a language file for current language doesn't exist, it falls back to en-GB. This is the intended behavior for the time being.

Since 5.0, intentionally or not, it is possible to change the default language using Joomla\Language\Language::setDefault() (technically it was always possible by extending Joomla\CMS\Language\Language). But doing this on the global language instance is not recommended. You should create a new instance and load the files however you want.

Phalaphun
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Mar 23, 2025 11:02 pm

Re: Problem with default language in Joomla\CMS\Language\Text

Post by Phalaphun » Fri Mar 28, 2025 3:30 am

SharkyKZ wrote: Tue Mar 25, 2025 9:47 am en-GB is the default language of the CMS as a whole. It comes with en-GB language pack which can't be uninstalled. If a language file for current language doesn't exist, it falls back to en-GB. This is the intended behavior for the time being.

Since 5.0, intentionally or not, it is possible to change the default language using Joomla\Language\Language::setDefault() (technically it was always possible by extending Joomla\CMS\Language\Language). But doing this on the global language instance is not recommended. You should create a new instance and load the files however you want.
Many thanks for the quick reply.

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”