Developer forum

Forum » Templates » "Translating" images on multilingual sites

"Translating" images on multilingual sites

Michael Nielsen
Reply
According to this
http://templates.dynamicweb-cms.com/TemplateTags/Dynamicweb-template-tags/General-tags/Translate%28%5BKey%5D,-%5BDefault%5D%29.aspx
it should be possible to use the translate tag on attributes.

I've used it (like below) on images and links, but they do not show up in the translation area on the template.
<img src="<!--@Translate(cartstep1, '/Files/Templates/Designs/SmykkerOgUre/images/dk/step1.gif', global)-->" alt="" />
Can anyone see what I'm doing wrong or point out a solution?


Replies

 
Michael Nielsen
Reply
Managed it by doing like below, but being able to write path to images and links in the translation would be nice (as the documentation also says you can)
<!--@If(Global:Area.ID=1)-->
    <img src="/Files/Templates/Designs/SmykkerOgUre/images/dk/step2.gif" alt="" />
<!--@EndIf-->
<!--@If(Global:Area.ID=2)-->
    <img src="/Files/Templates/Designs/SmykkerOgUre/images/uk/step2.gif" alt="" />
<!--@EndIf-->
<!--@If(Global:Area.ID=3)-->
    <img src="/Files/Templates/Designs/SmykkerOgUre/images/de/step2.gif" alt="" />
<!--@EndIf-->

 
Nuno Aguiar
Reply
Hi Michael,

You forgot one important thing about Dynamicweb tags. They are case sensitive, and for that matter, the default value in a translate tag has to always be in " instead of '

I came across the same issue when they got out. It works fine though, since it's a mix of server-side with client-side, or you can simply put the html element's atribute in ' because it's equally accepted by browsers and W3C valid.

Nuno

 
David Matheson
Reply
This post has been marked as an answer
Hi,

Personally I would not use the Global:Area.ID tag for this purpose, as this links to an area and not a language.  Therefore, if you at some point redesign your site in another "area", your code would become invalid.  Instead I would use the Global.Area.Culture.CountryCode tag.
<!--@If(Global:Area.Culture.CountryCode=DK)-->
     <img src="xxx.gif" />
<!--@EndIf-->
As a simpler (and better) alternative you could hard-code your image tag as follows:
<img src="files/billeder/whatever/<!--@Global:Area.Culture.CountryCode-->/step2.gif" />
Hope this helps
// David
Votes for this answer: 0
 
Michael Nielsen
Reply
Nuno: I know it's case-sensitive, but I can't see how that applies to my problem, so please elaborate on that.

David: Excellent point about the AreaID, I will change it to use CountryCode instead, and you solution to use it in the foldername is much better as I all ready have the language based images in sperate folders.

 
Nuno Aguiar
Reply
Hi Michael,

Check out below:
<!--@Translate(cartstep1, '/Files/Templates/Designs/SmykkerOgUre/images/dk/step1.gif', global)-->
<!--@Translate(cartstep1, "/Files/Templates/Designs/SmykkerOgUre/images/dk/step1.gif", global)-->

I underlined the difference. Use the " character.

Best Regards,

 
Michael Nielsen
Reply
Hi Nuno

DW's documentation specifies that when used in attributes, the default value should be encapsulated with apostrophs

 
Mateus Ávila Isidoro
Reply
Michael

Using " instead of ' the string parses. Using ' the string not parsed.

Sorry for my english.
Mateus

 
Nuno Aguiar
Reply
Hi Michael,

Unfortunatelly, it's just how Dynamicweb is working :(

 
Michael Nielsen
Reply
Ok, so don't completely trust Dynamicweb's documentation :)

Thanks Mateus (your english is fine) and Nuno.

 
Merethe Nielsen
Reply

Hi

What's not working on your site?

Do you use 19.2.5.2? (a bug with attributes was fixed in this hotfix and now you need to encapsulate the value with ')
 

When using the translate tag as attribute in Designs, you need to encapsulate the default value with apostrophs (from version 19.2.5.2).


I have tested the same code as you on our recent version (19.2.5.4 + using Designs) and it looks like the attached picture.

Used this code:
 

<img src="<!--@Translate(cartstep1, '/Files/Templates/Designs/Condition/Index.png', global)-->" alt="" />

 


Kind regards,
Merethe
translate_example.png
 
Michael Nielsen
Reply
Yes the version is 19.2.5.2, but it might have been updated after I had this problem, I haven't tested if it works now as I chose the workaround suggested by David.

 

You must be logged in to post in the forum