Ejemplo n.º 1
0
 /// <summary>
 /// Check for missing translations
 /// </summary>
 public void Check(_Language _Language)
 {
     foreach (JProperty property in JObject.FromObject(this).Properties())
     {
         if (string.IsNullOrEmpty(property.Value.ToString()))
         {
             Console.WriteLine($"NULL {_Language.ToString()}.{property.Name}");
         }
         else if (property.HasValues)
         {
             foreach (JProperty p in property.Value)
             {
                 if (string.IsNullOrEmpty(p.Value.ToString()))
                 {
                     Console.WriteLine($"NULL {_Language.ToString()}.{property.Name}.{p.Name}");
                 }
             }
         }
     }
     _Data.Translate.Add(_Language, this);
 }
Ejemplo n.º 2
0
    public void SetLanguage(_Language lang)
    {
        this.lang = lang;
        if (lang == _Language.None)
        {
            LanguageLabel.Text = "";
        }
        else
        {
            LanguageLabel.Text = lang.ToString();
        }

        if (runnables.Contains(lang))
        {
            RunButton.Show();
        }
        else
        {
            RunButton.Hide();
        }

        int            line   = 87;
        JsonTextReader reader = new JsonTextReader(new StringReader(File.ReadAllText(path + "bin/Monaco/config.json")));

        while (reader.Read())
        {
            if (reader.Value != null)
            {
                if (reader.TokenType == JsonToken.String)
                {
                    line = Int32.Parse(reader.Value.ToString());
                }
            }
        }
        if (lang == _Language.None)
        {
            ChangeLine("					language: '',", path + "bin/Monaco/Monaco.html", line);
        }
        else
        {
            ChangeLine("					language: '"+ lang.ToString().ToLower() + "',", path + "bin/Monaco/Monaco.html", line);
        }

        if (File.Exists(path + "bin/language.json"))
        {
            File.Delete(path + "bin/language.json");
        }

        StringBuilder sb   = new StringBuilder();
        StringWriter  strw = new StringWriter(sb);

        using (JsonWriter writer = new JsonTextWriter(strw))
        {
            writer.Formatting = Formatting.Indented;
            writer.WriteStartObject();
            writer.WritePropertyName("Language");
            writer.WriteValue(lang.ToString());
            writer.WriteEndObject();
        }

        using (Stream s = File.Open(path + "bin/language.json", FileMode.CreateNew))
            using (StreamWriter sw = new StreamWriter(s))
            {
                sw.Write(sb.ToString());
            }
    }