Re: [xwiki-users] Getting the translated country name

2016-05-17 Thread Thomas Mortagne
The API you are actually manipulating when you do this is
https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html which
is about languages and language variants.

getDisplayName return the display name for the whole Locale but you
can get the language pretty name using getDisplayLanguage and the
country pretty name with getDisplayCountry. So the trick would be to
create a Locale with the country part in it and then call
getDisplayCountry.

Here is a few experiments for you:

$services.localization.toLocale('it').getDisplayName('fr')
$services.localization.toLocale('it_IT').getDisplayName('fr')
$services.localization.toLocale('it_IT').getDisplayLanguage('fr')
$services.localization.toLocale('it_IT').getDisplayCountry('fr')

On Tue, May 17, 2016 at 5:10 PM, Gerritjan Koekkoek
 wrote:
> I found a nice way to translate $language into pretty language name in the 
> translation desired.
>
>
> {{velocity}}
>
> #displayLanguagePrettyName("it")
>
> #macro(displayLanguagePrettyName $language)#set($languageLocale = 
> $services.localization.toLocale("it"))$stringtool.capitalize($languageLocale.getDisplayName("nl"))#end
>
> {{/velocity}}
>
>
> So changing the 'nl' to 'pt' (portugese) it will do
>
> Italiaans (dutch) -> Italiano (portugese)
>
>
> Ca the same be done for country?
>
> Italië (dutch) -> Itália (Portuguse)
>
>
>
>
> Gerritjan Koekkoek
> Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
> Visit our website
> Facebook
> email
>
>
>
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Getting the translated country name

2016-05-17 Thread Gerritjan Koekkoek
I found a nice way to translate $language into pretty language name in the 
translation desired.


{{velocity}}

#displayLanguagePrettyName("it")

#macro(displayLanguagePrettyName $language)#set($languageLocale = 
$services.localization.toLocale("it"))$stringtool.capitalize($languageLocale.getDisplayName("nl"))#end

{{/velocity}}


So changing the 'nl' to 'pt' (portugese) it will do

Italiaans (dutch) -> Italiano (portugese)


Ca the same be done for country?

Italië (dutch) -> Itália (Portuguse)




Gerritjan Koekkoek
Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS
Visit our website
Facebook
email



___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users