From 849c109ae26960be15722f01b9ea8230f4a2efc2 Mon Sep 17 00:00:00 2001 From: Alee Date: Mon, 10 Jun 2019 12:13:55 -0400 Subject: Localisation (Working progress) --- Assets/Scripts/Localisation/LocalisationSystem.cs | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Assets/Scripts/Localisation/LocalisationSystem.cs (limited to 'Assets/Scripts/Localisation/LocalisationSystem.cs') diff --git a/Assets/Scripts/Localisation/LocalisationSystem.cs b/Assets/Scripts/Localisation/LocalisationSystem.cs new file mode 100644 index 0000000..3d48244 --- /dev/null +++ b/Assets/Scripts/Localisation/LocalisationSystem.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class LocalisationSystem +{ + public enum Language + { + English, + French + } + + public static Language language = Language.English; + + private static Dictionary localisedEN; + private static Dictionary localisedFR; + + public static bool isInit; + + public static void Init() + { + Debug.Log("Initalizing the localisation system..."); + CSVLoader csvLoader = new CSVLoader(); + csvLoader.LoadCSV(); + + localisedEN = csvLoader.GetDictionaryValues("en"); + localisedFR = csvLoader.GetDictionaryValues("fr"); + + isInit = true; + Debug.Log("Loaded the values for the localisation system."); + } + + public static string GetLocalisedValue(string key) + { + if (!isInit) { Init(); } + + string value = key; + + switch (language) + { + case Language.English: + localisedEN.TryGetValue(key, out value); + break; + case Language.French: + localisedFR.TryGetValue(key, out value); + break; + + } + + return value; + } + +} -- cgit v1.2.3