i18n for tosamp

This commit is contained in:
Willem Cazander 2022-03-26 22:44:17 +01:00
parent 168bb55af4
commit fabf63607b
4 changed files with 46 additions and 12 deletions

View file

@ -1,5 +1,7 @@
package love.distributedrebirth.gdxapp4d.app.tosamp; package love.distributedrebirth.gdxapp4d.app.tosamp;
import java.util.ResourceBundle;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Component;
@ -10,6 +12,7 @@ import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService; import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4LocaleService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher; import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection; import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection;
@ -28,15 +31,23 @@ public class TosAmpComponent {
@Reference @Reference
private SystemWarpShip warpShip; private SystemWarpShip warpShip;
@Reference
private VrGem4LocaleService localeService;
private final static String I18N_BUNDLE = "love.distributedrebirth.gdxapp4d.app.tosamp.Messages";
private DeskAppLauncher launcher; private DeskAppLauncher launcher;
public TosAmpComponent() { public TosAmpComponent() {
} }
private ResourceBundle createBundle() {
return ResourceBundle.getBundle(I18N_BUNDLE, localeService.getTextLocale());
}
@Activate @Activate
void open(final BundleContext context) { void open(final BundleContext context) {
log.debug(this, SystemGdxLog.ACTIVATE); log.debug(this, SystemGdxLog.ACTIVATE);
launcher = new DeskAppLauncher(DeskAppMenuSection.MULTIMEDIA, "TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser(), context, warpShip)); launcher = new DeskAppLauncher(DeskAppMenuSection.MULTIMEDIA, "TosAmp", () -> new TosAmpDeskApp(createBundle(), bootArgs.getFileChooser(), context, warpShip));
deskAppService.installDeskApp(launcher); deskAppService.installDeskApp(launcher);
} }

View file

@ -1,5 +1,6 @@
package love.distributedrebirth.gdxapp4d.app.tosamp; package love.distributedrebirth.gdxapp4d.app.tosamp;
import java.util.ResourceBundle;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
@ -26,23 +27,29 @@ import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer { public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
private final ResourceBundle bundle;
private final MusicManager music; private final MusicManager music;
private final NativeFileChooser fileChooser; private final NativeFileChooser fileChooser;
private NativeFileChooserConfiguration fileChooserConfig; private NativeFileChooserConfiguration fileChooserConfig;
public TosAmpDeskApp(NativeFileChooser fileChooser, BundleContext context, SystemWarpShip warpShip) { public TosAmpDeskApp(ResourceBundle bundle, NativeFileChooser fileChooser, BundleContext context, SystemWarpShip warpShip) {
this.bundle = bundle;
this.fileChooser = fileChooser; this.fileChooser = fileChooser;
this.music = new MusicManager(); this.music = new MusicManager();
this.music.init(context, warpShip); this.music.init(context, warpShip);
} }
private String getTxt(String key) {
return bundle.getString(TosAmpDeskApp.class.getSimpleName()+"."+key);
}
public void create() { public void create() {
getContours().setTitle("\uf001 TosAmp"); getContours().setTitle(getTxt("title"));
getContours().registrateContour(DeskAppContourSection.MAIN, this); getContours().registrateContour(DeskAppContourSection.MAIN, this);
getContours().registrateContour(DeskAppContourSection.FILE_NEW, new DeskAppRenderer() { getContours().registrateContour(DeskAppContourSection.FILE_NEW, new DeskAppRenderer() {
@Override @Override
public void render() { public void render() {
if (ImGui.menuItem(FontAwesomeIcons.Plus + " Add")) { if (ImGui.menuItem(getTxt("menuAdd"))) {
fileChooser.chooseFile(fileChooserConfig, fileChooser.chooseFile(fileChooserConfig,
NativeFileChooserCallbackAdapter.onFileChosen(v -> music.addBackgroundMusic(v))); NativeFileChooserCallbackAdapter.onFileChosen(v -> music.addBackgroundMusic(v)));
} }
@ -56,7 +63,7 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
@Override @Override
public void render() { public void render() {
ImGui.text("Current Song:"); ImGui.text(getTxt("currentSong"));
MusicSong currentSong = music.getCurrentSong(); MusicSong currentSong = music.getCurrentSong();
if (currentSong != null) { if (currentSong != null) {
ImGui.sameLine(); ImGui.sameLine();
@ -64,11 +71,11 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
} }
ImGui.separator(); ImGui.separator();
if (currentSong != null) { if (currentSong != null) {
if (ImGui.button("Play")) { if (ImGui.button(getTxt("play"))) {
music.play(currentSong); music.play(currentSong);
} }
} else { } else {
ImGui.text("Play"); ImGui.text(getTxt("actionPlay"));
} }
ImGui.sameLine(); ImGui.sameLine();
if (ImGui.button("<")) { if (ImGui.button("<")) {
@ -79,15 +86,15 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
music.next(); music.next();
} }
ImGui.sameLine(); ImGui.sameLine();
if (ImGui.button("Stop")) { if (ImGui.button(getTxt("actionStop"))) {
music.stop(); music.stop();
} }
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV; int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
ImGui.beginTable("playlist", 4, flags); ImGui.beginTable("playlist", 4, flags);
ImGui.tableSetupColumn("#", ImGuiTableColumnFlags.NoHide); ImGui.tableSetupColumn("#", ImGuiTableColumnFlags.NoHide);
ImGui.tableSetupColumn("Play"); ImGui.tableSetupColumn(getTxt("listPlay"));
ImGui.tableSetupColumn("List"); ImGui.tableSetupColumn(getTxt("listName"));
ImGui.tableSetupColumn("Name"); ImGui.tableSetupColumn(getTxt("listSong"));
ImGui.tableHeadersRow(); ImGui.tableHeadersRow();
int i=1; int i=1;
for (MusicSong song:music.getMusicSongs()) { for (MusicSong song:music.getMusicSongs()) {

View file

@ -0,0 +1,8 @@
TosAmpDeskApp.title=\uf001 TosAmp
TosAmpDeskApp.menuAdd=\uf067 Add
TosAmpDeskApp.currentSong=Current Song:
TosAmpDeskApp.actionPlay=Play
TosAmpDeskApp.actionStop=Stop
TosAmpDeskApp.listPlay=Do
TosAmpDeskApp.listName=Playlist
TosAmpDeskApp.listSong=Song

View file

@ -0,0 +1,8 @@
TosAmpDeskApp.title=\uf001 TosAmp
TosAmpDeskApp.menuAdd=\uf067 Add
TosAmpDeskApp.currentSong=Current Song:
TosAmpDeskApp.actionPlay=Play
TosAmpDeskApp.actionStop=Stop
TosAmpDeskApp.listPlay=Do
TosAmpDeskApp.listName=Playlist
TosAmpDeskApp.listSong=Song