Added german language, finished controller
This commit is contained in:
42
Assets/Scripts/Handler/TextHandler.cs
Normal file
42
Assets/Scripts/Handler/TextHandler.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user