예제 #1
0
  /**
   * Loads java-ui.properties and sets all key-value pairs using UIManager.put(). This is needed to
   * translate JFileChooser to languages not supported by Java natively.
   */
  private void updateJavaUILanguage() {
    // load properties jar file
    if (currentLocale == ((AppD) app).getLocale()) return;

    // update locale
    currentLocale = ((AppD) app).getLocale();
    String lang = currentLocale.getLanguage();
    boolean deleteKeys = false;

    if ("it".equals(lang)
        || "zh".equals(lang)
        || "ja".equals(lang)
        || "de".equals(lang)
        // || "es".equals(lang) we have our own Spanish translation
        // || "fr".equals(lang) we have our own French translation
        || "ko".equals(lang)
        || "sv".equals(lang)) {
      // get keys to delete
      // as Java is localized in these languages already
      // http://openjdk.java.net/groups/i18n/
      rbJavaUI = MyResourceBundle.loadSingleBundleFile(LocalizationD.RB_JAVA_UI);
      deleteKeys = true;
    } else {
      rbJavaUI = MyResourceBundle.createBundle(LocalizationD.RB_JAVA_UI, currentLocale);
    }

    Enumeration<String> keys = rbJavaUI.getKeys();
    while (keys.hasMoreElements()) {
      String key = keys.nextElement();
      String value = deleteKeys ? null : rbJavaUI.getString(key);
      UIManager.put(key, value);
    }

    // update file chooser
    if (getFileChooser() != null) {
      getFileChooser().setLocale(currentLocale);
      SwingUtilities.updateComponentTreeUI(getFileChooser());

      // Unfortunately the preceding line removes the event listener from
      // the
      // internal JTextField inside the file chooser. This means that the
      // listener has to be registered again. (e.g. a simple call to
      // 'AutoCompletion.install(this);' inside the GeoGebraFileChooser
      // constructor is not sufficient)
      AutoCompletion.install(getFileChooser(), true);
    }
  }
예제 #2
0
  /** Returns the Maxima command for the given key (from ggb2Maxima.properties) */
  public synchronized String getTranslatedCASCommand(String key) {
    if (ggb2Maxima == null) {
      ggb2Maxima = MyResourceBundle.loadSingleBundleFile(RB_GGB_TO_Maxima);
    }

    String ret;
    try {
      ret = ggb2Maxima.getString(key);
    } catch (MissingResourceException e) {
      ret = null;
    }

    return ret;
  }