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


Java I18NUtil.getContentLocaleOrNull方法代码示例

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


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

示例1: testShallowFilesAndFoldersListWithLocale

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
public void testShallowFilesAndFoldersListWithLocale() throws Exception
{
    Locale savedLocale = I18NUtil.getContentLocaleOrNull();
    try
    {
        I18NUtil.setContentLocale(Locale.CANADA);
        List<FileInfo> files = fileFolderService.list(workingRootNodeRef);
        // check
        String[] expectedNames = new String[]
        { NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
        checkFileList(files, 2, 3, expectedNames);
    }
    finally
    {
        I18NUtil.setContentLocale(savedLocale);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:FileFolderServiceImplTest.java

示例2: getTranslatedNodeRef

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
 * Converts the node referenice where an alternative translation should be used.
 * 
 * @param nodeRef       the basic nodeRef
 * @return              Returns the replacement if required
 */
private NodeRef getTranslatedNodeRef(NodeRef nodeRef)
{
    // Ignore null
    if (nodeRef == null)
    {
        return nodeRef;
    }
    // Ignore everything without the correct aspect
    if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT))
    {
        return nodeRef;
    }
    Locale filterLocale = I18NUtil.getContentLocaleOrNull();
    if (filterLocale == null)
    {
        // We aren't doing any filtering
        return nodeRef;
    }
    // Find the best translation.  This won't return null.
    NodeRef translatedNodeRef = multilingualContentService.getTranslationForLocale(nodeRef, filterLocale);
    // Done
    if (logger.isDebugEnabled())
    {
        if (nodeRef.equals(translatedNodeRef))
        {
            logger.debug("NodeRef substitution: " + nodeRef + " --> " + translatedNodeRef);
        }
        else
        {
            logger.debug("NodeRef substitution: " + nodeRef + " (no change)");
        }
    }
    return translatedNodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:MLTranslationInterceptor.java

示例3: processTemplate

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
 * @see org.alfresco.service.cmr.repository.TemplateService#processTemplate(java.lang.String, java.lang.String, java.lang.Object, java.util.Locale)
 */
private void processTemplate(String engine, String template, Object model, Writer out, Locale locale)
    throws TemplateException
{
    Locale currentLocale = I18NUtil.getLocaleOrNull();
    Locale currentContentLocale = I18NUtil.getContentLocaleOrNull();
    
    try
    {
       // set locale for cases where message method is used inside of template
       I18NUtil.setLocale(locale);
       // execute template processor
       TemplateProcessor processor = getTemplateProcessor(engine);
       processor.process(template, model, out, locale);
    }
    catch (TemplateException terr)
    {
       throw terr;
    }
    catch (Throwable err)
    {
       throw new TemplateException(err.getMessage(), err);
    }
    finally
    {
        I18NUtil.setLocale(currentLocale);
        I18NUtil.setContentLocale(currentContentLocale);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:TemplateServiceImpl.java

示例4: testGetType

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
/**
 * Validates <a href="https://issues.alfresco.com/jira/browse/ALFCOM-2655">ACT-7225</a>
 */
public void testGetType() throws Exception
{
    Locale savedLocale = I18NUtil.getContentLocaleOrNull();
    try
    {
        I18NUtil.setContentLocale(Locale.CANADA);
        FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
        assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
    }
    finally
    {
        I18NUtil.setContentLocale(savedLocale);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:FileFolderServiceImplTest.java

示例5: invoke

import org.springframework.extensions.surf.util.I18NUtil; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable
{
    Object ret = null;
    String methodName = invocation.getMethod().getName();
    
    if (I18NUtil.getContentLocaleOrNull() == null)
    {
        // This can shortcut anything as there is no filtering going on
        return invocation.proceed();
    }
    else if (METHOD_NAMES_LIST.contains(methodName))
    {
    	Object result = invocation.proceed();
    	if(result instanceof List)
    	{
    		return processList((List<FileInfo>)result);
    	}
    	else if(result instanceof PagingResults)
    	{
    		return processPagingResults((PagingResults<FileInfo>)result);
    	}
    	else
    	{
    		throw new ClassCastException("Unexpected return type from method " + methodName + " in " + this);
    	}
    }
    else if (METHOD_NAMES_SINGLE.contains(methodName))
    {
        Object obj = invocation.proceed();
        if (obj instanceof FileInfo)
        {
            FileInfo fileInfo = (FileInfo) obj;
            ret = getTranslatedFileInfo(fileInfo);
        }
        else if (obj instanceof NodeRef)
        {
            NodeRef nodeRef = (NodeRef) obj;
            ret = getTranslatedNodeRef(nodeRef);
        }
    }
    else if (METHOD_NAMES_OTHER.contains(methodName))
    {
        // There is nothing to do
        ret = invocation.proceed();
    }
    else
    {
        throw new RuntimeException("Method not handled by interceptor: " + methodName);
    }
    
    // Done
    return ret;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:55,代码来源:MLTranslationInterceptor.java


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