Skip to content

Instantly share code, notes, and snippets.

@listopad
Last active September 3, 2017 09:41
Show Gist options
  • Save listopad/3f7fdd55de7fa621eb4502608c7f0027 to your computer and use it in GitHub Desktop.
Save listopad/3f7fdd55de7fa621eb4502608c7f0027 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using UnityEngine;
public class Localization : MonoBehaviour
{
public enum Language
{
ENGLISH,
GERMAN,
RUSSIAN
}
public Language language;
private static Dictionary<String, Dictionary<Language, String>> localizationMap = new Dictionary<String, Dictionary<Language, String>>();
static Localization()
{
Dictionary<Language, String> scene1Title = new Dictionary<Language, String>();
scene1Title.Add(Language.ENGLISH, "Clash in the Clouds");
scene1Title.Add(Language.GERMAN, "Kampf in den Wolken");
scene1Title.Add(Language.RUSSIAN, "Столкновение в облаках");
localizationMap.Add("scene1Title", scene1Title);
Dictionary<Language, String> scene2Title = new Dictionary<Language, String>();
scene2Title.Add(Language.ENGLISH, "Burial at Sea");
scene2Title.Add(Language.GERMAN, "Seebestattung");
scene2Title.Add(Language.RUSSIAN, "Захоронение в море");
localizationMap.Add("scene2Title", scene2Title);
Dictionary<Language, String> scene3Title = new Dictionary<Language, String>();
scene3Title.Add(Language.ENGLISH, "Minerva's Den");
scene3Title.Add(Language.GERMAN, "Minervas Höhle");
scene3Title.Add(Language.RUSSIAN, "Пещера Минервы");
localizationMap.Add("scene3Title", scene3Title);
}
public String getTranslation(String keyWord)
{
Dictionary<Language, String> h = localizationMap[keyWord];
if (h != null)
{
return h[language];
}
else
{
return null;
}
}
public void setLanguage(Language language) { this.language = language; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment