Tip & Tricks: add language strings in overrides

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Post Reply
User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Tip & Tricks: add language strings in overrides

Post by infograf768 » Wed Oct 17, 2007 10:16 am

Just add in each override

JPlugin::loadLanguage( 'tpl_nameoftemplate' );

Then add the strings in the en-GB.tpl_nameoftemplate.ini file frontend file.

Enjoy !

EDIT:
Other solution

$lang =& JFactory::getLanguage();
$lang->load('tpl_nameoftemplate', JPATH_SITE); // or JPATH_ADMINISTRATOR if the template language file is only present in the admin language folder(s)
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by Jinx » Sat Oct 20, 2007 6:03 pm

Good find JM, a quick note though, the JPlugin::loadLanguage is not intended to be used in template override scope. I can not guarantee that this method will keep functioning in future versions.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Tip & Tricks: add language strings in overrides

Post by infograf768 » Sun Oct 21, 2007 4:22 am

I guess you guys will devise a better way to get the overrides to accept language strings in future versions (although keeping this works OK).
In the meanwhile, this will help all template designers and does not cost one line of code.  ;)
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

fleuveblanc
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Jun 24, 2008 8:04 am

Re: Tip & Tricks: add language strings in overrides

Post by fleuveblanc » Tue Jun 24, 2008 3:24 pm

Hello,

I'm sory but i don't understand where the en-GB.tpl_nameoftemplate.ini file has to be saved. Can you be more specific ?

Thanks

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Tip & Tricks: add language strings in overrides

Post by infograf768 » Tue Jun 24, 2008 3:41 pm

fleuveblanc wrote:Hello,

I'm sory but i don't understand where the en-GB.tpl_nameoftemplate.ini file has to be saved. Can you be more specific ?

Thanks
Some templates do not have that file, others do (milkyway).
If it does not exist, create it in languages/en-GB/
The file can also be loaded in a template package with the following tags in the xml

Code: Select all

<languages>
		<language tag="en-GB">en-GB.name_of_template.ini</language>
</languages>
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

Mello
Joomla! Intern
Joomla! Intern
Posts: 98
Joined: Fri Jan 25, 2008 8:12 am
Location: Kuwait
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by Mello » Sat Jul 19, 2008 6:49 pm

thanks for the TIP
but I couldn't understand the thread if you got any full reference for overrides and the benefits of it
Please advice

thanks again
Mestslm Rady Be Tab3ek, 3sfor Fe El-7elm Masaknk :: Me7tar 3la Shat Shafayfk, Dh 3tor El Koon Men Ward
Rosheha Nasyeny Meen ANA!
My Hosting Company : http://www.sz4h.com

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Tip & Tricks: add language strings in overrides

Post by infograf768 » Sun Jul 20, 2008 7:05 am

This is used when you have occurences of JText in the index.php of your template and the template is distributed over the Net to people not using the same language as yours.

Example for Milkyway:

Code: Select all

<p id="power_by">
<?php echo JText::_('Powered by') ?> <a href="http://www.joomla.org">Joomla!</a>.
<?php echo JText::_('Valid') ?> <a href="http://validator.w3.org/check/referer">XHTML</a> <?php echo JText::_('and') ?> <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>.
</p>
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

nono_kaki
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Tue Apr 14, 2009 8:16 am
Location: Makassar, Indonesia
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by nono_kaki » Mon Jun 01, 2009 1:30 pm

I'm newbie here, so I've got to subscribe this...
Thanks... :laugh: :laugh:

User avatar
Macsimice
Joomla! Explorer
Joomla! Explorer
Posts: 331
Joined: Sun Mar 18, 2007 12:50 pm
Location: Netherlands
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by Macsimice » Sat Oct 31, 2009 12:07 pm

Thanks!
Cheers, Babs
-------------------
http://crossinghippos.com

User avatar
joomfriend
Joomla! Explorer
Joomla! Explorer
Posts: 284
Joined: Sun Feb 08, 2009 5:10 pm
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by joomfriend » Mon Dec 07, 2009 5:23 am

Thanks very much infograf768. Great Tip.
- https://www.adelnipet.com: Adelni Pet - Your Social Pet Network
- https://www.egliseprimitive.org: Christian Website

orjinal textil
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Feb 09, 2010 7:17 pm
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by orjinal textil » Sun Feb 14, 2010 10:54 am

Thanks infograf768.

modhumiah
Joomla! Intern
Joomla! Intern
Posts: 56
Joined: Wed Feb 24, 2010 2:14 am

Re: Tip & Tricks: add language strings in overrides

Post by modhumiah » Sun Mar 07, 2010 3:27 pm

@infograf768

Thank you very much. It was very helpfull.

Batouta
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Tue May 25, 2010 9:29 am

Re: Tip & Tricks: add language strings in overrides

Post by Batouta » Tue May 25, 2010 10:08 am

Thanks for the tips !
Merci pour l'astuce :)
Développeur web:
http://www.yootint.com/ - Site corporate pour la pose de vitre teintée pour auto.

Armon99
Joomla! Intern
Joomla! Intern
Posts: 98
Joined: Mon Jan 04, 2010 7:38 am

Re: Tip & Tricks: add language strings in overrides

Post by Armon99 » Wed Jun 30, 2010 7:12 am

To: infograf768

About, Just add in each override

JPlugin::loadLanguage( 'tpl_nameoftemplate' );

Then add the strings in the en-GB.tpl_nameoftemplate.ini file frontend file.

Hi
I am new in all this but learning :) Please, i like to know when this become useful. I would have thought that most template would come with English as the main language. Is this plugin for other languages?

KDavid01
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Jun 21, 2010 11:56 am

Re: Tip & Tricks: add language strings in overrides

Post by KDavid01 » Wed Jul 14, 2010 6:08 am

infograf768 wrote:I guess you guys will devise a better way to get the overrides to accept language strings in future versions (although keeping this works OK).
In the meanwhile, this will help all template designers and does not cost one line of code.  ;)
I am agree with you.

David.

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: Tip & Tricks: add language strings in overrides

Post by Geraint » Tue Aug 31, 2010 8:53 am

I wrote a very small plugin that does this for all components and addons (as well as Joomla core translation strings) so that it can be applied to any template with no code changes and can maintain separate translations in different addons (in case the same string is repeated).

See http://extensions.joomla.org/extensions ... tion/13147

Geraint

User avatar
ChiefGoFor
Joomla! Champion
Joomla! Champion
Posts: 5614
Joined: Tue Sep 13, 2005 12:22 am
Location: Omaha, Nebraska, USA
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by ChiefGoFor » Tue Oct 19, 2010 4:26 am

@Geraint - Thank you! It works beautifully! You just saved me a couple hours of coding. ;)

Five free Internets for you!
Joomla! ...because open source matters
"Try to answer two questions for every one question you ask." - Me

f1b0n4cc1
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Fri May 28, 2010 4:10 pm
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by f1b0n4cc1 » Sun Oct 31, 2010 7:16 pm

anybody checked this if have problem with joomfish component ?
Please read forum rules regarding signatures: http://forum.joomla.org/viewtopic.php?t=65

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: Tip & Tricks: add language strings in overrides

Post by Geraint » Wed Nov 03, 2010 3:27 pm

As the co-author of Joomfish I can confirm that this should have no impact on the behaviour joomfish.

This addon works on the Joomla language string translation and not your website content.

trytony
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Mar 16, 2011 3:40 pm

Re: Tip & Tricks: add language strings in overrides

Post by trytony » Wed Mar 16, 2011 3:51 pm

Wow.. Thank you, Thank you, Thank you!!!

pauleffah
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Fri Jun 03, 2011 12:22 pm

Re: Tip & Tricks: add language strings in overrides

Post by pauleffah » Fri Jun 03, 2011 12:40 pm

Guys pls help me out on this topic. I get it when installing templates.

"Error! Could not find an XML setup file in the package" via the link below

http://forum.joomla.org/viewtopic.php?f=469&t=625543

User avatar
enbees
Joomla! Guru
Joomla! Guru
Posts: 860
Joined: Mon Sep 20, 2010 7:58 am
Location: Jakarta - Indonesia
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by enbees » Sun Sep 11, 2011 6:17 am

infograf768 wrote:Just add in each override

JPlugin::loadLanguage( 'tpl_nameoftemplate' );

Then add the strings in the en-GB.tpl_nameoftemplate.ini file frontend file.

Enjoy !
Hi, infograf768

I'm in the process of overriding the output of com_search in J! 1.7 Frontend and try to use the trick above.

1. I edit the default_result.php, and then put the file in the template HTML folder, as for template override in Beez5.

Code: Select all

<?php 
	echo JText::sprintf('TPL_BEEZ5_COM_SEARCH_CATEGORY', $url); 				
?>
2. Edit the en-GB.tpl_beez5.ini, by inserting a new entry

Code: Select all

TPL_BEEZ5_COM_SEARCH_CATEGORY="%s"
It work perfectly without JPlugin::loadLanguage( 'tpl_nameoftemplate' );

My question, is it okay for J! 1.7 and how to use the
JPlugin::loadLanguage( 'tpl_nameoftemplate' );
in my case?

Thanks
Regards,
enbees, I'm here: http://koperasoft.com

gfxcasa
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Sep 15, 2011 11:51 am
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by gfxcasa » Thu Sep 15, 2011 11:54 am

Thank you very much infograf768. It was very helpfull

User avatar
sakiss
Joomla! Explorer
Joomla! Explorer
Posts: 349
Joined: Wed Aug 20, 2008 4:09 pm

Re: Tip & Tricks: add language strings in overrides

Post by sakiss » Wed Nov 16, 2011 6:06 pm

Thank you!!

aakashdavis
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Sat Apr 21, 2012 3:19 am
Location: India
Contact:

Re: Tip & Tricks: add language strings in overrides

Post by aakashdavis » Sat Apr 21, 2012 3:59 am

Thanks infograf768.
~Aakash
A computer once beat me at chess, but it was no match for me at kick boxing
http://akashtablet.in/
Moving http://aadhaaruid.org/ from WP to Joomla

shaji
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Wed Apr 10, 2013 10:09 am

Re: Tip & Tricks: add language strings in overrides

Post by shaji » Fri Jul 05, 2013 2:24 pm

Hi
Right now you can also do this using either method and add language strings in overrides is better?
also Joomla language string translation ?
What about other languages ​​like Arabic and Turkish?

Here can I get more information about this topic?
http://docs.joomla.org/Category:Tips_and_tricks

If you know, please introduce other sources on this topic
Thank you
http://karajab.ir/ . http://tehranab.ir/
Thank you so very much for making Joomla the best CMS on the planet!


Post Reply

Return to “Templates for Joomla! 1.5”