the <p:calendar> default language is English, I want to change it to French
I added local="fr" but nothing has changed
I add lang="fr" nothing has changed
You need to add script to you page in which localization for calendar is defined. You can see it on Primefaces calendar i18n
Sometimes even though if you change local in code and if it doesn't work then you need to change Browser settings and change local as French or English.
IE --> Tools --> Internet Options --> Under General tab --> languages and add language.
Related
I built web site using JSF, support multi-language(German and English).
I just set the internationalization values for each language in properties to be use in xhtml. Now I added Arabic language and create lang_ar.properties for Arabic values. It works fine, but the direction is still displayed in the wrong place. Since Arabic is RTL, so when change to Arabic the its should change the direction of the whole content of the page to RTL.
I searched a lot for the solution but I didn't find what I am looking for.
If I use html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ar" dir="rtl">
It will change the direction of the page even if I use German or English. I don't want to use separate page for Arabic content I want use the same pages which take the value from properties files just like English and German, but I need to change the direction when use arabic properties.
If I use the following:
<h:inputText ... dir="#{view.locale.language eq 'ar' ? 'rtl' : 'ltr'}" />
This will works just for the plain text entered in the input field not to the input field itself. So the input field will stay ltr but the text inside will be rtl.
Can any one help me?
I would like to change language of web content in liferay. So I tried to change language programatically from en_EN to sk_SK (Slovak) this way:
$themeDisplay.getLanguageId() // there it is en_EN
$themeDisplay.setLanguageId('sk_SK')
$themeDisplay.getLanguageId() // there it is sk_SK
same it is with this code
#set ($locale=$localeUtil.fromLanguageId("sk_SK"))
$themeDisplay.setLocale($locale)
$themeDisplay.getLocale()
But the web content didn't change. Do you know why?
If this is not clear I will try to give you an example: On the top of web-page are usually some language buttons, so you can switch between more languages. I want to do same in liferay. So I have one WebContent with more translations and with this buttons I want to change language/translation of webContent.
On the top of web-page are usually some language buttons, so you can
switch between more languages. I want to do same in liferay. So I have
one WebContent with more translations and with this buttons I want to
change language/translation of webContent.
If i'm not wrong Liferay already provide such functionality out-of-the-box. You don't need to do it with pragmatically.
Use Liferay's navigation portlet to switch the languages.
Thank you, but I would like to add it into my code, into *.vm file. So this is my solution (finally I found it)
<div id="language-portlet">
#set ($VOID = $velocityPortletPreferences.setValue('portlet-setup-show-borders', 'true'))
#set ($VOID = $theme.runtime("82", '', $velocityPortletPreferences.toString()))
#set ($VOID = $velocityPortletPreferences.reset())
</div>
It show possible translations on your web-page. (For me it is flags)
The best solution is to override this property
locale.default.request=false
company.default.locale=sk_SK
is portal-ext.proprties file
In Liferay 6.1, we created a hook to hide the sign out link in the dockbar. However, when I look at the code for 6.2, I see the following:
<c:if test="<%= themeDisplay.isShowSignOutIcon() %>">
<aui:nav-item cssClass="sign-out" href="<%= themeDisplay.getURLSignOut() %>" iconCssClass="icon-off" label="sign-out" />
</c:if>
No matter how much I google, I can't find any reference to themeDisplay.isShowSignOutIcon(), aside from the API reference, which does me no good, as it is not commented at all. I did find the page that discusses the native LR theme properties and apparently determining whether to show/hide a sign out linkn is not one of the native theme properties.
Does anyone know if you can set the theme itself to show/hide the sign out link and how you would go about doing it?
I too analyzed ServicePreAction code, and found that all this code does is:
checks if the user is logged in or not
if yes, shows 'sign out' link, not otherwise
You can simply create a hook to override html/portlet/dockbar/view_user_account.jspf to either remove that code snippet from this jsp to hide it for all scenarios OR modify the condition to show/hide as per your requirements.
The only place that I've found where ThemeDisplay.setShowSignOutIcon is called is in ServicePreAction (linking master branch here). That being said, it looks like it's not configurable, but you can easily create another ServicePreAction in a hook. Please see an example in this plugin (referencing portal.properties and liferay-hook.xml, but naturally there's also code that I'm sure you'll find. It's not big)
Another option - if you just want to unconditionally get rid of the link: Use CSS to hide it. Yes, it will still be there, but any way you choose to hide the link, the actopm at /c/portal/logout will still be available...
I have a localized website for different languages
Users can select which language to use in a profile and this will be applied beforePageLoad
using
context.setLocalString("en")
"en" is default to en-US i believe so the dates on the website is displayed in the US format so I learned that I can use instead.
context.setLocale(new Locale("en","gb"))
the problem with setLocal is that is does not update the HTML lang="en" attribute so event though the dates are correct after using setLocal the language file that is used is still the englisn(US) and not the english(uk) one. (i.e not html lang="en-gb")
so when users from england set their language to en-uk in thier profile they get the US language file.
So I tried to do both like this
context.setLocale(new Locale("en","gb"))
context.setLocalString("en-GB")
but then the setLocalString overrides the setLocalString and vice versa. so it looks like I can't use them both
Is there any way I can add code on beforePageLoad to make sure both the html lang attribute gets updated with correct language and my dates dispay in the correct format for the language set?
Instead of using the context object try to set the locale directly in the view root during beforeRenderResponse:
<xp:this.beforeRenderResponse>
<![CDATA[#{javascript:
facesContext.getViewRoot().setLocale( new java.util.Locale("en-GB") );
}]]>
</xp:this.beforeRenderResponse>
Or you can switch the locale in a phase listener as described here:
http://openntf.org/XSnippets.nsf/snippet.xsp?id=xpages-localization-setter
EDIT:
The locale setting is a little bit strange. You have to use an underscore between en and GB when using context.setLocaleString() (as Panu Haaramo answered), but this won't solve problem, because the ViewRootRender uses only the language setting for the generation of the lang attribute while rendering the HTML output.
This
new java.util.Locale("en", "GB").getLanguage()
will return en only, the "GB" is ignored.
Using the context.setLocaleString will bring the same result because this only parses the given string and converts it into a java.util.Locale which returns the same result as descibed.
But using an undefined Locale will generate a lowercased lang attribute. F.e. this
<xp:this.beforeRenderResponse>
<![CDATA[#{javascript:
facesContext.getViewRoot().setLocale( new java.util.Locale("en-Blabla-Blubb") );
}]]>
</xp:this.beforeRenderResponse>
generates the following HTML tag:
<html lang="en-blabla-blubb">
Thats why the code at top of this answer sets the lang attribute to en-gb, but this is still incorrect: It should set it to en-GB as described here: w3.org: Best Practices: Specifying Language in XHTML & HTML Content
GWT gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie en_US) locale.
Why doesn't it get it from the browser settings?
It seems the only solution to this is to replace your static html launch page with something like a JSP that reads the browser locales and sets the locale or redirects using the query string. There has to be a better solution than this or simply hard-coding a locale, surely?
You can also put this switch in your *.gwt.xml
<set-configuration-property name="locale.useragent" value="Y"/>
this will add language selecting based on language selected in browser. You can also control search order for locale by setting
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>
But beware that in IE this doesn't work - you should develop server-side language pick based on 'Accept-Language' header send by the IE.
If you put a list of available languages into your *.gwt.xml file it will by default switch to the first language listed.
<!-- Slovenian in Slovenia -->
<extend-property name="locale" values="sl"/>
<!-- English language, independent of country -->
<extend-property name="locale" values="en"/>
You can use a cookie to save and send this value, but for that you have to add in your *.gwt.xml first
<set-configuration-property name="locale.cookie" value="yourCookieName"/>
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent"/>
Note that "queryparam" has the biggest priority here, that allows to set a new locale using the http query and ignore the value on the cookie.
This worked for me, I hope it also works for you.
My problem was that I have not declared any locale value in .gwt.xml module descriptor. In that case only the default locale is used. GWT does that way because any different supported locale means a new compilation iteration/permutation. Therefore only declared locales are used.
Here you are an example:
<!-- Locales -->
<extend-property name="locale" values="en_US"/>
<extend-property name="locale" values="es"/>
<set-property-fallback name="locale" value="en_US"/>
<set-configuration-property name="locale.useragent" value="Y" />
<set-configuration-property name="locale.searchorder" value="queryparam,cookie,meta,useragent" />
The first and second lines set the available/supported locales (English from US and Spanish without specific country in my example). The third line sets the default locale in case no one is detected (this default declaration must be set after the default value is declared in a extend-property line). The fourth line enables the locale detection by means of the HTTP-Headers Accept-Language sent by browser (probably is enabled by default and not needed to set at all). The final line sets the order in which the different detection mechanisms try to detect the locale:
As a parameter in the URL query
From cookies
As a meta value in the HTML page
From the HTTP header sent by browser
If your entry page is a JSP you can inspect the request's Accept-Language header to dynamically set the locale.
add this entry in your *.gwt.xml file to see the effect!
Please check the following line for more information!
<set-configuration-property name="locale.useragent" value="Y"/>