Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Display image according to the language

Display image according to the language

Locked

Views: 3,237

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
26 Apr 2008, 8:32 PM
#1
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Display image according to the language

Good afternoon!

I'm looking for a way to link a image with a selected language .

This background image is actualy displaying navigation menus, so I need it to display in the correct language!

I've created the two images and called them

topmenubg_english.gif
topmenubg_french.gif

My site works fine right now with the english image always showing, whether the language is english or french.

the file current image used is topmenubg.gif

I found mention of it in this file, but don't know what to do with this information

/includes/templates/(CUSTOM-TEMPLATE)/css/colors.css

#navMain { background-color: #FFFFFF; background-image: url('../images/topmenubg.gif'); background-repeat: no-repeat }

Is there a way for me to program something like:

If language is = english, ('../images/topmenubg_english.gif')
else ('../images/topmenubg_french.gif')

or sometime along those lines???

26 Apr 2008, 11:36 PM
#2
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

It's much easier. It's built into Zen Cart that a stylesheet called french_stylesheet.css will load automatically, but only when the site is displaying pages in French (works for other languages too).

28 Apr 2008, 4:52 PM
#3
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

really?!

great!! that program never cease to amaze me

ok so, would that new file (french_stylesheet.css) be in the same folder as the other css files?

right now, I have:
/includes/templates/(CUSTOM-TEMPLATE)/css/

colors.css
layout.css
stylesheet.css
print_stylesheet.css
<-- french_stylesheet.css goes here?

and should I ONLY write the line concerning my image in that css file? or do I need to copy-paste the english css and modify the line concerning my image?

28 Apr 2008, 5:02 PM
#4
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

Oui! oui, oui et non.

28 Apr 2008, 5:11 PM
#5
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

haha :laugh: :P

non à quoi au juste?

non to
I ONLY write the line concerning my image

or

non to
copy-paste the original css and modify the line for my image

(btw, thanks a lot kuroi :D)

28 Apr 2008, 5:15 PM
#6
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

non to
copy-paste the original css and modify the line for my image

You only to to change the line the has the location of the image that you wish to vary by language.

28 Apr 2008, 5:19 PM
#7
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

Many, many thanks! :smartalec:

Have a great day

28 Apr 2008, 7:30 PM
#8
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

It worked perflectly!

I have another question, in the same track...

I now have two different navbar image, one for each language of my site

However, the "help-tip" is still only in english (what displays when you leave the cursor on a link for a second or two)

I know that these "help-tips" are defined here:
includes/templates/CUSTOM-TEMPLATE/common/tpl_main_page.php

[I erase some of the code in the example below, just for clarity]

<div id="navMain"> <a href="index.php"> alt="Home" <a href="index.php?main_page=login"> alt="My Account" <a href="index.php?main_page=logoff"> alt="Log Out my account" <a href="index.php?main_page=shopping_cart"> alt="Shopping Cart" <a href="index.php?main_page=checkout_shipping"> alt="Checkout"

I tried copying the tpl_main_page.php and renaming it french_tpl_main_page.php and modifying the line for the help-tips but it doesnt work

Is there a way to do this?!
(I could live without but since the other question was so easily answered, I figured it would be stupid not to ask! :smile:)

28 Apr 2008, 10:39 PM
#9
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

If you have anything even closely resembling that in your tpl_main_page.php file, then I'm not surprised that it's not doing what it's supposed to.

That code has a long list of problems and clearly couldn't work, but I have no way of knowing which are problems on your site, and which you have introduced by editing the code before posting it here, so it would be a waste of time for me to prepare more detailed comments on it.

28 Apr 2008, 11:33 PM
#10
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

I fear that I didn't explain too clearly.. :blink: :laugh:

I simply meant to show what help-tips I was talking about..

"Home Page"
"My Account"
"Log Out my account"
"Shopping Cart"
"Checkout Now"

The actual code that I have in
includes/templates/CUSTOM-TEMPLATE/common/tpl_main_page.php

is

<div id="navMain">
<a href="index.php">
<img src="includes/templates/S12_Mountain/images/spacer.gif" alt="Home Page" width="96" height="44" border="0" /></a>
<a href="index.php?main_page=login">
<img src="includes/templates/S12_Mountain/images/spacer.gif" alt="My Account" width="114" height="44" border="0" /></a>
<a href="index.php?main_page=logoff">
<img src="includes/templates/S12_Mountain/images/spacer.gif" alt="Log Out of My Account" width="89" height="44" border="0" /></a>
<a href="index.php?main_page=shopping_cart">
<img src="includes/templates/S12_Mountain/images/spacer.gif" alt="Shopping Cart" width="131" height="44" border="0" /></a>
<a href="index.php?main_page=checkout_shipping">
<img src="includes/templates/S12_Mountain/images/spacer.gif" alt="Checkout Now" width="106" height="44" border="0" /></a>
</div>

The result I aiming at is to have an english tpl_main_page.php (as shown above)
and a french tpl_main_page.php, with the help-tips being:

"Acceuil"
"Mon Compte"
"Log Out"
"Mon Panier"
"Acheter Maintenant"

Sorry about the misunderstanding :blush:

28 Apr 2008, 11:42 PM
#11
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

If you actually have this block of code in your tpl_main_page.php, then that's a problem. Are you perhaps using a commercial template that hasn't been properly constructed?

This code would normally be in the the tpl_header.php, but more significantly, instead of having the "alt text" hard-coded into the php file, php constants such as HEADER_TITLE_CHECKOUT would be used. Zen Cart then automatically defines these constants according to which language is being used.

29 Apr 2008, 12:25 AM
#12
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

yes, I am using a template that I did not create myself (I bought it - I don't know if it's against forum regulation to post outside links soI wont say where I bought it)

and it is working great in english (I guess the creator didn't plan on anybody using french on it)

here my site:

https://www.jd-unique.com

.. you did give me the idea to use custom constant that I could create, though

I hadnt thought of that

In what file should I define the value of the constant?
english.php and french.php!?

I'll work on it tomorrow

many thanks again! :)

29 Apr 2008, 12:45 AM
#13
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

humm..

you are right, these seems to be already define in my
/includes/templates/CUSTOM-TEMPLATE/common/tpl_header.php

why would my template have this (with defined constant) and have another file which overrides it with its hardcoded values...

<div id="navMainWrapper">
<div id="navMain">
    <ul class="back">
    <li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>
<?php if ($_SESSION['customer_id']) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
<?php
      } else {
        if (STORE_STATUS == '0') {
?>
    <li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
    <li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
    <li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
<?php }?>
</ul>
</div>
29 Apr 2008, 12:55 AM
#14
kuroi avatar

kuroi

Totally Zenned

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

Re: Display image according to the language

The author of your template is using image substitution so wanted to fix some things and use different HTML markup to achieve this. But he (for I believe that it is a "he" who built this template!) went too far.

Your image markup should follow his structure to avoid breaking the look & feel, but to insert the constants use the following model for the image tags

<img src="blah blah" alt="<?php echo HEADER_TITLE_CART_CONTENTS ?>" width="blah blah" height="blah blah" />

I'd define the constants in the header.php files in your languages/english/YOUR_TEMPLATE and languages/french/YOUR_TEMPLATE folders. You may even find some useful constants already defined.

29 Apr 2008, 12:59 AM
#15
jdunique avatar

jdunique

New Zenner

Join Date:
Apr 2008
Location:
Montreal, Quebec, Canada
Posts:
28
Plugin Contributions:
0

Re: Display image according to the language

:D kuroi, I'd kiss you if I weren't married :smartalec:

Thanks a million time

this forum, and everyone contributing, is simply awesome

cheers!