@Component @Named(value="localization") @Singleton public class LocalizationScriptService extends Object implements org.xwiki.script.service.ScriptService
Constructor and Description |
---|
LocalizationScriptService() |
Modifier and Type | Method and Description |
---|---|
Translation |
get(String key) |
Translation |
get(String key,
Locale locale) |
Set<Locale> |
getAvailableLocales() |
Locale |
getCurrentLocale() |
String |
render(Collection<String> keys) |
String |
render(Collection<String> keys,
Collection<?> parameters) |
String |
render(Collection<String> keys,
Collection<?> parameters,
Locale locale) |
String |
render(Collection<String> keys,
Locale locale) |
String |
render(Collection<String> keys,
org.xwiki.rendering.syntax.Syntax syntax) |
String |
render(Collection<String> keys,
org.xwiki.rendering.syntax.Syntax syntax,
Collection<?> parameters) |
String |
render(Collection<String> keys,
org.xwiki.rendering.syntax.Syntax syntax,
Collection<?> parameters,
Locale locale) |
String |
render(Collection<String> keys,
org.xwiki.rendering.syntax.Syntax syntax,
Locale locale) |
String |
render(String key) |
String |
render(String key,
Collection<?> parameters) |
String |
render(String key,
Collection<?> parameters,
Locale locale) |
String |
render(String key,
Locale locale) |
String |
render(String key,
org.xwiki.rendering.syntax.Syntax syntax) |
String |
render(String key,
org.xwiki.rendering.syntax.Syntax syntax,
Collection<?> parameters) |
String |
render(String key,
org.xwiki.rendering.syntax.Syntax syntax,
Collection<?> parameters,
Locale locale) |
String |
render(String key,
org.xwiki.rendering.syntax.Syntax syntax,
Locale locale) |
Locale |
toLocale(String str)
Converts the given string to a locale.
|
boolean |
use(String bundleType,
String bundleId) |
public Translation get(String key)
key
- the translation keypublic Translation get(String key, Locale locale)
public boolean use(String bundleType, String bundleId)
bundleType
- the hint of the TranslationBundleFactory
to use to get the
actual bundlebundleId
- the identifier of the bundle for the passed typepublic Locale getCurrentLocale()
Locale
to use by default in the current contextpublic Locale toLocale(String str)
str
- the String to convert to LocaleLocale.ROOT
if the given string is null
or empty; if the
given string doesn't represent a locale (e.g. invalid format) then null
is returnedLocaleUtils.toLocale(String)
public String render(String key)
key
- the translation keypublic String render(Collection<String> keys)
keys
- the translations keys to try one by onepublic String render(Collection<String> keys, Locale locale)
public String render(String key, Collection<?> parameters)
key
- the translation keyparameters
- the translation parameterspublic String render(Collection<String> keys, Collection<?> parameters)
keys
- the translations keys to try one by oneparameters
- the translation parameterspublic String render(String key, Collection<?> parameters, Locale locale)
key
- the translation keyparameters
- the translation parameterslocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).public String render(Collection<String> keys, Collection<?> parameters, Locale locale)
keys
- the translations keys to try one by oneparameters
- the translation parameterslocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).public String render(String key, org.xwiki.rendering.syntax.Syntax syntax)
key
- the translation keysyntax
- the syntax in which to render the translation messagepublic String render(Collection<String> keys, org.xwiki.rendering.syntax.Syntax syntax)
keys
- the translations keys to try one by onesyntax
- the syntax in which to render the translation messagepublic String render(String key, org.xwiki.rendering.syntax.Syntax syntax, Locale locale)
key
- the translation keysyntax
- the syntax in which to render the translation messagelocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).public String render(Collection<String> keys, org.xwiki.rendering.syntax.Syntax syntax, Locale locale)
keys
- the translations keys to try one by onesyntax
- the syntax in which to render the translation messagelocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).public String render(String key, org.xwiki.rendering.syntax.Syntax syntax, Collection<?> parameters)
key
- the translation keysyntax
- the syntax in which to render the translation messageparameters
- the translation parameterspublic String render(Collection<String> keys, org.xwiki.rendering.syntax.Syntax syntax, Collection<?> parameters)
keys
- the translations keys to try one by onesyntax
- the syntax in which to render the translation messageparameters
- the translation parameterspublic String render(String key, org.xwiki.rendering.syntax.Syntax syntax, Collection<?> parameters, Locale locale)
key
- the translation keysyntax
- the syntax in which to render the translation messageparameters
- the translation parameterslocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).public String render(Collection<String> keys, org.xwiki.rendering.syntax.Syntax syntax, Collection<?> parameters, Locale locale)
keys
- the translations keys to try one by onesyntax
- the syntax in which to render the translation messageparameters
- the translation parameterslocale
- the Locale
for which this translation is searched. The result might me associated to a
different Locale
(for example getting the fr
translation when asking for the
fr_FR
one).Copyright © 2004–2019 XWiki. All rights reserved.