StonehearthEditor.FilePreview.EditLocStringCallback.OnAccept C# (CSharp) Method

OnAccept() public method

public OnAccept ( string inputMessage ) : bool
inputMessage string
return bool
            public bool OnAccept(string inputMessage)
            {
                string key = mLocKey;
                string[] split = key.Split(':');
                string modName = "stonehearth";

                if (split.Length > 1)
                {
                    modName = split[0];
                    key = split[1];
                }

                Module mod = ModuleDataManager.GetInstance().GetMod(modName);
                if (mod == null)
                {
                    MessageBox.Show("Could not change loc key. There is no mod named " + modName);
                    return true;
                }

                JValue token = mod.EnglishLocalizationJson.SelectToken(key) as JValue;
                if (token == null)
                {
                    // No such localization key. Try to add it.
                    string[] tokenSplit = key.Split('.');
                    JObject parent = mod.EnglishLocalizationJson;
                    for (int i = 0; i < tokenSplit.Length - 1; ++i)
                    {
                        if (parent == null)
                        {
                            break;
                        }

                        if (parent[tokenSplit[i]] == null)
                        {
                            parent[tokenSplit[i]] = new JObject();
                        }

                        parent = parent[tokenSplit[i]] as JObject;
                    }

                    if (parent == null)
                    {
                        MessageBox.Show("Could not insert localization token " + mLocKey);
                        return true;
                    }

                    parent.Add(tokenSplit[tokenSplit.Length - 1], inputMessage);
                }
                else
                {
                    token.Value = inputMessage;
                }

                mod.WriteEnglishLocalizationToFile();
                return true;
            }
FilePreview.EditLocStringCallback