001    /**
002     * iFish - An iRiver iHP jukebox database creation tool
003     *
004     * Copyright (C) 2009 Richard "Shred" Körber
005     *   http://ifish.shredzone.org
006     *
007     * This program is free software: you can redistribute it and/or modify
008     * it under the terms of the GNU General Public License as published by
009     * the Free Software Foundation, either version 3 of the License, or
010     * (at your option) any later version.
011     *
012     * This program is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015     * GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
019     */
020    package net.shredzone.ifish.i18n;
021    
022    import java.util.*;
023    
024    /**
025     * Offers internationalisation (i18n). It's a simple call of
026     * <code>String text = L.tr("key");</code>.
027     *
028     * @author  Richard Körber &lt;dev@shredzone.de&gt;
029     * @version $Id: L.java 291 2009-04-28 21:29:27Z shred $
030     */
031    public class L {
032      private static final ResourceBundle resource;
033      
034      static {
035        resource = PropertyResourceBundle.getBundle( "net.shredzone.ifish.i18n.GUI" );
036      }
037      
038      /**
039       * Translates a key into the matching translation. If a translation string is
040       * missing, the key is returned enclosed into double square brackets.
041       *
042       * @param   key       Key to be translated
043       * @return  Translated String
044       */
045      public static String tr( String key ) {
046        try {
047          return resource.getString( key ).intern();
048        }catch( MissingResourceException e ) {
049          return "[["+key+"]]";
050        }
051      }
052       
053    }