aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/Localisation/LocalisationSystem.cs
blob: 3d48244ed60bb5beac17d318ab42c095fa09bfd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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<string, string> localisedEN;
   private static Dictionary<string, string> 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;
   }

}