Search in sources :

Example 1 with TranslationData

use of org.terasology.i18n.assets.TranslationData in project Terasology by MovingBlocks.

the class TranslationFormatTests method testEmptyDataGenGermany.

@Test
public void testEmptyDataGenGermany() throws IOException, InvalidAssetFilenameException {
    AssetDataFile assetDataFile = mockAssetDataFile("menu_de-DE.lang", "{}".getBytes(StandardCharsets.UTF_8));
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    Assert.assertEquals(Locale.GERMANY, data.getLocale());
    Assert.assertTrue(data.getTranslations().isEmpty());
}
Also used : AssetDataFile(org.terasology.assets.format.AssetDataFile) TranslationData(org.terasology.i18n.assets.TranslationData) ResourceUrn(org.terasology.assets.ResourceUrn) Test(org.junit.Test)

Example 2 with TranslationData

use of org.terasology.i18n.assets.TranslationData in project Terasology by MovingBlocks.

the class TranslationFormatTests method testEmptyDataGenRoot.

@Test
public void testEmptyDataGenRoot() throws IOException, InvalidAssetFilenameException {
    AssetDataFile assetDataFile = mockAssetDataFile("menu.lang", "{}".getBytes(StandardCharsets.UTF_8));
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    Assert.assertEquals(new SimpleUri("engine:menu"), data.getProjectUri());
    Assert.assertEquals(Locale.ROOT, data.getLocale());
}
Also used : AssetDataFile(org.terasology.assets.format.AssetDataFile) SimpleUri(org.terasology.engine.SimpleUri) TranslationData(org.terasology.i18n.assets.TranslationData) ResourceUrn(org.terasology.assets.ResourceUrn) Test(org.junit.Test)

Example 3 with TranslationData

use of org.terasology.i18n.assets.TranslationData in project Terasology by MovingBlocks.

the class TranslationFormatTests method testDataGenGerman.

@Test
public void testDataGenGerman() throws IOException, InvalidAssetFilenameException {
    byte[] resource = createSimpleTranslationFile().getBytes(StandardCharsets.UTF_8);
    AssetDataFile assetDataFile = mockAssetDataFile("menu_de-DE.lang", resource);
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    Assert.assertEquals("Einzelspieler", data.getTranslations().get("engine:mainMenuScreen#singleplayer#text"));
}
Also used : AssetDataFile(org.terasology.assets.format.AssetDataFile) TranslationData(org.terasology.i18n.assets.TranslationData) ResourceUrn(org.terasology.assets.ResourceUrn) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ResourceUrn (org.terasology.assets.ResourceUrn)3 AssetDataFile (org.terasology.assets.format.AssetDataFile)3 TranslationData (org.terasology.i18n.assets.TranslationData)3 SimpleUri (org.terasology.engine.SimpleUri)1