38 lines
1.0 KiB
C#
38 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class LanguageDetector<T>
|
|
{
|
|
[SerializeField]
|
|
public List<IndexValuePair<SystemLanguageEnum, T>> InstanceTemplates;
|
|
|
|
|
|
public T DetectInstanceBasedOnLanguage()
|
|
{
|
|
/*if (!PlayerPrefs.HasKey("language"))
|
|
throw new Exception("Language not setted !!!");*/
|
|
|
|
switch (PlayerPrefs.GetString("language"))
|
|
{
|
|
case "English":
|
|
{
|
|
return InstanceTemplates.Where(template => template.Key == SystemLanguageEnum.English).First().Value;
|
|
}
|
|
case "Polish":
|
|
{
|
|
return InstanceTemplates.Where(template => template.Key == SystemLanguageEnum.Polish).First().Value;
|
|
}
|
|
default:
|
|
{
|
|
return InstanceTemplates.Where(template => template.Key == SystemLanguageEnum.Polish).First().Value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|