本文整理汇总了Java中org.springframework.extensions.surf.util.I18NUtil.parseLocale方法的典型用法代码示例。如果您正苦于以下问题:Java I18NUtil.parseLocale方法的具体用法?Java I18NUtil.parseLocale怎么用?Java I18NUtil.parseLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.extensions.surf.util.I18NUtil
的用法示例。
在下文中一共展示了I18NUtil.parseLocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processLocaleValue
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
private Serializable processLocaleValue(Object value)
{
if (value instanceof String)
{
return I18NUtil.parseLocale((String) value);
}
else
{
throw new FormException("Locale property values must be represented as a String! Value is of type: "
+ value.getClass());
}
}
示例2: setLocale
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
* Sets the Locale
*
* @param locale (language_country_variant)
*/
public void setLocale(String locale)
{
// construct locale
this.locale = I18NUtil.parseLocale(locale);
// store original
strLocale = locale;
}
示例3: getUserLocaleOrDefault
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
* Gets the user's locale.
*
* @param userId the user id
* @return the default locale or the user's preferred locale, if available
*/
public Locale getUserLocaleOrDefault(String userId)
{
if (userId != null && personService.personExists(userId))
{
String localeString = AuthenticationUtil.runAsSystem(() -> (String) preferenceService.getPreference(userId, "locale"));
if (localeString != null)
{
return I18NUtil.parseLocale(localeString);
}
}
return I18NUtil.getLocale();
}
示例4: setLocale
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
* Sets current Locale from string
*/
public void setLocale(String localeStr)
{
Locale newLocale = I18NUtil.parseLocale(localeStr);
I18NUtil.setLocale(newLocale);
}
示例5: parseLocale
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public Locale parseLocale(String localeStr)
{
return I18NUtil.parseLocale(localeStr);
}
示例6: testGetMissingTranslation
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public void testGetMissingTranslation() throws Exception
{
List<String> langList = contentFilterLanguagesService.getFilterLanguages();
int langListSize = langList.size();
// make sure that it exists at least tree language filter
assertFalse("The testGetMissingTranslation test case needs at least three language", langListSize < 3);
// get the first tree locale of the content filter language list
Locale loc1 = I18NUtil.parseLocale(langList.get(0));
Locale loc2 = I18NUtil.parseLocale(langList.get(1));
Locale loc3 = I18NUtil.parseLocale(langList.get(2));
// create three content
NodeRef nodeRef1 = createContent();
NodeRef nodeRef2 = createContent();
NodeRef nodeRef3 = createContent();
multilingualContentService.makeTranslation(nodeRef1, loc1);
List<Locale> missing = multilingualContentService.getMissingTranslations(nodeRef1, false);
// make sure that the missing language list size is correct
assertFalse("Missing Translation Size false. " +
"Real size : " + missing.size() + ". Normal Size " + (langListSize - 1), missing.size() != (langListSize - 1));
// make sure that the missing language list is correct
assertFalse("Missing Translation List false. Locale " + loc1 + " found", missing.contains(loc1.toString()));
multilingualContentService.addTranslation(nodeRef2, nodeRef1, loc2);
multilingualContentService.addTranslation(nodeRef3, nodeRef1, loc3);
// Add the missing translations in
missing = multilingualContentService.getMissingTranslations(nodeRef1, false);
// Make sure that the missing language list size is correct
assertFalse("Missing Translation Size false. " +
"Real size : " + missing.size() + ". Normal Size " + (langListSize - 3), missing.size() != (langListSize - 3));
// make sure that the missing language list is correct
assertFalse("Missing Translation List false. Locale " + loc2.toString() + " or " + loc3.toString() + " found", missing.contains(loc2) || missing.contains(loc3));
}
示例7: createContentProperty
import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
* Construct a content property from a string
*
* @param contentPropertyStr the string representing the content details
* @return Returns a bean version of the string
*/
public static ContentData createContentProperty(String contentPropertyStr)
{
String contentUrl = null;
String mimetype = null;
long size = 0L;
String encoding = null;
Locale locale = null;
// now parse the string
StringTokenizer tokenizer = new StringTokenizer(contentPropertyStr, "|");
while (tokenizer.hasMoreTokens())
{
String token = tokenizer.nextToken();
if (token.startsWith("contentUrl="))
{
contentUrl = token.substring(11);
if (contentUrl.length() == 0)
{
contentUrl = null;
}
}
else if (token.startsWith("mimetype="))
{
mimetype = token.substring(9);
if (mimetype.length() == 0)
{
mimetype = null;
}
}
else if (token.startsWith("size="))
{
String sizeStr = token.substring(5);
if (sizeStr.length() > 0)
{
size = Long.parseLong(sizeStr);
}
}
else if (token.startsWith("encoding="))
{
encoding = token.substring(9);
if (encoding.length() == 0)
{
encoding = null;
}
}
else if (token.startsWith("locale="))
{
String localeStr = token.substring(7);
if (localeStr.length() > 0)
{
locale = I18NUtil.parseLocale(localeStr);
}
}
}
ContentData property = new ContentData(contentUrl, mimetype, size, encoding, locale);
// done
return property;
}