constant with default values

General questions regarding the use of languages in Joomla! 4.x.

Moderator: 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
User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

constant with default values

Post by Dangerous Boy » Thu Nov 18, 2021 6:03 pm

Not sure if this goes here, may be in coding... ???

when declaring a new contant for module, component or in template with overrides works fine when working with a single language, but on multi-language it doesn't
Say you do a new override MY_NEW_CONSTANT="New item %s" inside en-GB.override.ini, but if the a new language is installed your constant is not use.

Code: Select all

<?php echo JText::_('MY_NEW_CONSTANT', $this->item->relation[$i]->title); ?>
Normally it will show New item Boxer M234, but because of the new language instead it shows
MY_NEW_CONSTANT
So, how can I tell to use my default override, which in any case it will be en-GB.override.ini ... ?
<?php echo JText::_('MY_NEW_CONSTANT', $this->item->relation[$i]->title)->default('New item %s'); ?>
Nothing for the moment....

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

Re: constant with default values

Post by Webdongle » Thu Nov 18, 2021 6:07 pm

Do you not need to put the constant in the override of the other 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".

User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Re: constant with default values

Post by Dangerous Boy » Thu Nov 18, 2021 6:20 pm

Yes, that is true, and for any other new language a new override has to be made with any custom constant, but while that is done no translation is shown...
Nothing for the moment....

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

Re: constant with default values

Post by Webdongle » Thu Nov 18, 2021 8:25 pm

So when you create a new override for a different language
1. You select that language in the language override e.g. French (fr-FR) -site
2, Create the override so it becomes creates the frFR.override.ini
Is that correct?
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".

User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Re: constant with default values

Post by Dangerous Boy » Thu Nov 18, 2021 9:39 pm

Yes that is correct, and it works fine when working with 4 or even 10 languages... it gets "complicated" when working with 20 plus custom languages such as en-CA, fr-CA, de-NL, de-DE, fr-BE, de-BE, de-NL...es-MX, es-CO, es-AR, es-PU... etc and you end up with 30+ languages and each has about 80 to 100+ custom constant...
Nothing for the moment....

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

Re: constant with default values

Post by Webdongle » Thu Nov 18, 2021 10:01 pm

afaik that is the only way of doing it.
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".

User avatar
Dangerous Boy
Joomla! Explorer
Joomla! Explorer
Posts: 255
Joined: Mon Dec 26, 2005 6:25 pm
Location: Home

Re: constant with default values

Post by Dangerous Boy » Fri Nov 19, 2021 4:19 am

Yup, for Joomla! v3 I did my own helper class for stuff like this, I guess I'll have to do the same...

Thanks.
Nothing for the moment....


Post Reply

Return to “Language - Joomla! 4.x”