Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using Assets.Program_Modules.Localization;
  4. using SimpleLocalization;
  5. using SimpleLocalization.Providers;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8.  
  9. [RequireComponent(typeof(Text))]
  10. public class LocalizatorText : MonoBehaviour
  11. {
  12.     public string LocalizationKey = "MyTestText";
  13.  
  14.     public bool UseGameObjectName;
  15.  
  16.     private Text _text;
  17.  
  18.     private void Awake()
  19.     {
  20.         LocalizationManager.MemoryLocalizationProvider =
  21.             new XmlMemoryLocalizationProvider(new Unity3DResourcesSource());
  22.  
  23.         LocalizationManager.MemoryLocalizationProvider.LoadFrom(
  24.             new Uri($"Localizations{Path.DirectorySeparatorChar}{Application.systemLanguage}", UriKind.Relative));
  25.     }
  26.  
  27.     private void Start()
  28.     {
  29.         _text = GetComponent<Text>();
  30.  
  31.         _text.text = LocalizationManager.MemoryLocalizationProvider[LocalizationKey];
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement