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


Java I18n类代码示例

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


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

示例1: testTreeTranslatableObject

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testTreeTranslatableObject() {
    final TreeTranslatableObject treeTranslatableObject = new TreeTranslatableObject(
            new SimpleTranslatableObject("input", "input"), new SimpleTranslatableObject("input", "input"));
    assertEquals("input", treeTranslatableObject.getItemNotToBeTranslated().getItemToBeTranslated());
    assertEquals("input", treeTranslatableObject.getItemNotToBeTranslated().getItemNotToBeTranslated());
    assertEquals("input", treeTranslatableObject.getItemToBeTranslated().getItemToBeTranslated());
    assertEquals("input", treeTranslatableObject.getItemToBeTranslated().getItemNotToBeTranslated());

    final TreeTranslatableObject translatedObject = tr(treeTranslatableObject);
    assertEquals("input", translatedObject.getItemNotToBeTranslated().getItemToBeTranslated());
    assertEquals("input", translatedObject.getItemNotToBeTranslated().getItemNotToBeTranslated());
    assertEquals("output", translatedObject.getItemToBeTranslated().getItemToBeTranslated());
    assertEquals("input", translatedObject.getItemToBeTranslated().getItemNotToBeTranslated());

}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:18,代码来源:LocalisationTest.java

示例2: getI18n

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
private static I18n getI18n() {
    // init only once
    if (i18n == null) {
        i18n = I18nFactory.getI18n(Localisation.class, "Messages");
    }
    return i18n;
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:8,代码来源:Localisation.java

示例3: setUp

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@Before
public void setUp() {
    mockI18n = mock(I18n.class);
    PowerMockito.doReturn("output").when(mockI18n).tr("input");
    PowerMockito.mockStatic(I18nFactory.class);
    PowerMockito.when(I18nFactory.getI18n(any(), anyString())).thenReturn(mockI18n);
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:8,代码来源:LocalisationTest.java

示例4: testSimpleTranslatableObject

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testSimpleTranslatableObject() {
    final SimpleTranslatableObject translatableObject = new SimpleTranslatableObject("input", "input");
    assertEquals("input", translatableObject.getItemNotToBeTranslated());
    assertEquals("input", translatableObject.getItemToBeTranslated());

    final SimpleTranslatableObject translatedObject = tr(translatableObject);
    assertEquals("input", translatedObject.getItemNotToBeTranslated());
    assertEquals("output", translatedObject.getItemToBeTranslated());
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:12,代码来源:LocalisationTest.java

示例5: testSimpleTranslatableObjectWithBuilder

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testSimpleTranslatableObjectWithBuilder() {
    final SimpleTranslatableObjectBuilder translatableObject = new SimpleTranslatableObjectBuilder.Builder()
            .withItemNotToBeTranslated("input").withItemToBeTranslated("input").build();
    assertEquals("input", translatableObject.getItemNotToBeTranslated());
    assertEquals("input", translatableObject.getItemToBeTranslated());

    final SimpleTranslatableObjectBuilder translatedObject = tr(translatableObject);
    assertEquals("input", translatedObject.getItemNotToBeTranslated());
    assertEquals("output", translatedObject.getItemToBeTranslated());
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:13,代码来源:LocalisationTest.java

示例6: testTreeTranslatableCollectionObject

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testTreeTranslatableCollectionObject() {
    final CollectionsOfTranslatableObject collectionsOfTranslatableObject = new CollectionsOfTranslatableObject(
            Arrays.asList("input", "input"), Arrays.asList("input", "input"));

    final CollectionsOfTranslatableObject translatedObject = tr(collectionsOfTranslatableObject);
    assertEquals(Arrays.asList("input", "input"), translatedObject.getItemNotToBeTranslated());
    assertEquals(Arrays.asList("output", "output"), translatedObject.getItemToBeTranslated());
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:11,代码来源:LocalisationTest.java

示例7: getI18n

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
/**
 * Returns the I18n instance for the package the given
 * class is in
 * 
 * @param className fully qualified class name (ClassName.class)
 * @return I18n instance to use the tr functions
 */
@SuppressWarnings("rawtypes")
public I18n getI18n(Class className) {
	Locale loc = new Locale(this.getLanguageCode());
	I18n i18n = I18nFactory.getI18n(className, loc);
	
	return i18n;
}
 
开发者ID:matthiasplappert,项目名称:Cryptographics,代码行数:15,代码来源:Configuration.java

示例8: main

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
public static void main(String[] args)
{
	I18n i18n = I18nFactory.getI18n(I18nExample.class, "Messages");
	/*
	 * We do two runs, the first with the orginal locale the second one
	 * with the German locale, to see which messages are translated and
	 * how.
	 */
	for (int i = 0; i < 2; i++) {
		
		if (i == 0) {
			print("First run");
			
		}
		else {
			print("Second run");
			i18n.setLocale(Locale.GERMAN);
		}
		
		/*
		 * This is the method you will be using most of the time.
		 */
		print(i18n.tr("This text is marked for translation and is translated"));
	
		/*
		 * This method marks the text for translation, but doesn't
		 * translate. This can be used for keys which should be stored
		 * untranslated but should be translated in the user interface.
		 */
		String mark = i18n.marktr("This text is marked for translation but not translated");
	
		/*
		 * See in the second run, it's never translated.
		 */
		print(mark);
	
		/*
		 * Now you can use the text in a variable and it is correctly
		 * translated.
		 */
		print(i18n.tr(mark));
	
		/*
		 * A convenience wrapper for MessageFormat.format(String, Object[]).
		 */
		print(i18n.tr("Four: {0}", new Integer(4)));
	
		/*
		 * This method disambiguates a word which has to be translated
		 * differently depending on how it is used. In our example the
		 * word "chat" is translated differently to German when it is
		 * used as a noun and as a verb.
		 */
		print(i18n.trc("chat (verb)", "chat"));
		
		print(i18n.trc("chat (noun)", "chat"));
	
		/*
		 * I18n.trn handles plurals. The third parameter contains the number
		 * of objects to decide which plural form to use.
		 */
		print(i18n.trn("{0} file is open", "{0} files are open", 1, new Integer(1)));
		
		print(i18n.trn("{0} file is open", "{0} files are open", 2, new Integer(2)));
	}
}
 
开发者ID:dallaslu,项目名称:gettext-commons,代码行数:67,代码来源:I18nExample.java

示例9: testTrWithAString

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testTrWithAString() {
    assertEquals("output", tr("input"));
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:6,代码来源:LocalisationTest.java

示例10: testTrWithNull

import org.xnap.commons.i18n.I18n; //导入依赖的package包/类
@PrepareForTest({ I18nFactory.class, I18n.class })
@Test
public synchronized void testTrWithNull() {
    assertEquals(null, tr(null));
}
 
开发者ID:PhoenicisOrg,项目名称:POL-POM-5,代码行数:6,代码来源:LocalisationTest.java


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