hi~
Question 1:When I tried to translate things in my code to Chinese by using Localizing, I found that it just didn’t work and I don’t know why…
here is my code, it is a sample from wiki.
second is my translation file - Lang_zh, I placed it on the file where Screen3.java and the src file on
I got “can’t find resource for bundle java.util.PropertyResourceBundle,key nice game” for error message
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.system.AppSettings;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.ImageBuilder;
import de.lessvoid.nifty.builder.LayerBuilder;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.builder.ScreenBuilder;
import de.lessvoid.nifty.builder.TextBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.label.builder.LabelBuilder;
import java.util.ResourceBundle;
/**
- This demo shows a two-screen layout in Nifty’s Java syntax.
- You see two screens with two layers each, containing several panels.
- The panels contain images, text, and controls (label and buttons).
- Buttons have an interaction defined, and some of the text
- is dynamically defined, using the MyStartScreen controller.
-
@author iamcreasy
*/
public class Screen3 extends SimpleApplication {
private static Screen3 app;
public static void main(String[] args) {
app = new Screen3();
AppSettings settings = new AppSettings(true);
settings.setResolution(640, 480);
app.setShowSettings(false); // splashscreen
app.setSettings(settings);
app.start();
}
@Override
public void simpleInitApp() {
app.setDisplayFps(false);
app.setDisplayStatView(false);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(
assetManager, inputManager, audioRenderer, guiViewPort);
Nifty nifty = niftyDisplay.getNifty();
guiViewPort.addProcessor(niftyDisplay);
flyCam.setDragToRotate(true);
nifty.loadStyleFile("nifty-default-styles.xml");
nifty.loadControlFile("nifty-default-controls.xml");
// <screen>
nifty.addScreen("start", new ScreenBuilder("start") {{
controller(new mygame.MyStartScreen());
layer(new LayerBuilder("background") {{
childLayoutCenter();
// add image
image(new ImageBuilder() {{
filename("Interface/start-background.png");
}});
}});
layer(new LayerBuilder("foreground") {{
childLayoutVertical();
// panel added
panel(new PanelBuilder("panel_top") {{
childLayoutCenter();
alignCenter();
height("25%");
width("75%");
// add text
text(new TextBuilder() {{
text(ResourceBundle.getBundle("Lang").getString("nice Game"));
font("Interface/Fonts/Default.fnt");
height("100%");
width("100%");
}});
}});
panel(new PanelBuilder("panel_mid") {{
childLayoutCenter();
alignCenter();
height("50%");
width("75%");
// add text
text(new TextBuilder() {{
text(ResourceBundle.getBundle("Lang").getString("hello World"));
wrap(true);
height("100%");
width("100%");
}});
}});
panel(new PanelBuilder("panel_bottom") {{
childLayoutHorizontal();
alignCenter();
height("25%");
width("75%");
panel(new PanelBuilder("panel_bottom_left") {{
childLayoutCenter();
valignCenter();
height("50%");
width("50%");
// add button controlStart")"{{
control(new ButtonBuilder("StartButton", ResourceBundle.getBundle("Lang").getString("Start")){{
alignCenter();
valignCenter();
height("50%");
width("50%");
visibleToMouse(true);
interactOnClick("startGame(hud)");
}});
}});
panel(new PanelBuilder("panel_bottom_right") {{
childLayoutCenter();
valignCenter();
height("50%");
width("50%");
// add button control
control(new ButtonBuilder("QuitButton", ResourceBundle.getBundle("Lang").getString("Quit")){{
alignCenter();
valignCenter();
height("50%");
width("50%");
visibleToMouse(true);
interactOnClick("quitGame()");
}});
}});
}}); // panel added
}});
}}.build(nifty));
nifty.addScreen("hud", new ScreenBuilder("hud") {{
controller(new mygame.MyStartScreen());
layer(new LayerBuilder("background") {{
childLayoutCenter();
// add image
image(new ImageBuilder() {{
filename("Interface/hud-frame.png");
}});
}});
layer(new LayerBuilder("foreground") {{
childLayoutHorizontal();
// panel added
panel(new PanelBuilder("panel_left") {{
childLayoutVertical();
height("100%");
width("80%");
// <!-- spacer -->
}});
panel(new PanelBuilder("panel_right") {{
childLayoutVertical();
height("100%");
width("20%");
panel(new PanelBuilder("panel_top_right1") {{
childLayoutCenter();
height("15%");
width("100%");
// add label control
control(new LabelBuilder(){{
id("score");
color("#000");
text("123");
width("100%");
height("100%");
}});
}});
panel(new PanelBuilder("panel_top_right2") {{
childLayoutCenter();
height("15%");
width("100%");
// add image
image(new ImageBuilder() {{
filename("Interface/face1.png");
valignCenter();
alignCenter();
height("50%");
width("30%");
}});
}});
panel(new PanelBuilder("panel_bot_right") {{
childLayoutCenter();
valignCenter();
height("70%");
width("100%");
}});
}}); // panel added
}});
}}.build(nifty));
nifty.gotoScreen("start"); // start the screen
//nifty.gotoScreen("hud"); // start the screen
}
}
[/java]
Lang_zh.properties
nice Game = 好遊戲
hello World = 你好世界
Start = 開始遊戲
Quit = 離開
Thank you for help me.
Hope people who help me will get million yearly salary^^