Ejemplo n.º 1
0
        void Import_Language_from_Cache(int langIndex, string langData, bool useFallback, bool onlyCurrentSpecialization)
        {
            int iTerm = 0;
            int index = 0;

            while (index < langData.Length)
            {
                var termData = mTerms[iTerm];
                iTerm++;

                int nextIndex = langData.IndexOf("[i2t]", index);
                if (nextIndex < 0)
                {
                    nextIndex = langData.Length;
                }

                string translation = null;

                if (index != nextIndex)
                {
                    translation = langData.Substring(index, nextIndex - index);
                    if (translation.StartsWith("[i2fb]"))
                    {
                        translation = (useFallback) ? translation.Substring(6) : null;
                    }
                    if (onlyCurrentSpecialization && translation != null)
                    {
                        translation = SpecializationManager.GetSpecializedText(translation, null);
                    }
                }
                termData.Languages[langIndex] = translation;
                index = nextIndex + 5;
            }
        }
Ejemplo n.º 2
0
        [SerializeField] private string[] Languages_Touch = null;      // TO BE REMOVED IN A FUTURE RELEASE

        public string GetTranslation(int idx, string specialization = null)
        {
            string text = Languages[idx];

            if (text != null)
            {
                text = SpecializationManager.GetSpecializedText(text, specialization);
                text = text.Replace("[i2nt]", "").Replace("[/i2nt]", "");
            }
            return(text);
        }
        void Import_Language_from_Cache(int langIndex, string langData, bool useFallback, bool onlyCurrentSpecialization)
        {
            int index = 0;

            while (index < langData.Length)
            {
                int nextIndex = langData.IndexOf("[i2t]", index);
                if (nextIndex < 0)
                {
                    nextIndex = langData.Length;
                }

                // check for errors
                int termNameEnd = langData.IndexOf("=", index);
                if (termNameEnd >= nextIndex)
                {
                    return;
                }

                string termName = langData.Substring(index, termNameEnd - index);
                index = termNameEnd + 1;

                var termData = GetTermData(termName, false);
                if (termData != null)
                {
                    string translation = null;

                    if (index != nextIndex)
                    {
                        translation = langData.Substring(index, nextIndex - index);
                        if (translation.StartsWith("[i2fb]"))
                        {
                            translation = (useFallback) ? translation.Substring(6) : null;
                        }
                        if (onlyCurrentSpecialization && translation != null)
                        {
                            translation = SpecializationManager.GetSpecializedText(translation, null);
                        }
                    }
                    termData.Languages[langIndex] = translation;
                }
                index = nextIndex + 5;
            }
        }