diff --git a/android/assets/i18n/l10n.properties b/android/assets/i18n/l10n.properties index 4496d53b..67589674 100644 --- a/android/assets/i18n/l10n.properties +++ b/android/assets/i18n/l10n.properties @@ -6,6 +6,14 @@ about_txt = Original code & graphics: {0}\n\ Try it on Windows, Mac OS or Linux - it's awesome! ;)\n\n\ Please visit the official website for additional info: +# AmuletScene +amulet_txt = You finally hold it in your hands, the Amulet of Yendor. Using its power \ + you can take over the world or bring peace and prosperity to people or whatever. \ + Anyway, your life will change forever and this game will end here. \ + Or you can stay a mere mortal a little longer. +amulet_exit = Let's call it a day +amulet_stay = I'm not done yet + # TitleScreen title_play = Play title_rankings = Rankings diff --git a/core/src/com/watabou/pixeldungeon/scenes/AboutScene.java b/core/src/com/watabou/pixeldungeon/scenes/AboutScene.java index 05834569..a5f3e9bb 100644 --- a/core/src/com/watabou/pixeldungeon/scenes/AboutScene.java +++ b/core/src/com/watabou/pixeldungeon/scenes/AboutScene.java @@ -18,7 +18,6 @@ package com.watabou.pixeldungeon.scenes; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.utils.I18NBundle; import com.watabou.input.NoosaInputProcessor; import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Camera; @@ -40,8 +39,7 @@ public class AboutScene extends PixelScene { public void create() { super.create(); - final I18NBundle i18nBundle = Game.instance.getI18nBundle(); - BitmapTextMultiline text = createMultiline(i18nBundle.format(TXT, "Watabou", "Arcnor", "Cubic_Code", "Brian Walker", "Brogue"), 8); + BitmapTextMultiline text = createMultiline(tr(TXT, "Watabou", "Arcnor", "Cubic_Code", "Brian Walker", "Brogue"), 8); text.maxWidth = Math.min( Camera.main.width, 120 ); text.measure(); add( text ); diff --git a/core/src/com/watabou/pixeldungeon/scenes/AmuletScene.java b/core/src/com/watabou/pixeldungeon/scenes/AmuletScene.java index 2de78701..6f8cc416 100644 --- a/core/src/com/watabou/pixeldungeon/scenes/AmuletScene.java +++ b/core/src/com/watabou/pixeldungeon/scenes/AmuletScene.java @@ -30,20 +30,16 @@ public class AmuletScene extends PixelScene { - private static final String TXT_EXIT = "Let's call it a day"; - private static final String TXT_STAY = "I'm not done yet"; + private static final String TXT_EXIT = "amulet_exit"; + private static final String TXT_STAY = "amulet_stay"; private static final int WIDTH = 120; private static final int BTN_HEIGHT = 18; private static final float SMALL_GAP = 2; private static final float LARGE_GAP = 8; - private static final String TXT = - "You finally hold it in your hands, the Amulet of Yendor. Using its power " + - "you can take over the world or bring peace and prosperity to people or whatever. " + - "Anyway, your life will change forever and this game will end here. " + - "Or you can stay a mere mortal a little longer."; - + private static final String TXT = "amulet_txt"; + public static boolean noText = false; private Image amulet; @@ -54,7 +50,7 @@ public void create() { BitmapTextMultiline text = null; if (!noText) { - text = createMultiline( TXT, 8 ); + text = createMultiline(tr(TXT), 8); text.maxWidth = WIDTH; text.measure(); add( text ); @@ -63,7 +59,7 @@ public void create() { amulet = new Image( Assets.AMULET ); add( amulet ); - RedButton btnExit = new RedButton( TXT_EXIT ) { + RedButton btnExit = new RedButton(tr(TXT_EXIT)) { @Override protected void onClick() { Dungeon.deleteGame( Dungeon.hero.heroClass, true ); @@ -73,7 +69,7 @@ protected void onClick() { btnExit.setSize( WIDTH, BTN_HEIGHT ); add( btnExit ); - RedButton btnStay = new RedButton( TXT_STAY ) { + RedButton btnStay = new RedButton(tr(TXT_STAY)) { @Override protected void onClick() { onBackPressed(); diff --git a/core/src/com/watabou/pixeldungeon/scenes/PixelScene.java b/core/src/com/watabou/pixeldungeon/scenes/PixelScene.java index 5910b466..04844305 100644 --- a/core/src/com/watabou/pixeldungeon/scenes/PixelScene.java +++ b/core/src/com/watabou/pixeldungeon/scenes/PixelScene.java @@ -19,9 +19,14 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; -import com.watabou.input.NoosaInputProcessor; -import com.watabou.noosa.*; +import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText.Font; +import com.watabou.noosa.BitmapTextMultiline; +import com.watabou.noosa.Camera; +import com.watabou.noosa.ColorBlock; +import com.watabou.noosa.Game; +import com.watabou.noosa.Scene; +import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Sample; import com.watabou.pixeldungeon.Assets; import com.watabou.pixeldungeon.Badges; @@ -220,7 +225,15 @@ public static BitmapTextMultiline createMultiline( String text, float size ) { return result; } - + + protected String tr(final String key) { + return Game.instance.getI18nBundle().get(key); + } + + protected String tr(final String key, final Object... args) { + return Game.instance.getI18nBundle().format(key, args); + } + public static float align( Camera camera, float pos ) { return ((int)(pos * camera.zoom)) / camera.zoom; } diff --git a/core/src/com/watabou/pixeldungeon/scenes/TitleScene.java b/core/src/com/watabou/pixeldungeon/scenes/TitleScene.java index 92ce5cd0..efcd6b4e 100644 --- a/core/src/com/watabou/pixeldungeon/scenes/TitleScene.java +++ b/core/src/com/watabou/pixeldungeon/scenes/TitleScene.java @@ -17,7 +17,6 @@ */ package com.watabou.pixeldungeon.scenes; -import com.badlogic.gdx.utils.I18NBundle; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; @@ -67,8 +66,7 @@ public void create() { placeTorch( title.x + 18, title.y + 20 ); placeTorch( title.x + title.width - 18, title.y + 20 ); - final I18NBundle i18nBundle = Game.instance.getI18nBundle(); - DashboardItem btnBadges = new DashboardItem(i18nBundle.get(TXT_BADGES), 3) { + DashboardItem btnBadges = new DashboardItem(tr(TXT_BADGES), 3) { @Override protected void onClick() { Game.switchScene( BadgesScene.class ); @@ -77,7 +75,7 @@ protected void onClick() { btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE ); add( btnBadges ); - DashboardItem btnAbout = new DashboardItem(i18nBundle.get(TXT_ABOUT), 1) { + DashboardItem btnAbout = new DashboardItem(tr(TXT_ABOUT), 1) { @Override protected void onClick() { Game.switchScene( AboutScene.class ); @@ -86,7 +84,7 @@ protected void onClick() { btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE ); add( btnAbout ); - DashboardItem btnPlay = new DashboardItem(i18nBundle.get(TXT_PLAY), 0) { + DashboardItem btnPlay = new DashboardItem(tr(TXT_PLAY), 0) { @Override protected void onClick() { Game.switchScene( StartScene.class ); @@ -95,7 +93,7 @@ protected void onClick() { btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE ); add( btnPlay ); - DashboardItem btnHighscores = new DashboardItem(i18nBundle.get(TXT_HIGHSCORES), 2) { + DashboardItem btnHighscores = new DashboardItem(tr(TXT_HIGHSCORES), 2) { @Override protected void onClick() { Game.switchScene( RankingsScene.class );