Forums / Addon Language Packs / tpl_footer & tpl_header text based on language

tpl_footer & tpl_header text based on language

Locked

Views: 5,789

Results 1 to 20 of 25
This thread is locked. New replies are disabled.
24 Oct 2008, 7:33 AM
#1
shocker avatar

shocker

Zen Follower

Join Date:
Jul 2007
Location:
Jakarta
Posts:
346
Plugin Contributions:
0

tpl_footer & tpl_header text based on language

I want to control a small snippet of text in the my header and footer depending the language chosen.

Can anyone give me a code snippet that I can stick into the header and footer files to check for this?

24 Oct 2008, 7:56 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: tpl_footer & tpl_header text based on language

echo MY_TEXT
and then define MY_TEXT in the language file for each language. E.g.
define('MY_TEXT','Hello'); in english.php
define('MY_TEXT','Bonjour'); in french.php
define('MY_TEXT','Hola'); in spanish.php

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

24 Oct 2008, 8:08 AM
#3
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: tpl_footer & tpl_header text based on language

Define the text as the value of a constant in a language file, and it will be swapped automatically when you switch languages.

You should have a separate version of all language files for each language.

...Like Kuroi describes above...

24 Oct 2008, 8:08 AM
#4
shocker avatar

shocker

Zen Follower

Join Date:
Jul 2007
Location:
Jakarta
Posts:
346
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

kuroi:

and then define MY_TEXT in the language file for each language. E.g.

Wow! Thanks! That was easy.

24 Oct 2008, 8:12 AM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: tpl_footer & tpl_header text based on language

Zen Cart Magic

:jawdrop:

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

26 Dec 2008, 6:53 AM
#6
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

I've been attempting to put the information in this thread to use but have run into a snag - I can't really get my head around the logic.

I would like to have a home link in the header for each of the two site languages, each leading to their respective home locations. I've added this to tpl_header.php:

<li><?php echo '<a href="' . zen_href_link(FILENAME_HOME_IT, '', 'SSL') . '">' . BOX_INFORMATION_HOME_IT . '</a>'; ?></li>

and defined it in italian.php. On the Italian side it works as intended. However, on the English side, in the header bar, you see:

BOX_INFORMATION_HOME_IT
Since the tpl_header.php file is not located in a language file, it makes sense that it would be visible, but I can't quite immagine how to properly resolve it. Can I just add a language file within my includes/templates/my_template/? Somehow that doesn't seem quite kosher...

26 Dec 2008, 7:11 AM
#7
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

Hmmm... OK, after re-reading what I posted it occured to me that I had not defined the English side of things. So, in english.php:

// Italian language home link
define('BOX_INFORMATION_HOME_IT', '');
Leaving it blank seemed to work.

Now, how can I properly direct this link to the Italian language home page?

<li><?php echo '<a href="' . zen_href_link(FILENAME_HOME_IT, '', 'SSL') . '">' . BOX_INFORMATION_HOME_IT . '</a>'; ?></li>

Usually I would do something like:

<li class="submenu"><a href="http://www.beadedlilydesigns.com/?language=it">Home</a>

but then the file names are not being utilized and so wouldn't be recognized by the language files, right? :blink: Ow - My head!!

27 Dec 2008, 2:36 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: tpl_footer & tpl_header text based on language

If you are wanting to (say) go to the Italian homepage from an English page, you would also (first) want to switch the language setting. When that happens, the home page will show in Italian, and the rest of the site will display in Italian until you switch back to English.
Or are you not wanting to switch languages in the session? That sounds tricky, forcing the page to display in a language other than the one set. You might be able to force it by adding to the url "&language=italian" in whatever form that should take... maybe?? Would that reset the session value?? Would it be read by the files using $_SESSION['language'] ?

Yes. my head hurts too...

27 Dec 2008, 2:45 AM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: tpl_footer & tpl_header text based on language

The page is not a single file, and the language files are called by the destination files, not in the url. I think you will need to make the session language switch before the homepage link happens, or maybe you can do them simultaneously. Is that something that javascript can do that PHP can't?

27 Dec 2008, 2:49 AM
#10
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

If I remember correctly, zen stores the language you selects in session. So the language param appears in the url only at the first time you select the language.
So if you visit a page for too long and the session expires, then you are switched back to the default languages.

Most seo modules (excluding ultimate seo url, I believe) addresses this problem by always inserting the language code in the links.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

27 Dec 2008, 4:09 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: tpl_footer & tpl_header text based on language

Then perhaps integrating the language call into the url will reset the session language?
If that is so, I don't think it is necessary to try to call the "Italian homepage"; call the homepage with the language parameter and you will be set. Try it and see.

27 Dec 2008, 6:09 AM
#12
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

The need for my attempt to alter the header link is based on the fact that originally, after installing the second language, the home link on the Italian page took me not to the Italian home but to the English home page. It happens also in this site from the Zen showcase. Switch languages, visit a different page and then return to the home page using the header home link - The language defaults back to English. I would prefer that Italian customers are able to shop in Italian unless they intentionally switch back to English.

I have been able to make the proper changes so that each language has their own header home link. It seems to me that all I would need to do at this point is properly configure the destination of the Italian side:

<li><?php echo '<a href="' . zen_href_link(FILENAME_HOME_IT, '', 'SSL') . '">' . BOX_INFORMATION_HOME_IT . '</a>'; ?></li>

Within Zen, how can I point BOX_INFORMATION_HOME_IT to beadedlilydesigns.com/?language=it?

27 Dec 2008, 6:33 AM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: tpl_footer & tpl_header text based on language

You know, that sounds like an unintended behavior... perhaps even to be called a bug. It certainly doesn't seem like the way I would want a site to work.
Posting in the bug reports might get a method for fixing the underlying behavior.

27 Dec 2008, 6:50 AM
#14
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

gjh42:

You know, that sounds like an unintended behavior... perhaps even to be called a bug. It certainly doesn't seem like the way I would want a site to work.
Posting in the bug reports might get a method for fixing the underlying behavior.

Will do, Glenn - In the interim, do you know how to define the location of a "constant" such as my self-created Italian home link BOX_INFORMATION_HOME_IT? If I can define the destination properly, it should utilize the language file system and return to the Italian home page, as HEADER_TITLE_CATALOG does for the English side.

Thanks

27 Dec 2008, 6:52 AM
#15
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

Did you change the default language in admin btw?

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

27 Dec 2008, 6:56 AM
#16
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

yellow1912:

Did you change the default language in admin btw?

In what way? I do switch back and forth between languages...

27 Dec 2008, 7:06 AM
#17
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

MeltDown:

In what way? I do switch back and forth between languages...
You can set the default language by going to
admin/languages.php

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

27 Dec 2008, 7:12 AM
#18
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

Oh, I see what you mean - Yes, Italian is also defined at admin/languages with English as the default.

27 Dec 2008, 7:22 AM
#19
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

MeltDown:

The need for my attempt to alter the header link is based on the fact that originally, after installing the second language, the home link on the Italian page took me not to the Italian home but to the English home page. It happens also in this site from the Zen showcase. Switch languages, visit a different page and then return to the home page using the header home link - The language defaults back to English. I would prefer that Italian customers are able to shop in Italian unless they intentionally switch back to English.

I have been able to make the proper changes so that each language has their own header home link. It seems to me that all I would need to do at this point is properly configure the destination of the Italian side:

Within Zen, how can I point BOX_INFORMATION_HOME_IT to beadedlilydesigns.com/?language=it?

On the site you showed, after I switched the lang and goes back to home, I still see the home in the lang I chose. Unless you waited too long so that the session is expired, you should not see the (wrong) behavior you mentioned.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

27 Dec 2008, 12:16 PM
#20
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: tpl_footer & tpl_header text based on language

Yellow - Please be certain that you are truly seeing the correct pages, as I do not yet have language buttons and the main text on each home page was in English. I have now removed the English text from the Italian home page.

This link will bring you to the Italian home page. Please go to another page and then return using the home link located in the header. Probably you will not be able to as the link destination has yet to be defined.

Thanks