Esempio n. 1
0
 private void btnNew_Click(object sender, EventArgs e)
 {
   if (CheckSave())
   {
     NewLanguageDialog newlanguage = new NewLanguageDialog(_languageList);
     if (newlanguage.ShowDialog() == DialogResult.OK)
     {
       _languageList.Add(newlanguage.Selected);
       DrawLanguageList(newlanguage.Selected.Name);
       _targetStrings = new StringFile();
       _targetStrings._languageName = newlanguage.Selected.Name;
       _targetStrings._sections = new List<StringSection>();
       cbLanguages_SelectedIndexChanged(this, new EventArgs());
     }
   }
 }
Esempio n. 2
0
    private void cbLanguages_SelectedIndexChanged(object sender, EventArgs e)
    {
      if (cbLanguages.SelectedIndex != 0 && cbLanguages.SelectedIndex != _currentLanguage)
      {
        if (CheckSave())
        {
          LanguageInfo info = _languageList[cbLanguages.SelectedIndex - 1];
          _targetStrings = LoadStrings(_stringPath, info.Name);

          BuildMissingList();
          ColourMissingSections();
          SetTargetSection();
          BuildEditList();
          DrawTargetList();
          btnSave.Enabled = false;
          _modifiedSection = false;
          _currentLanguage = cbLanguages.SelectedIndex;
        }
      }
      cbLanguages.SelectedIndex = _currentLanguage;
    }
Esempio n. 3
0
    private void LoadDefaultStrings()
    {
      _strings = new LocalisationStrings(_stringPath);
      _defaultStrings = LoadStrings(_stringPath, "en");

      // Get Available language list
      _languageList = new List<LanguageInfo>();
      foreach (CultureInfo language in _strings.GetAvailableLanguages())
      {
        if (language.Name != "en")
        {
          LanguageInfo langInfo = new LanguageInfo(language);
          _languageList.Add(langInfo);

        }
      }

      DrawLanguageList(null);

      // Build section trees
      treeSections.Nodes.Clear();
     
      tvSections.Nodes.Clear();
      foreach (StringSection section in _defaultStrings.Sections)
      {
        treeSections.Nodes.Add(section.SectionName);
        tvSections.Nodes.Add(section.SectionName);
      }
    }
Esempio n. 4
0
 private void btnNewStrings_Click(object sender, EventArgs e)
 {
   _defaultStrings = new StringFile();
   _defaultStrings._sections = new List<StringSection>();
   _defaultStrings._languageName = "en";
   tabsModes.Controls[(int)Tabs.Create].Enabled = true;
   tabsModes.SelectedIndex = (int)Tabs.Create;
 }
Esempio n. 5
0
 /// <summary>
 /// Saves the given <paramref name="stringFile"/> to an xml file formated as "strings_<paramref name="language"/>.xml"
 /// in the specified <paramref name="directory"/>.
 /// </summary>
 /// <param name="stringFile">The <see cref="StringFile"/> to save.</param>
 /// <param name="directory">The directory to save the <paramref name="stringFile"/> to.</param>
 /// <param name="language">The language of the <see cref="StringFile"/>.</param>
 /// <returns>Whether the <see cref="StringFile"/> was saved.</returns>
 private static bool SaveStrings(StringFile stringFile, string directory, string language)
 {
   string filename = "strings_" + language + ".xml";
   string path = Path.Combine(directory, filename);
   /// Make a backup of the current languagefile.
   if (File.Exists(path + ".bak"))
     File.Delete(path + ".bak");
   if (File.Exists(path))
     File.Move(path, path + ".bak");
   /// Serialize the StringFile
   try
   {
     XmlSerializer s = new XmlSerializer(typeof(StringFile));
     XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
     ns.Add("", "");
     using (XmlTextWriter writer = new XmlTextWriter(new StreamWriter(path)))
     {
       writer.Formatting = Formatting.Indented;
       s.Serialize(writer, stringFile, ns);
     }
     return true;
   }
   catch (Exception)
   {
     return false;
   }
 }