Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Becas Kostas
Velocity template for webcontent and localization
September 26, 2012 6:27 AM
Answer

Becas Kostas

Rank: Junior Member

Posts: 28

Join Date: August 30, 2012

Recent Posts

Hey,

I am not sure if my post is in right section, but is relevant for sure.

I have created a a new web content structure with 3 fields. Description, Image and MoreInfo.

I have created also a template (using velocity) for that structure. The template looks something like this:

 1
 2<h1> $reserved-article-title.getData()</h1>
 3<div id="myarticle">
 4    <div class="articleImage">
 5        <img alt="" src="$image.getData()" />
 6    </div>
 7    <div class="descriptionArticle">
 8        $description.getData()
 9    </div>
10    <hr>
11    <h2>More Info</h2>   <--- Localized value??
12    <div class="moreInfo">
13    $preparation.getData()
14    </div>
15</div>


Is it possible to get the localized value for More Info in <h2></h2>

I tried #set ($a = $languageUtil.get($locale, “more-info”))

and then

<h2> $a </h2>

But i get an error. Maybe the above solution works only for theme templating(?)
Any help to archive that would be great.

With Regards,
Vasilis
Prasanna Raj
RE: Velocity template for webcontent and localization
September 26, 2012 9:55 AM
Answer

Prasanna Raj

Rank: Junior Member

Posts: 69

Join Date: January 30, 2012

Recent Posts

can you check this post?
http://www.liferay.com/community/forums/-/message_boards/message/10703201

HTH
Becas Kostas
RE: Velocity template for webcontent and localization
September 27, 2012 12:59 AM
Answer

Becas Kostas

Rank: Junior Member

Posts: 28

Join Date: August 30, 2012

Recent Posts

Hey Prasanna,

Thanks for the response, but i do not see how that can help me. I can use the localization for the structure fields with no problem.
My problem is using localization inside the velocity template for non user inputs.
As i said in my previous post.

 1
 2<h1> $reserved-article-title.getData()</h1>  [b]<-- USER INPUT. Localization OK[/b]
 3<div id="myarticle">
 4    <div class="articleImage">
 5        <img alt="" src="$image.getData()" /> [b]<-- USER INPUT. Localization OK[/b]
 6    </div>
 7    <div class="descriptionArticle">
 8        $description.getData() [b]<-- USER INPUT. Localization OK[/b]
 9    </div>
10    <hr>
11    <h2>More Info</h2>   [b]<--- Localized value here?? Static text[/b]
12    <div class="moreInfo">
13    $preparation.getData() [b]<-- USER INPUT. Localization OK[/b]
14    </div>
15</div>


So my problem is using localization for the static text above. Not the user inputs. With that i do not have a problem.

Thanks
Amos Fong
RE: Velocity template for webcontent and localization
September 27, 2012 2:36 AM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1954

Join Date: October 7, 2008

Recent Posts

If this is an already existing language key or you can add a language key through a hook, you can use:

$languageUtil.get($locale, "more-info")

Otherwise, you'll probably have to do something like:

#if ($locale.toString().equals("xxx"))
More info
#elseif (...)
More info in spanish
#elseif (...)
more info in german
#end
Jacques Traore
RE: Velocity template for webcontent and localization
September 4, 2014 8:13 AM
Answer

Jacques Traore

Rank: Junior Member

Posts: 47

Join Date: January 21, 2013

Recent Posts

Hi everyone,
Is there any way to force localization of a user input in velocity template (LF 6.2 CE)?
This is the requirement:
- Before liferay 6.2 there was a localization checkbox when creating custom structure. If a user input is not specified as localizable then the default one will be fetched in the template.
- In 6.2, that checbox is no longer available. Instead of editing all contents with that structure, I wanted to modify the template to get the English data for some specific fields (like Firstname, Lastname, Picture, ...).

Thanks in advance

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!