Fórum

Velocity template for webcontent and localization

Becas Vasilis, modificado 11 Anos atrás.

Velocity template for webcontent and localization

Junior Member Postagens: 28 Data de Entrada: 30/08/12 Postagens Recentes
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:


<h1> $reserved-article-title.getData()</h1>
<div id="myarticle">
    <div class="articleImage">
        <img alt="" src="$image.getData()">
    </div>
    <div class="descriptionArticle">
        $description.getData()
    </div>
    <hr>
    <h2>More Info</h2>   &lt;--- Localized value??
    <div class="moreInfo">
    $preparation.getData()
    </div>
</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, modificado 11 Anos atrás.

RE: Velocity template for webcontent and localization

Junior Member Postagens: 68 Data de Entrada: 30/01/12 Postagens Recentes
can you check this post?
http://www.liferay.com/community/forums/-/message_boards/message/10703201

HTH
Becas Vasilis, modificado 11 Anos atrás.

RE: Velocity template for webcontent and localization

Junior Member Postagens: 28 Data de Entrada: 30/08/12 Postagens Recentes
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.


<h1> $reserved-article-title.getData()</h1>  [b]&lt;-- USER INPUT. Localization OK[/b]
<div id="myarticle">
    <div class="articleImage">
        <img alt="" src="$image.getData()"> [b]&lt;-- USER INPUT. Localization OK[/b]
    </div>
    <div class="descriptionArticle">
        $description.getData() [b]&lt;-- USER INPUT. Localization OK[/b]
    </div>
    <hr>
    <h2>More Info</h2>   [b]&lt;--- Localized value here?? Static text[/b]
    <div class="moreInfo">
    $preparation.getData() [b]&lt;-- USER INPUT. Localization OK[/b]
    </div>
</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
thumbnail
Amos Fong, modificado 11 Anos atrás.

RE: Velocity template for webcontent and localization (Resposta)

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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
thumbnail
Jacques Traore, modificado 9 Anos atrás.

RE: Velocity template for webcontent and localization

Junior Member Postagens: 49 Data de Entrada: 21/01/13 Postagens Recentes
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