com.badlogic.gdx.utils.I18NBundle Java Examples

The following examples show how to use com.badlogic.gdx.utils.I18NBundle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActionLog.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Handles adding messages to the HUD.
 */
public ActionLog() {
  i18n = Main.assets.get("i18n/xibalba", I18NBundle.class);
  actions = new ArrayList<>();

  add("intro");
}
 
Example #2
Source File: Messages.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private static String getFromBundle(String key){
	String result;
	for (I18NBundle b : bundles){
		result = b.get(key);
		//if it isn't the return string for no key found, return it
		if (result.length() != key.length()+6 || !result.contains(key)){
			return result;
		}
	}
	return null;
}
 
Example #3
Source File: Messages.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void setup( Languages lang ){
	//seeing as missing keys are part of our process, this is faster than throwing an exception
	I18NBundle.setExceptionOnMissingKey(false);

	bundles = new ArrayList<>();
	Messages.lang = lang;
	Locale locale = new Locale(lang.code());

	for (String file : prop_files) {
		bundles.add(I18NBundle.createBundle(Gdx.files.internal(file), locale));
	}
}
 
Example #4
Source File: ConfigurationController.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Initiate(priority = HIGH_PRIORITY)
public void initVisUiI18n(final InterfaceService interfaceService, final LocaleService localeService) {
    Locales.setLocale(localeService.getCurrentLocale());
    interfaceService.setActionOnBundlesReload(new Runnable() {
        @Override
        public void run() {
            Locale locale = localeService.getCurrentLocale();
            Locales.setButtonBarBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/buttonbar"), locale));
            Locales.setColorPickerBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/colorpicker"), locale));
            Locales.setDialogsBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/dialogs"), locale));
            Locales.setFileChooserBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/filechooser"), locale));
            Locales.setTabbedPaneBundle(I18NBundle.createBundle(Gdx.files.internal("i18n/visui/tabbedpane"), locale));
        }
    });
}
 
Example #5
Source File: EntityFactory.java    From xibalba with MIT License 4 votes vote down vote up
public EntityFactory() {
  i18n = Main.assets.get("i18n/xibalba", I18NBundle.class);
}
 
Example #6
Source File: Dialogs.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private static I18NBundle getBundle () {
	return Locales.getDialogsBundle();
}
 
Example #7
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns common I18N bundle. If current bundle is null, a default bundle is set and returned */
public static I18NBundle getCommonBundle () {
	if (commonBundle == null) commonBundle = getBundle("com/kotcrab/vis/ui/i18n/Common");
	return commonBundle;
}
 
Example #8
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns I18N bundle used by {@link FileChooser}, if current bundle is null, a default bundle is set and returned */
public static I18NBundle getFileChooserBundle () {
	if (fileChooserBundle == null) fileChooserBundle = getBundle("com/kotcrab/vis/ui/i18n/FileChooser");
	return fileChooserBundle;
}
 
Example #9
Source File: TabbedPane.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private static I18NBundle getBundle () {
	return Locales.getTabbedPaneBundle();
}
 
Example #10
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns I18N bundle used by {@link Dialogs}, if current bundle is null, a default bundle is set and returned */
public static I18NBundle getDialogsBundle () {
	if (dialogsBundle == null) dialogsBundle = getBundle("com/kotcrab/vis/ui/i18n/Dialogs");
	return dialogsBundle;
}
 
Example #11
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private static I18NBundle getBundle () {
	return Locales.getCommonBundle();
}
 
Example #12
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns I18N bundle used by {@link TabbedPane}, if current bundle is null, a default bundle is set and returned */
public static I18NBundle getTabbedPaneBundle () {
	if (tabbedPaneBundle == null) tabbedPaneBundle = getBundle("com/kotcrab/vis/ui/i18n/TabbedPane");
	return tabbedPaneBundle;
}
 
Example #13
Source File: GlobalDebugActions.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
@LmlAction("reloadLocalization") public void reloadLocalization() {
    String language = localeService.getCurrentLocale().getLanguage();
    I18NBundle bundle = I18NBundle.createBundle(Gdx.files.internal("i18n/bundle"), new Locale(language));
    interfaceService.getParser().getData().addI18nBundle("default", bundle);
}
 
Example #14
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns I18N bundle used by {@link ColorPicker}, if current bundle is null, a default bundle is set and returned */
public static I18NBundle getColorPickerBundle () {
	if (colorPickerBundle == null) colorPickerBundle = getBundle("com/kotcrab/vis/ui/i18n/ColorPicker");
	return colorPickerBundle;
}
 
Example #15
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private static I18NBundle getBundle (String path) {
	FileHandle bundleFile = Gdx.files.classpath(path);
	return I18NBundle.createBundle(bundleFile, locale);
}
 
Example #16
Source File: Locales.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
/** Returns I18N bundle used by {@link ButtonBar}, if current bundle is null, a default bundle is set and returned */
public static I18NBundle getButtonBarBundle () {
	if (buttonBarBundle == null) buttonBarBundle = getBundle("com/kotcrab/vis/ui/i18n/ButtonBar");
	return buttonBarBundle;
}
 
Example #17
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes bundle used by {@link TabbedPane}, will not affect already created TabbedPane.
 * If set to null then {@link #getTabbedPaneBundle()} will return default bundle.
 */
public static void setTabbedPaneBundle (I18NBundle tabbedPaneBundle) {
	Locales.tabbedPaneBundle = tabbedPaneBundle;
}
 
Example #18
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes bundle used by {@link ButtonBar}, will not affect already created bars.
 * If set to null then {@link #getButtonBarBundle()} ()} will return default bundle.
 */
public static void setButtonBarBundle (I18NBundle buttonBarBundle) {
	Locales.buttonBarBundle = buttonBarBundle;
}
 
Example #19
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes bundle used by {@link ColorPicker}, will not affect already created pickers.
 * If set to null then {@link #getColorPickerBundle()} will return default bundle.
 */
public static void setColorPickerBundle (I18NBundle colorPickerBundle) {
	Locales.colorPickerBundle = colorPickerBundle;
}
 
Example #20
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes bundle used by {@link Dialogs}, will not affect already created dialogs.
 * If set to null then {@link #getDialogsBundle()} will return default bundle.
 */
public static void setDialogsBundle (I18NBundle dialogsBundle) {
	Locales.dialogsBundle = dialogsBundle;
}
 
Example #21
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes bundle used by {@link FileChooser}, will not affect already created FileChoosers.
 * If set to null then {@link #getFileChooserBundle()} will return default bundle.
 */
public static void setFileChooserBundle (I18NBundle fileChooserBundle) {
	Locales.fileChooserBundle = fileChooserBundle;
}
 
Example #22
Source File: Locales.java    From vis-ui with Apache License 2.0 2 votes vote down vote up
/**
 * Changes common bundle. Since this bundle may be used by multiple VisUI parts it should be changed before loading VisUI.
 * If set to null then {@link #getCommonBundle()} will return default bundle.
 */
public static void setCommonBundle (I18NBundle commonBundle) {
	Locales.commonBundle = commonBundle;
}
 
Example #23
Source File: App.java    From gdx-texture-packer-gui with Apache License 2.0 votes vote down vote up
public I18NBundle getI18n() { return localeService.getI18nBundle(); }