Ejemplo n.º 1
0
        private void Awake()
        {
            if (_textTranslate != null)
            {
                _dicTranslate.Clear();
                if (PlayerPrefs.HasKey("KtranslaterLanguage"))
                {
                    _language = (SystemLanguage)PlayerPrefs.GetInt("KtranslaterLanguage");
                }
                int numberColumn = GetColumnNumber(_language.ToString());
                if (numberColumn != -1)
                {
                    string[] fileLine = _textTranslate.text.Split('\n');

                    for (int i = 1; i < fileLine.Length; i++)
                    {
                        string[] line = fileLine[i].Split(',');
                        if (line.Length > 1)
                        {
                            _dicTranslate.Add(KTranslateUtils.ClearString(line[0]),
                                              KTranslateUtils.ClearString(line[numberColumn]));
                        }
                    }
                }
                if (_LanguageChoice != null)
                {
                    SetDropDown();
                }
            }
            else
            {
                Debug.LogError("Please define dictionary file");
            }
        }
Ejemplo n.º 2
0
        void LoadFile()
        {
            _dicTranslate.Clear();

            if (_textTranslate != null)
            {
                var fileLine = _textTranslate.text.Split('\n');
                var langLine = fileLine[0].Split(',');
                Language.Clear();

                for (int target = 1; target < langLine.Length; target++)
                {
                    Language.Add(KTranslateUtils.ClearString(langLine[target]));
                }

                for (int target = 1; target < fileLine.Length; target++)
                {
                    if (fileLine[target].Length > 1)
                    {
                        var      item  = new List <string>();
                        string[] words = fileLine[target].Split(',');
                        if (words[0] != null && words[0] != "")
                        {
                            for (int i = 1; i < words.Length; i++)
                            {
                                string word = KTranslateUtils.ClearString(words[i]);
                                item.Add(word);
                            }
                        }
                        _dicTranslate.Add(KTranslateUtils.ClearString(words[0]), item);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        int GetColumnNumber(string lang)
        {
            int target = -1;

            string[] fileLine     = _textTranslate.text.Split('\n');
            string[] ListLanguage = fileLine[0].Split(',');
            for (int i = 0; i < ListLanguage.Length; i++)
            {
                if (KTranslateUtils.ClearString(ListLanguage[i]) == lang)
                {
                    target = i;
                }
            }
            return(target);
        }
Ejemplo n.º 4
0
        private void SetDropDown()
        {
            if (_LanguageChoice != null)
            {
                List <string> listLanguage = new List <string>();

                string[] fileLineL  = _textTranslate.text.Split('\n');
                string[] arrayLangL = fileLineL[0].Split(',');

                for (int i = 1; i < arrayLangL.Length; i++)
                {
                    listLanguage.Add(KTranslateUtils.ClearString(arrayLangL[i]));
                }

                foreach (string VARIABLE in listLanguage)
                {
                    _LanguageChoice.options.Add(new Dropdown.OptionData(VARIABLE));
                }
                _LanguageChoice.value = GetColumnNumber((_language - 1).ToString());
                _LanguageChoice.onValueChanged.AddListener(delegate { DropdownValueChanged(_LanguageChoice); });
            }
        }