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


Java I18n类代码示例

本文整理汇总了Java中com.day.cq.i18n.I18n的典型用法代码示例。如果您正苦于以下问题:Java I18n类的具体用法?Java I18n怎么用?Java I18n使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initModel

import com.day.cq.i18n.I18n; //导入依赖的package包/类
@PostConstruct
private void initModel() throws Exception {
    CommerceService commerceService = currentPage.getContentResource().adaptTo(CommerceService.class);
    try {
        commerceSession = commerceService.login(request, response);
    } catch (CommerceException e) {
        LOGGER.error("Failed to create commerce session", e);
    }
    
    Locale pageLocale = currentPage.getLanguage(true);
    ResourceBundle bundle = request.getResourceBundle(pageLocale);
    i18n = new I18n(bundle);

    isEmpty = commerceSession.getCartEntries().isEmpty();
    
    shippingTotal = formatShippingPrice(commerceSession.getCartPriceInfo(new PriceFilter(WeRetailConstants.PRICE_FILTER_SHIPPING)));
    subTotal = commerceSession.getCartPrice(new PriceFilter(WeRetailConstants.PRICE_FILTER_PRE_TAX));
    taxTotal = commerceSession.getCartPrice(new PriceFilter(WeRetailConstants.PRICE_FILTER_TAX));
    total = commerceSession.getCartPrice(new PriceFilter(WeRetailConstants.PRICE_FILTER_TOTAL));
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:21,代码来源:ShoppingCartPricesModel.java

示例2: doEndTag

import com.day.cq.i18n.I18n; //导入依赖的package包/类
public int doEndTag() throws JspException {
    try {
        init();
        
        ValueMap valueMap = request.getResource().adaptTo(ValueMap.class);
        I18nResourceBundle bundle = new I18nResourceBundle(valueMap,
                getResourceBundle(getBaseName(), request));
        
        // make this resource bundle & i18n available as ValueMap for TEI
        pageContext.setAttribute(getMessagesName(),
                bundle.adaptTo(ValueMap.class), 
                PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getI18nName(), 
                new I18n(bundle), 
                PageContext.PAGE_SCOPE);

        // make this resource bundle available for fmt functions
        Config.set(pageContext, "javax.servlet.jsp.jstl.fmt.localizationContext", new LocalizationContext(bundle, getLocale(request)), 1);
    } catch(Exception e) {
        LOG.error(e.getMessage());
        throw new JspException(e);
    }
    return EVAL_PAGE;
}
 
开发者ID:steeleforge,项目名称:ironsites,代码行数:25,代码来源:I18nHelperTag.java

示例3: initModel

import com.day.cq.i18n.I18n; //导入依赖的package包/类
@PostConstruct
private void initModel() {
    if (request != null) {
        i18n = new I18n(request);
    }
    type = Type.fromString(typeString);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:8,代码来源:ButtonImpl.java

示例4: doGet

import com.day.cq.i18n.I18n; //导入依赖的package包/类
@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    SlingBindings bindings = (SlingBindings) request.getAttribute(SlingBindings.class.getName());
    Page currentPage = (Page) bindings.get(WCMBindings.CURRENT_PAGE);
    final Locale pageLocale = currentPage.getLanguage(true);
    final ResourceBundle bundle = request.getResourceBundle(pageLocale);
    i18n = new I18n(bundle);
    SimpleDataSource countriesDataSource = new SimpleDataSource(buildCountriesList(request.getResourceResolver()).iterator());
    request.setAttribute(DataSource.class.getName(), countriesDataSource);
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:12,代码来源:CountriesFormOptionsDataSource.java

示例5: getOrderStatus

import com.day.cq.i18n.I18n; //导入依赖的package包/类
@Override
protected String getOrderStatus(String orderId) throws CommerceException {
    //
    // Status is kept in the vendor section (/etc/commerce); need to find corresponding order there.
    //
    Session serviceSession = null;
    try {
        serviceSession = commerceService.serviceContext().slingRepository.loginService("orders", null);
        //
        // example query: /jcr:root/etc/commerce/orders//element(*)[@orderId='foo')]
        //
        StringBuilder buffer = new StringBuilder();
        buffer.append("/jcr:root/etc/commerce/orders//element(*)[@orderId = '")
                .append(Text.escapeIllegalXpathSearchChars(orderId).replaceAll("'", "''"))
                .append("']");

        final Query query = serviceSession.getWorkspace().getQueryManager().createQuery(buffer.toString(), Query.XPATH);
        NodeIterator nodeIterator = query.execute().getNodes();
        if (nodeIterator.hasNext()) {
            return nodeIterator.nextNode().getProperty("orderStatus").getString();
        }
    } catch (Exception e) {
        // fail-safe when the query above contains errors
        log.error("Error while fetching order status for orderId '" + orderId + "'", e);
    } finally {
        if (serviceSession != null) {
            serviceSession.logout();
        }
    }
    final I18n i18n = new I18n(request);
    return i18n.get("unknown", "order status");
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:33,代码来源:WeRetailCommerceSessionImpl.java

示例6: Translate

import com.day.cq.i18n.I18n; //导入依赖的package包/类
public static String Translate(Page currentPage, SlingHttpServletRequest slingRequest, String value){
		if (!"".equals(value)){
			Locale pageLocale = currentPage.getLanguage(false);
			//Locale myLocale = new Locale("fr");  
			ResourceBundle resourceBundle = slingRequest.getResourceBundle(pageLocale);   
			I18n i18n = new I18n(resourceBundle);
//			I18n i18n = new I18n(slingRequest);
			return i18n.get(value);
			//return i18n.get(value);
		}
		return "";
	}
 
开发者ID:infielddigital,项目名称:aem-id-googlesearch,代码行数:13,代码来源:Functions.java


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