当前位置: 首页>>代码示例>>Java>>正文


Java I18NUtil.getContentLocale方法代码示例

本文整理汇总了Java中org.springframework.extensions.surf.util.I18NUtil.getContentLocale方法的典型用法代码示例。如果您正苦于以下问题:Java I18NUtil.getContentLocale方法的具体用法?Java I18NUtil.getContentLocale怎么用?Java I18NUtil.getContentLocale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.extensions.surf.util.I18NUtil的用法示例。


在下文中一共展示了I18NUtil.getContentLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClosestValue

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
private Serializable getClosestValue(MLText mlText)
{
    Set<Locale> locales = mlText.getLocales();
    Locale contentLocale = I18NUtil.getContentLocale();
    Locale locale = I18NUtil.getNearestLocale(contentLocale, locales);
    if (locale != null)
    {
        return mlText.getValue(locale);
    }

    // If the content locale is too specific, try relaxing it to just language
    Locale contentLocaleLang = I18NUtil.getContentLocaleLang();
    // We do not expect contentLocaleLang to be null
    if (contentLocaleLang != null)
    {
        locale = I18NUtil.getNearestLocale(contentLocaleLang, locales);
        if (locale != null)
        {
            return mlText.getValue(locale);
        }
    }
    else
    {
        logger.warn("contentLocaleLang is null in getClosestValue. This is not expected.");
    }
    
    // Just return the default translation
    return mlText.getDefaultValue();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:MLPropertyInterceptor.java

示例2: getClosestLocale

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public Locale getClosestLocale(Collection<?> collection)
{
    if (collection.size() == 0)
    {
        return null;
    }
    // Use the available keys as options
    HashSet<Locale> locales = new HashSet<Locale>();
    for(Object o : collection)
    {
        MLText mlText = (MLText)o;
        locales.addAll(mlText.keySet());
    }
    // Try the content locale
    Locale locale = I18NUtil.getContentLocale();
    Locale match = I18NUtil.getNearestLocale(locale, locales);
    if (match == null)
    {
        // Try just the content locale language
        locale = I18NUtil.getContentLocaleLang();
        match = I18NUtil.getNearestLocale(locale, locales);
        if (match == null)
        {
            // No close matches for the locale - go for the default locale
            locale = I18NUtil.getLocale();
            match = I18NUtil.getNearestLocale(locale, locales);
            if (match == null)
            {
                // just get any locale
                match = I18NUtil.getNearestLocale(null, locales);
            }
        }
    }
    return match;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:MLPropertyInterceptor.java

示例3: onSetUp

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
@Override
protected void onSetUp() throws Exception
{
    super.onSetUp();
    contentLocaleToRestore = I18NUtil.getContentLocale();
    localeToRestore = I18NUtil.getLocale();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:ExporterComponentTest.java

示例4: getContentLocale

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public Locale getContentLocale()
{
    return I18NUtil.getContentLocale();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:5,代码来源:MessageServiceImpl.java

示例5: testMLText

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public void testMLText() throws Exception
{
 NodeRef rootNode = nodeService.getRootNode(storeRef);
 NodeRef folderNodeRef = nodeService.createNode(
         rootNode,
         ContentModel.ASSOC_CHILDREN,
         ContentModel.ASSOC_CHILDREN,
         ContentModel.TYPE_FOLDER).getChildRef();
 
 FileInfo exportFolder = fileFolderService.create(folderNodeRef, "export", ContentModel.TYPE_FOLDER);
 FileInfo content = fileFolderService.create(exportFolder.getNodeRef(), "file", ContentModel.TYPE_CONTENT);
 MLText title = new MLText();
 title.addValue(Locale.ENGLISH, null);
 title.addValue(Locale.FRENCH, "bonjour");
 nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_TITLE, title);
 nodeService.setProperty(content.getNodeRef(), ContentModel.PROP_NAME, "file");
 
 FileInfo importFolder = fileFolderService.create(folderNodeRef, "import", ContentModel.TYPE_FOLDER);
	
 // export
 File acpFile = exportContent(exportFolder.getNodeRef());
	
 // import
 FileInfo importFolderFileInfo = importContent(acpFile, importFolder.getNodeRef());
 assertNotNull(importFolderFileInfo);
 NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "file");
 assertNotNull("Couldn't find imported file: file", importedFileNode);
 
	Locale currentLocale = I18NUtil.getContentLocale();
	try
	{
    	I18NUtil.setContentLocale(Locale.ENGLISH);

  String importedTitle = (String)nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE);
  assertNull(importedTitle);
     
    	I18NUtil.setContentLocale(Locale.FRENCH);

  importedTitle = (String)nodeService.getProperty(importedFileNode, ContentModel.PROP_TITLE);
  assertNotNull(importedTitle);
     assertEquals("bonjour", importedTitle);
	}
	finally
	{
    	I18NUtil.setContentLocale(currentLocale);
	}
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:48,代码来源:ExporterComponentTest.java


注:本文中的org.springframework.extensions.surf.util.I18NUtil.getContentLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。