how to localise texts fetched by database struts - localization

To localise any text, we do in general
index.jsp
<!--<span>hello</span>-->
<span><bean:message key="index.hello"/></span>
ApplicationResource_en.properties
index.hello=hello
ApplicationResource_es.properties
index.hello=hola
My problem is how to localise dynamic text like
index.jsp
<span><bean:write "information" property="hello" />
Please suggest ?

You can use bean:message tag instead of bean:write as following
<bean:message bundle= "bundleKey" key= "a.message" />
Bundle is the name of the locale

Related

Show Localized value for HybrisEnumValue in Hybris Backoffice

We are trying to show the localized value for a "dynamic" enum.
In our backoffice-config.xml We have something like this
<context type="CustomeType" component="base" merge-by="type">
<y:base xmlns:y="http://www.hybris.com/cockpit/config/hybris">
<y:labels>
<y:label>customProperty.hybrisEnumValueProperty.name</y:label>
</y:labels>
</y:base>
</context>
With this we receive the default TypeName(Pk) in backoffice instead of the localized name. For the code it works just fine. Also for hmc it works as well.
You need to add localization text for these enums like below.
mycoreextension-items.xml
<enumtype code="myenum" generate="true" dynamic="true">
<value code="ENUM1" />
<value code="ENUM2" />
</enumtype>
mycoreextension-locales_en.properties
type.myenum.name=My Enum Name
type.myenum.description=My enum description
type.myenum.enum1.name=My enum value 1
type.myenum.enum2.name=My enum value 1

what is the difference between grails link ,createlink and resource tags

Is there any difference between grails link ,create link and resource tags and I want to know when to use each tag as per my knowledge the createlink tag has depricated
it's simple:
g.createLink generates only the url, like /aaa/bbb/222, based on controller/action/params for example
g.link generated the <a>-HTML-tag, using the g.createLink to generate the url to be put into the #href attribute
g.resource outputs a path to a resource file, available under web-app folder
<link rel="stylesheet" href="${resource(dir:'css',file:'style.css')}" />
produces
<link rel="stylesheet" href="/css/style.css" />
CREATE LINK is soemthing power full when u come to knowing the absolute or relative path in using likes inside a gsp page.
Let assume i have the following path /yourapp/controller1/view1
Instead of using
<a href="{grailscontext.thensomebaseurlstuff}/"+controller/view /> ,
which fails according to some context using the below will make it easy.
my link
<g:createLink url="[action:'list',controller:'book']" />
And ,glink is the above implementation using taglib form.. does the same effect as above but being in taglib makes reduce some computation or create some am not sure.
g.link("text of the link here", action:"foo", controller:"bar")
ResourceTags is no wonder its something help full and important in attaching either an image,css and js folder/file resource into a grails application.
// generates "/shop/css/main.css"
<g:resource dir="css" file="main.css" />
// generates "http://portal.mygreatsite.com/css/main.css"
<g:resource dir="css" file="main.css" absolute="true" />
// generates "http://admin.mygreatsite.com/css/main.css"
<g:resource dir="css" file="main.css" base="http://admin.mygreatsite.com"/>
Alloha!

How to extend felogin's locallang?

How is it possible to add translations of strings to the felogin plugin? I slowly start to get the convention for templates (directing to the modified templates in the plugin's typoscript configuration) but that does not work with the locallang. The original messages are in English in the xlf format, located in the plugin's folder. I know this can be done in TypoScript but I do not like to have the strings defined so incosistently. (I guess modifying that original file is not the proper way.)
Overriding labels by TypoScript is the way to go. Manually editing the l10n files is a really bad idea - these files are overwritten on updating the translations. If the extension gets an update and new labels are added, you will want to perform the updates.
The change from XML files for translation to the XLIFF format didn't change anything in the best practise you should use for adjusting labels according to your needs. It's just another format with a standardized translation server (Pootle) that (in theory) allows some special features like e.g. plural forms.
Conclusion: Use TypoScript.
For the default language (no config.language set) use:
plugin.tx_felogin_pi1._LOCAL_LANG.default {
key = value
}
For a specific language, e.g. German, use
plugin.tx_felogin_pi1._LOCAL_LANG.de {
key = value
}
The best way is to use the following code:
ext_tables.php, e.g. of your theme extension with
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:felogin/Resources/Private/Language/locallang.xlf'][] = 'EXT:theme/Resources/Private/Language/locallang_felogin.xlf';
and in this file you can use something like
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2015-06-30T21:14:27Z">
<header>
<description>Language labels for felogin</description>
</header>
<body>
<trans-unit id="permalogin">
<source>An diesem Rechner angemeldet bleiben</source>
</trans-unit>
<trans-unit id="ll_forgot_header">
<source>Passwort vergessen?</source>
</trans-unit>
<trans-unit id="ll_welcome_header">
<source>Sie betreten den Händlerbereich</source>
</trans-unit>
<trans-unit id="ll_welcome_message">
<source>Bitte loggen Sie sich ein.</source>
</trans-unit>
</body>
</file>
</xliff>
You can use the BE language module to download preconfigured locallangs for every language you need.
The files are stored in e.g. typo3conf/l10n/de/fe_login.
You can edit these files manually in l10n to get your own strings inside or use an extension like snowbabal to do the editing inside a BE module.

how to translate sign under appbar buttom

Hello I want to localize text below standard AddAppBarButton
<Style x:Key="AddAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="AddAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="Add"/>
<Setter Property="Content" Value=""/>
</Style>
I've tried in Resource filead add something like
ButtonId.AutomationProperties.Name = value
But it doesn not work. I get errors when app starts. How can I trasnlate this property ?
Why not put the translation strings in resource files and let XAML parser do the work?
You need to create a folder in your project matching the locale name and put a resw file inside it, e.g sl-SI\Resources.resw.
Add x:Uid attribute to XAML elements to name them:
<Button x:Uid="AppBarButton" Style="{StaticResource AddAppBarButtonStyle}" />
Now just name the resource strings appropriately so that the XAML parser will find them. The pattern is UidName.PropertyName, e.g. Button.Content. In the case of AppBar buttons the syntax is a little more complex because of attached properties:
AppBarButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
You could try AutomationProperties.SetName(ButtonId, value);

Grails: How to include an html link inside a <g:message> default attribute?

I am starting with Grails and want to have one page with multilanguage content.
I started using the tag which works fine.
But here is what I want to do:
I want to include the default text of the default language right in the text, to avoid switching back and forth in between files.
<g:message code="homepage.feature.headline1" default="This is an english text" />
The above works.
But now I a have a message which should include a link like this:
<g:message code="homepage.feature.headline1" default="This is an english text with <a href='somefile.html'>a link</a>" />
This gives me an exception:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Grails tags were not closed! [[<g:message>]] in GSP
How can I achieve that I can include a link there? I have tried escaping the <> brackets but still no luck.
I really would like to avoid splitting up this one sentence into multiple smaller sentences.
Thanks
Christoph
Closures can be used for nested i18n messages. I find it useful for when the link generation needs additional logic.
<g:message code="homepage.feature.headline1" default="This is an english text with a {0}" encodeAs="raw" args="[link(controller: 'someController', action: 'someAction') { message(code:'homepage.feature.headline1.link')}]"/>
You have two possible ways:
<g:message code="homepage.feature.headline1" default="This is an english text with ${'<a href=\'somefile.html\'>a link</a>'}" />
or
<% def link = "<a href='somefile.html'>a link</a>"%>
<g:message code="homepage.feature.headline1" default="This is an english text with $link" />
I usually create 2 messages: the original one and the key other to be replaced. This makes it optional to create the link or not. Considering both keys are provided (leaving the verification out of this snippet):
packagesUpdate.error.server.unreachable=The packages repository server "{0}" is unreachable. This usually happens behind a network proxy server.
packagesUpdate.error.server.proxyReplace=network proxy server
Replacing the string in the controller, e.g., on ref msgWithLink:
def msg = message(code: 'packagesUpdate.error.server.unreachable')
def proxyReplace = message(code:'packagesUpdate.error.server.proxyReplace')
def msgWithLink = msg.replace(proxyReplace,
"<a href='/csvn/packagesUpdate/available'>${proxyReplace}</a>")
Replacing in the g:message tag:
< g:set var="msg" value="${message(code:'packagesUpdate.error.server.unreachable')}" />
< g:set var="proxyReplace" value="${message(code:'packagesUpdate.error.server.proxyReplace')}" />
< g:set var="link" value="${proxyReplace}" />
< g:set var="msgWithLink" value="${msg.replace(proxyReplace, link)}" />

Resources