2023-07-05 14:43:52 +02:00

43 lines
1021 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization.Settings;
public class TextHandler : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public static string getText(string key){
key = key.Replace("(","").Replace(")","");
if(key[0].Equals(Char.ToUpperInvariant(key[0]))){
key = Char.ToLowerInvariant(key[0]) + key.Substring(1);
}
if(key.Contains("\r\n")){
return key;
}
string text = LocalizationSettings.StringDatabase.GetLocalizedString("MyTexts",key);
return text;
}
public static string translate(string text){
string result = "";
for(int i = 0; i < text.Split(" ").Length; i++){
result += getText(text.Split(" ")[i]) + " ";
}
return result;
}
}