Search in sources :

Example 1 with TranslationData

use of org.terasology.engine.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));
    assertEquals(Locale.GERMANY, data.getLocale());
    assertTrue(data.getTranslations().isEmpty());
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 2 with TranslationData

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

the class TranslationFormatTests method testMultiLine.

@Test
public void testMultiLine() throws IOException, InvalidAssetFilenameException {
    byte[] resource = createSimpleMultiLineTranslationFile().getBytes(StandardCharsets.UTF_8);
    AssetDataFile assetDataFile = mockAssetDataFile("game.lang", resource);
    ResourceUrn urn = createUrnFromFile(format, assetDataFile);
    TranslationData data = format.load(urn, Collections.singletonList(assetDataFile));
    assertEquals("line 1 \n line 2 \n line 3", data.getTranslations().get("multi-line"));
    assertEquals("line 1 \n line 2 \n line 3", data.getTranslations().get("single-line"));
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 3 with TranslationData

use of org.terasology.engine.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));
    assertEquals("Einzelspieler", data.getTranslations().get("engine:mainMenuScreen#singleplayer#text"));
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Example 4 with TranslationData

use of org.terasology.engine.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));
    assertEquals(new ResourceUrn("engine:menu"), data.getProjectUrn());
    assertEquals(Locale.ROOT, data.getLocale());
}
Also used : AssetDataFile(org.terasology.gestalt.assets.format.AssetDataFile) TranslationData(org.terasology.engine.i18n.assets.TranslationData) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 TranslationData (org.terasology.engine.i18n.assets.TranslationData)4 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)4 AssetDataFile (org.terasology.gestalt.assets.format.AssetDataFile)4