Template override language localization

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.
Locked
mehdid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 16, 2008 6:48 pm

Template override language localization

Post by mehdid » Thu Oct 16, 2008 6:51 pm

Hi !

I'm wondering if I can add localization to my template...
i.e. I'm overriding some of my modules and components views, and I'm using customized strings. I'd like them to be available in both english and french.
Can I do that from within my template, or do I have to manually modify each module ?

Thx a lot for your help !

Mehdi
Last edited by mehdid on Sat Oct 18, 2008 7:16 pm, edited 1 time in total.

User avatar
juicymedia
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Wed Jun 20, 2007 8:56 am
Location: Preston, UK
Contact:

Re: Template localization

Post by juicymedia » Fri Oct 17, 2008 10:34 am

Have you checked out JoomFish?

This is the simplest way to deal with multi-lingual content and we've used it on many commercial clients. Of course, if you just want the Joomla shell to be converted you can download the seperate language packs.
Juicy Media - Bespoke Joomla & Open-Source Development
www.juicymedia.co.uk

mehdid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 16, 2008 6:48 pm

Re: Template localization

Post by mehdid » Fri Oct 17, 2008 11:06 am

I'm talking about a few strings only, so I wouldn't want to use JoomFish for just a few of them ! Thx for the idea though ! :D

User avatar
juicymedia
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Wed Jun 20, 2007 8:56 am
Location: Preston, UK
Contact:

Re: Template localization

Post by juicymedia » Fri Oct 17, 2008 11:22 am

Is the text stored within the template? For example is it contained within:

Code: Select all

<?php echo JText::_('My Custom Text') ?>
If so, you can create a new localised language folder 'en-GB' with the file 'en-GB.ini' for example, that contains the text definition:

Code: Select all

MY CUSTOM TEXT=My Translated Text
Just an idea.
Juicy Media - Bespoke Joomla & Open-Source Development
www.juicymedia.co.uk

mehdid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 16, 2008 6:48 pm

Re: Template localization

Post by mehdid » Fri Oct 17, 2008 3:24 pm

Yes, that's the kind of structure I was looking for, but didn't know how to do before I finally found out in the following link:
http://www.m65.net/article-chapter-page ... 6-209.html

I actually needed to add the following to my xml init file:

Code: Select all

<languages>
    <language tag="en-GB">en-GB.tpl_YourTemplateName.ini</language>
</languages>
and I needed to convert each of my template's static strings :

Code: Select all

<? php echo 'My static string x'; ?>
to:

Code: Select all

<?php echo JText::_('MY STATIC STRING X'); ?>
And Finally add the following files to my template's root:
en-GB.tpl_YourTemplateName.ini

Code: Select all

MY STATIC STRING 1=My static string 1
MY STATIC STRING 2=My static string 2
and
fr-FR.tpl_YourTemplateName.ini

Code: Select all

MY STATIC STRING 1=Ma chaine statique 1
MY STATIC STRING 2=Ma chaine statique 2
Got it now...

Thanks for your help...

mehdid
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 16, 2008 6:48 pm

Re: Template localization

Post by mehdid » Sat Oct 18, 2008 7:15 pm

I forgot to say...

You need to add the following line of code to the very beginning of each of your template override file (default_item.php in com_content/frontpage):

Code: Select all

JPlugin::loadLanguage('tpl_myTemplateName');
Mehdi


Locked

Return to “Templates for Joomla! 1.5”