Exemplo n.º 1
0
        public static void LoadLanguage()
        {
            if (m_LanguageLoaded)
            {
                return;
            }

            m_Language = CocoLanguage.English;
            if (PlayerPrefs.HasKey(SAVEKEY))
            {
                m_Language = (CocoLanguage)Enum.Parse(typeof(CocoLanguage), PlayerPrefs.GetString(SAVEKEY));
            }
            else
            {
                m_Language = GetDeviceLanguage();
            }

    #if UNITY_EDITOR
            if (CocoDebugSettingsData.Instance.IsEditorLanguageEnabled)
            {
                m_Language = CocoDebugSettingsData.Instance.EditorLanguage;
            }
    #endif
            CocoLocalization.SetLanguage(GetLanguageName(m_Language));
            m_LanguageLoaded = CocoLocalization.IsDictionaryLoaded;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function is called by the Localization manager via a broadcast SendMessage.
        /// </summary>

        protected virtual void OnLocalize()
        {
            // If no localization key has been specified, use the label's text as the key
            if (string.IsNullOrEmpty(key))
            {
                Text lbl = GetComponent <Text> ();
                if (lbl != null)
                {
                    key = lbl.text;
                }
            }

            // If we still don't have a key, leave the value as blank
            if (!string.IsNullOrEmpty(key))
            {
                value = CocoLocalization.Get(key);
            }
        }
Exemplo n.º 3
0
 public static void SetLanguage(CocoLanguage language)
 {
     PlayerPrefs.SetString(SAVEKEY, language.ToString());
     m_Language = language;
     CocoLocalization.SetLanguage(GetLanguageName(m_Language));
 }