UpdateTranslations() public static method

public static UpdateTranslations ( ) : void
return void
Ejemplo n.º 1
0
        // Draw the whole inspector
        public override void OnInspectorGUI()
        {
            var localization = (LeanLocalization)target;

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("CurrentLanguage"));

            EditorGUILayout.Separator();

            DrawLanguages(localization);

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            DrawPhrases(localization);

            EditorGUILayout.Separator();

            // Update if dirty?
            if (serializedObject.ApplyModifiedProperties() == true || dirty == true)
            {
                dirty = false;

                LeanLocalization.UpdateTranslations();

                EditorUtility.SetDirty(localization);
                EditorApplication.MarkSceneDirty();
            }
        }
Ejemplo n.º 2
0
        public void LoadFromSource()
        {
            if (Source != null && string.IsNullOrEmpty(SourceLanguage) == false)
            {
                var localization = LeanLocalization.GetInstance();
                var lines        = Source.text.Split(newlineCharacters, System.StringSplitOptions.RemoveEmptyEntries);

                foreach (var line in lines)
                {
                    var equalsIndex = line.IndexOf('=');

                    if (equalsIndex != -1)
                    {
                        var phraseName        = line.Substring(0, equalsIndex).Trim();
                        var phraseTranslation = line.Substring(equalsIndex + 1).Trim();

                        // Replace line markers with actual newlines
                        phraseTranslation = phraseTranslation.Replace(newlineString, System.Environment.NewLine);

                        // Does this entry have a comment?
                        var commentIndex = phraseTranslation.IndexOf("//");

                        if (commentIndex != -1)
                        {
                            phraseTranslation = phraseTranslation.Substring(0, commentIndex).Trim();
                        }

                        // Find or add the translation for this phrase
                        var translation = localization.AddTranslation(SourceLanguage, phraseName);

                        // Set the translation text for this phrase
                        translation.Text = phraseTranslation;
                    }
                }

                // Update translations?
                if (localization.CurrentLanguage == SourceLanguage)
                {
                    LeanLocalization.UpdateTranslations();
                }
            }
        }