Exemplo n.º 1
0
        private void openDeployToolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LangType = StringsType.DeployTool;

              folderBrowserDialog1.Description = "Please select a path where [MediaPortal.DeployTool.resx] can be found:";
              folderBrowserDialog1.SelectedPath = Application.StartupPath;
              folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop;

              if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
            return;

              languagePath = folderBrowserDialog1.SelectedPath;
              // check if selected path contains the default resx file
              defaultTranslations = ResxHandler.Load(null);

              // if not show folderbrowserdlg until user cancels or selects a path that contains it
              while (defaultTranslations == null)
              {
            MessageBox.Show(
              "The file [MediaPortal.DeployTool.resx] could not be found.\nThe LanguageTool does not work without it.",
              "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
              return;
            languagePath = folderBrowserDialog1.SelectedPath;
            defaultTranslations = ResxHandler.Load(null);
              }

              gv.Dock = DockStyle.Fill;
              gv2.Dock = DockStyle.None;
              gv2.Visible = false;

              DisableMenuItems();

              SelectCulture dlg = new SelectCulture();
              if (dlg.ShowDialog() != DialogResult.OK) return;
              culture = dlg.GetSelectedCulture();
              Text = "MPLanguageTool -- Current language: " + culture.NativeName + " -- File: MediaPortal.DeployTool." +
             culture.Name + ".resx";
              ToolStripText("Loading \"MediaPortal.DeployTool." + culture.Name + ".resx\"...");

              Cursor = Cursors.WaitCursor;
              NameValueCollection translations = ResxHandler.Load(culture.Name);
              int untranslated = 0;
              foreach (string key in defaultTranslations.AllKeys)
              {
            gv.Rows.Add(key, translations[key]);
            if (String.IsNullOrEmpty(translations[key]))
            {
              gv.Rows[gv.RowCount - 1].Cells[0].Style.ForeColor = System.Drawing.Color.Red;
              gv.Rows[gv.RowCount - 1].Cells[1].Style.ForeColor = System.Drawing.Color.Red;
              untranslated++;
            }
              }
              ToolStripText(untranslated);
              saveToolStripMenuItem.Enabled = true;
              Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        private void InvokeXml()
        {
            string tmpFileName = XmlHandler.BuildFileName(null, false);

            folderBrowserDialog1.Description  = "Please select a path where [" + tmpFileName + "] can be found:";
            folderBrowserDialog1.SelectedPath = Application.StartupPath;
            folderBrowserDialog1.RootFolder   = Environment.SpecialFolder.Desktop;

            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            languagePath = folderBrowserDialog1.SelectedPath;

            // check if selected path contains the default translation file
            // if not show folderbrowserdlg until user cancels or selects a path that contains it
            while (!System.IO.File.Exists(System.IO.Path.Combine(languagePath, tmpFileName)))
            {
                MessageBox.Show(
                    "The file [" + tmpFileName + "] could not be found.\nThe LanguageTool does not work without it.",
                    "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                languagePath = folderBrowserDialog1.SelectedPath;
            }

            switch (LangType)
            {
            case StringsType.MpTagThat:
            case StringsType.MediaPortal_II:
                FillSectionsCombbo();
                cbSections.Enabled = true;
                string secs = (string)cbSections.SelectedItem;
                XmlHandler.InitializeXmlValues(secs);
                break;

            default:
                XmlHandler.InitializeXmlValues();
                break;
            }

            // check if selected path contains a valid default translation file
            originalTranslations = LoadSection(null);
            // if not show folderbrowserdlg until user cancels or selects a path with a valid one
            while (originalTranslations == null)
            {
                MessageBox.Show("The file [" + tmpFileName + "] is invalid.\nPlease select a correct working one.",
                                "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                languagePath         = folderBrowserDialog1.SelectedPath;
                originalTranslations = XmlHandler.Load(null, out originalMapping);
            }

            gv.Dock     = DockStyle.None;
            gv2.Dock    = DockStyle.Fill;
            gv2.Visible = true;

            DisableMenuItems();

            SelectCulture dlg = new SelectCulture();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            culture = dlg.GetSelectedCulture();

            tmpFileName = XmlHandler.BuildFileName(culture.Name, false);

            Text = "MPLanguageTool -- Current language: " + culture.NativeName + " -- File: " + tmpFileName;
            ToolStripText("Loading \"" + tmpFileName + "\"...");

            LoadTranslation();
        }
Exemplo n.º 3
0
        private void InvokeXml()
        {
            string tmpFileName = XmlHandler.BuildFileName(null, false);

              folderBrowserDialog1.Description = "Please select a path where [" + tmpFileName + "] can be found:";
              folderBrowserDialog1.SelectedPath = LangType == StringsType.MyFilms ? System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), @"Team MediaPortal\MediaPortal\language\MyFilms") : Application.StartupPath;
              // Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
              folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Desktop;

              if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
            return;
              languagePath = folderBrowserDialog1.SelectedPath;

              // check if selected path contains the default translation file
              // if not show folderbrowserdlg until user cancels or selects a path that contains it
              while (!System.IO.File.Exists(System.IO.Path.Combine(languagePath, tmpFileName)))
              {
            MessageBox.Show(
              "The file [" + tmpFileName + "] could not be found.\nThe LanguageTool does not work without it.",
              "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
              return;
            languagePath = folderBrowserDialog1.SelectedPath;
              }

              switch (LangType)
              {
            case StringsType.MpTagThat:
            case StringsType.MediaPortal_II:
              FillSectionsCombbo();
              cbSections.Enabled = true;
              string secs = (string)cbSections.SelectedItem;
              XmlHandler.InitializeXmlValues(secs);
              break;

            default:
              XmlHandler.InitializeXmlValues();
              break;
              }

              // check if selected path contains a valid default translation file
              originalTranslations = LoadSection(null);
              // if not show folderbrowserdlg until user cancels or selects a path with a valid one
              while (originalTranslations == null)
              {
            MessageBox.Show("The file [" + tmpFileName + "] is invalid.\nPlease select a correct working one.",
                        "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
              return;
            languagePath = folderBrowserDialog1.SelectedPath;
            originalTranslations = XmlHandler.Load(null, out originalMapping);
              }

              gv.Dock = DockStyle.None;
              gv2.Dock = DockStyle.Fill;
              gv2.Visible = true;

              DisableMenuItems();

              SelectCulture dlg = new SelectCulture();
              if (dlg.ShowDialog() != DialogResult.OK) return;
              culture = dlg.GetSelectedCulture();

              tmpFileName = XmlHandler.BuildFileName(culture.Name, false);

              Text = "MPLanguageTool -- Current language: " + culture.NativeName + " -- File: " + tmpFileName;
              ToolStripText("Loading \"" + tmpFileName + "\"...");

              LoadTranslation();
        }
Exemplo n.º 4
0
        private void openDeployToolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LangType = StringsType.DeployTool;

            folderBrowserDialog1.Description  = "Please select a path where [MediaPortal.DeployTool.resx] can be found:";
            folderBrowserDialog1.SelectedPath = Application.StartupPath;
            folderBrowserDialog1.RootFolder   = Environment.SpecialFolder.Desktop;

            if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            languagePath = folderBrowserDialog1.SelectedPath;
            // check if selected path contains the default resx file
            defaultTranslations = ResxHandler.Load(null);

            // if not show folderbrowserdlg until user cancels or selects a path that contains it
            while (defaultTranslations == null)
            {
                MessageBox.Show(
                    "The file [MediaPortal.DeployTool.resx] could not be found.\nThe LanguageTool does not work without it.",
                    "MPLanguageTool -- Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (folderBrowserDialog1.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                languagePath        = folderBrowserDialog1.SelectedPath;
                defaultTranslations = ResxHandler.Load(null);
            }

            gv.Dock     = DockStyle.Fill;
            gv2.Dock    = DockStyle.None;
            gv2.Visible = false;

            DisableMenuItems();

            SelectCulture dlg = new SelectCulture();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            culture = dlg.GetSelectedCulture();
            Text    = "MPLanguageTool -- Current language: " + culture.NativeName + " -- File: MediaPortal.DeployTool." +
                      culture.Name + ".resx";
            ToolStripText("Loading \"MediaPortal.DeployTool." + culture.Name + ".resx\"...");

            Cursor = Cursors.WaitCursor;
            NameValueCollection translations = ResxHandler.Load(culture.Name);
            int untranslated = 0;

            foreach (string key in defaultTranslations.AllKeys)
            {
                gv.Rows.Add(key, translations[key]);
                if (String.IsNullOrEmpty(translations[key]))
                {
                    gv.Rows[gv.RowCount - 1].Cells[0].Style.ForeColor = System.Drawing.Color.Red;
                    gv.Rows[gv.RowCount - 1].Cells[1].Style.ForeColor = System.Drawing.Color.Red;
                    untranslated++;
                }
            }
            ToolStripText(untranslated);
            saveToolStripMenuItem.Enabled = true;
            Cursor = Cursors.Default;
        }