Ejemplo n.º 1
0
    /// <summary>
    /// Sets the language.
    /// </summary>
    /// <param name="langCode">Lang code.</param>
    public void SetLanguage(string langCode)
    {
        InitLanguageXML(langCode, ref xDocLocalizedText);

        if (xDocLocalizedText != null)
        {
            xEleRoot = xDocLocalizedText.Element("Resources");
            PlayerPrefs.SetString("currentLangCode", langCode);

            currentLangCode = langCode;
            if (OnLanguageChangedEvent != null)
            {
                OnLanguageChangedEvent.Invoke(currentLangCode);
            }
        }
        else
        {
            xDocLocalizedText = XDocument.Parse(Resources.Load("strings-" + currentLangCode.ToLower()).ToString());
        }
    }
Ejemplo n.º 2
0
    }                                           // when true all keys return "*"

    public static void Initialize(LanguageCode languageCode, bool clearFiles = false)
    {
        _languageCode  = languageCode;
        _keyValuePairs = new Dictionary <string, LocalizerValue>();
        if (_files is null || clearFiles)
        {
            _files = new List <string>();
        }

        if (!string.IsNullOrEmpty(_styleFile))
        {
            SetStyle(_styleFile);
        }

        foreach (string file in _files)
        {
            LoadFile(file, true);
        }

        OnLanguageChangedEvent?.Invoke();
    }
Ejemplo n.º 3
0
 private static void OnLanguageChanged(SystemLanguage language)
 {
     OnLanguageChangedEvent?.Invoke(language);
 }