Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gui.utils.LanguageSwitcher.java

Here you can find all the information about the file org.dgpf.gui.utils.LanguageSwitcher.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Universitaet Kassel
 *
 * E-Mail           : mirko.dietrich@hrz.uni-kassel.de
 * Original Filename: org.dgpf.gui.DGPFResourceBundle.java
 *
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */


package org.dgpf.gui.utils;

import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author Mirko Dietrich
 */

public class LanguageSwitcher
  {

  /**
   * Package that contains the <code>PropertyResourceBundles</code>.
   */

  public static final String    propertyResourceBundlePath = "org.dgpf.gui.resources.rb.DGPF";

  /**
   * Holds all GUI strings that have to localized.
   */

  private static ResourceBundle rb;

  /**
   * Delivers a localized String.
   * 
   * @param p_key
   *          The key that identifies the string value.
   * @return The localized string value.
   */

  public static String getString(String p_key)
    {
    if(exists(p_key))
      {
      return rb.getString(p_key);
      }
    return p_key;
    }

  /**
   * Delivers a localized char.
   * 
   * @param p_key
   *          The key that identifies the char value.
   * @return The localized char value.
   */

  public static char getChar(String p_key)
    {
    if(exists(p_key))
      {
      return rb.getString(p_key).charAt(0);
      }
    return p_key.charAt(0);
    }

  /**
   * This method returns true if the key exists, else false.
   * 
   * @param p_key
   *          The key that identifies the string value.
   * @return true, if the key exists.
   */

  private static boolean exists(String p_key)
    {
    for(Enumeration e = rb.getKeys(); e.hasMoreElements();)
      {
      if(e.nextElement().equals(p_key))
        return true;
      }
    return false;
    }

  /**
   * Load a <code>ResourceBundle</code>.
   * 
   * @param p_locale
   *          is the Locale to use.
   */

  public static void loadBundle(Locale p_locale)
    {
    LanguageSwitcher.rb = ResourceBundle.getBundle(
        propertyResourceBundlePath, p_locale);
    }

  /**
   * Load a <code>ResourceBundle</code> using the default Locale.
   */

  public static void loadBundle()
    {
    LanguageSwitcher.rb = ResourceBundle
        .getBundle(propertyResourceBundlePath);
    }

  }

File Information:

file name:LanguageSwitcher.java
package:org.dgpf.gui.utils
qualified name:org.dgpf.gui.utils.LanguageSwitcher.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gui/utils/LanguageSwitcher.java
size:2.894 KB (2964 B)
uploaded: 2015-07-22 04:10:59 GMT+0000
last update: 2006-09-24 23:47:04 GMT+0000
last access: 2017-11-20 02:14:23 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-20 02:14:23 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo