it.tidalwave.bluebill.taxonomy.birds.ebn.italia.EbnItaliaLocaleInfo Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - open source birdwatching
* ==========================================
*
* Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
* http://bluebill.tidalwave.it/mobile/
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* $Id: EbnItaliaLocaleInfo.java,v d3b28eab0cdd 2010/08/01 20:17:04 fabrizio $
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.taxonomy.birds.ebn.italia;
import it.tidalwave.bluebill.taxonomy.birds.BirdLocaleInfo;
import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.Map;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import it.tidalwave.util.NotFoundException;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: $
*
**********************************************************************************************************************/
public class EbnItaliaLocaleInfo implements BirdLocaleInfo
{
private final Map> languages2 = new HashMap>();
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public EbnItaliaLocaleInfo (@Nonnull final String resourceName)
throws IOException
{
final BufferedReader br = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(resourceName), "UTF-8"));
br.readLine(); // skip header
for (;;)
{
final String s = br.readLine();
if (s == null)
{
break;
}
final String[] split = s.split("\\$");
final Map languages = new HashMap();
languages.put("en", split[14].trim());
languages.put("da", split[15].trim());
languages.put("de", split[16].trim());
languages.put("es", split[17].trim());
languages.put("fi", split[18].trim());
languages.put("fr", split[19].trim());
languages.put("it", split[20].trim());
languages.put("nl", split[21].trim());
languages.put("no", split[22].trim());
languages.put("sv", split[23].trim());
languages.put("en_US", split[24].trim());
// System.err.println(">>>> " + languages);
languages2.put(split[3].trim(), languages);
languages2.put(split[20].trim(), languages);
}
br.close();
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override @Nonnull
public String getLocalizedName (final @Nonnull String keyName, final @Nonnull String language)
throws NotFoundException
{
final Map languages = languages2.get(keyName);
if (languages == null)
{
throw new NotFoundException();
}
final String localizedName = languages.get(language);
if (localizedName == null)
{
throw new NotFoundException();
}
return localizedName;
}
}