Exemple #1
0
        /// <summary>
        /// Load the localization from the user settings
        /// </summary>
        public static void LoadLocalization()
        {
            string cultureCode = Properties.Settings.Default.Localization_CultureCode;

            if (string.IsNullOrEmpty(cultureCode))
            {
                cultureCode = CultureInfo.CurrentCulture.Name;
            }

            LocalizationInfo info = LocalizationList.Where(x => x.Code == cultureCode).FirstOrDefault();

            if (info == null)
            {
                info = LocalizationList.First();
            }

            if (info.Code != Properties.Resources.Localization_DefaultCultureCode)
            {
                ChangeLocalization(info);
            }
            else
            {
                CurrentLocalization = info;
            }
        }
Exemple #2
0
 public void OnEnable()
 {
     LocalizationList   = (LocalizationList)target;
     SOStringListEditor = new SerializedObject(LocalizationList);
     StringListList     = SOStringListEditor.FindProperty("StringListList");
     StringListList     = SOStringListEditor.FindProperty("StringListList");
     Count = SOStringListEditor.FindProperty(ListCount);
 }
        private (string, TimeSpan) Translate_Base(string resourceId, string lang)
        {
            var sw = new Stopwatch();

            sw.Start();

            var value = LocalizationList
                        .FirstOrDefault(x => x.ResourceId == resourceId && x.Lang == lang)?.Value;

            sw.Stop();
            return(value, sw.Elapsed);
        }
        public void Setup()
        {
            LocalizationList = LocalizationItemService.GetList();

            var comparer = StringComparer.OrdinalIgnoreCase;

            LocalizationDictionary = LocalizationList.ToDictionary(x => $"{x.ResourceId}_{x.Lang}", x => x.Value, comparer);

            var lastItem = LocalizationList.Last();

            _resourceId = lastItem.ResourceId;
            _lang       = "ar";
        }
        private (string, TimeSpan) Translate_IgnoreCase3(string resourceId, string lang)
        {
            var sw = new Stopwatch();

            sw.Start();

            var value = LocalizationList
                        .FirstOrDefault(x => x.ResourceId.Equals(resourceId, StringComparison.OrdinalIgnoreCase) &&
                                        x.Lang.Equals(lang, StringComparison.OrdinalIgnoreCase))
                        ?.Value;

            sw.Stop();
            return(value, sw.Elapsed);
        }
Exemple #6
0
    public string GetTextForKey(string key)
    {
        LocalizationList item = localizationSO.listData.Find(a => a.key == key);

        if (item == null)
        {
            return(null);
        }
        LocalizationValue itemValue = item.value.Find(a => a.language == currentLanguage);

        if (itemValue == null)
        {
            return(null);
        }
        return(itemValue.text);
    }
Exemple #7
0
    public override void OnBodyGUI()
    {
        //isFirstNode = new SerializedObject((target as DialogueNode)).FindProperty("isFirstNode");
        GUILayout.BeginHorizontal();
        DialogueNode     DialogueNode     = (DialogueNode)target;
        LocalizationList LocalizationList = (DialogueNode.graph as DialogueGraph).LocalizationList;

        NodeEditorGUILayout.PortField(target.GetInputPort("Input"), GUILayout.Width(100));
        EditorGUILayout.Space();
        if (DialogueNode.answers.Count == 0)
        {
            NodeEditorGUILayout.PortField(target.GetOutputPort("Output"), GUILayout.Width(100));
        }
        GUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("First Node", EditorStyles.boldLabel);
        bool tmp  = EditorGUILayout.Toggle(DialogueNode.isFirstNode);
        bool flag = false;

        foreach (DialogueNode node in DialogueNode.graph.nodes)
        {
            if (tmp == true && node.isFirstNode == true)
            {
                flag = true;
            }
        }
        if (flag == false)
        {
            DialogueNode.isFirstNode = tmp;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.LabelField("Dialogue", EditorStyles.boldLabel);
        EditorGUILayout.LabelField("Dialogue Key");
        DialogueNode.TextKey = EditorGUILayout.Popup(DialogueNode.TextKey, LocalizationList.targetStringList.Keys.ToArray());
        EditorGUILayout.LabelField("Dialogue Content");
        LocalizationList.targetStringList.Dialogue[DialogueNode.TextKey] = EditorGUILayout.TextArea(LocalizationList.targetStringList.Dialogue[DialogueNode.TextKey]);
        EditorGUILayout.LabelField("Dialogue Replies", EditorStyles.boldLabel);
        for (int i = 0; i < DialogueNode.answers.Count; i++)
        {
            EditorGUILayout.BeginVertical("box");
            EditorGUILayout.LabelField("Key");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.Width(30)))
            {
                DialogueNode.RemoveInstancePort(DialogueNode.answers[i].portName);
                DialogueNode.answers.RemoveAt(i);
                i--;
            }

            //DialogueNode.answers[i].TextKey = EditorGUILayout.TextField(DialogueNode.answers[i].TextKey);
            DialogueNode.answers[i].TextKey = EditorGUILayout.Popup(DialogueNode.answers[i].TextKey, LocalizationList.targetStringList.Keys.ToArray());
            NodeEditorGUILayout.PortField(new GUIContent(), target.GetOutputPort(DialogueNode.answers[i].portName), GUILayout.Width(-4));
            GUILayout.EndHorizontal();
            EditorGUILayout.LabelField("Content");
            LocalizationList.targetStringList.Dialogue[DialogueNode.answers[i].TextKey] = EditorGUILayout.TextArea(LocalizationList.targetStringList.Dialogue[DialogueNode.answers[i].TextKey]);
            EditorGUILayout.EndVertical();
        }
        if (GUILayout.Button("+", GUILayout.Width(30)))
        {
            NodePort newport = DialogueNode.AddInstanceOutput(typeof(DialogueNode));
            DialogueNode.answers.Add(new DialogueNode.Answer()
            {
                portName = newport.fieldName
            });
        }
    }