Пример #1
0
        private void StartTask(string sourceFile, string destFile, List <string> tags, bool isMove, bool isDelete)
        {
            if (!isDelete)
            {
                foreach (string lang in TranslationFile.SupportedLanguages)
                {
                    TranslationFile srcTranslation  = new TranslationFile(sourceFile, lang);
                    TranslationFile destTranslation = new TranslationFile(destFile, lang);

                    foreach (string tag in tags)
                    {
                        TranslationItem ti = srcTranslation.Items[tag];
                        destTranslation.Items[tag] = ti;
                    }

                    destTranslation.ForceSave();
                }
            }

            if (isMove || isDelete)
            {
                foreach (string lang in TranslationFile.SupportedLanguages)
                {
                    TranslationFile srcTranslation = new TranslationFile(sourceFile, lang);

                    foreach (string tag in tags)
                    {
                        srcTranslation.Items.Remove(tag);
                    }

                    srcTranslation.ForceSave();
                }
            }
        }
Пример #2
0
        private void lbSourceTranslation_SelectedIndexChanged(object sender, EventArgs e)
        {
            clbTags.Items.Clear();

            string srcFile = lbSourceTranslation.SelectedItem as string;

            if (!string.IsNullOrEmpty(srcFile) && File.Exists(srcFile))
            {
                try
                {
                    _srcTranslation = new TranslationFile(srcFile, "ro");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed: " + ex.Message);
                    _srcTranslation = null;
                    return;
                }

                if (_srcTranslation != null && _srcTranslation.Items != null)
                {
                    foreach (TranslationItem ti in _srcTranslation.Items.Values)
                    {
                        clbTags.Items.Add(ti.StringName);
                    }

                    clbTags.Sorted = true;
                }
                else
                {
                    _srcTranslation = null;
                }
            }
        }
Пример #3
0
        private void ReloadTranslations()
        {
            // Save data first
            SaveTranslations();

            string stringName = string.Empty;

            if (lvTranslations.SelectedItems.Count == 1)
            {
                stringName = lvTranslations.SelectedItems[0].SubItems[0].Text;
            }

            lvTranslations.Items.Clear();

            string file = lbTranslationFiles.SelectedItem as string;

            if (!string.IsNullOrEmpty(file) && File.Exists(file))
            {
                try
                {
                    _tf = new TranslationFile(file, cmbLanguage.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ReloadTranslations failed: " + ex.Message);
                    _tf = null;
                }

                if (_tf != null && _tf.Items != null)
                {
                    foreach (TranslationItem ti in _tf.Items.Values)
                    {
                        ListViewItem item = new ListViewItem(new string[]
                        {
                            ti.StringName, ti.BaseString, ti.TranslatedString
                        });

                        item.Tag = ti;

                        lvTranslations.Items.Add(item);
                    }

                    lvTranslations.SelectedItems.Clear();
                    lvTranslations.Select();
                    lvTranslations.Focus();

                    if (!string.IsNullOrEmpty(stringName))
                    {
                        foreach (ListViewItem lvi in lvTranslations.Items)
                        {
                            if (lvi.SubItems[0].Text == stringName)
                            {
                                lvi.Selected = true;
                                lvi.Focused  = true;
                                lvi.EnsureVisible();
                                break;
                            }
                        }
                    }
                }
            }

            EnableMenus();
        }
Пример #4
0
        void ResourceValidationDialog_Load(object sender, EventArgs e)
        {
            Dictionary <string, List <TranslationItem[]> > duplicateTranslations =
                new Dictionary <string, List <TranslationItem[]> >();

            foreach (string file in _scanAssemblies)
            {
                if (!duplicateTranslations.ContainsKey("en"))
                {
                    duplicateTranslations["en"] = new List <TranslationItem[]>();
                }

                TranslationFile tf = new TranslationFile(file, "ro");

                foreach (TranslationItem ti in tf.Items.Values)
                {
                    try
                    {
                        TranslationItem conflict = null;
                        if (CheckConflictingResource("en", ti, ref conflict))
                        {
                            List <TranslationItem[]> lst  = duplicateTranslations["en"];
                            TranslationItem[]        pair = new TranslationItem[2] {
                                ti, conflict
                            };

                            lst.Add(pair);
                        }
                    }
                    catch
                    {
                    }
                }


                foreach (string lang in TranslationFile.SupportedLanguages)
                {
                    if (!duplicateTranslations.ContainsKey(lang))
                    {
                        duplicateTranslations[lang] = new List <TranslationItem[]>();
                    }

                    tf = new TranslationFile(file, lang);

                    foreach (TranslationItem ti in tf.Items.Values)
                    {
                        try
                        {
                            TranslationItem conflict = null;
                            if (CheckConflictingResource(lang, ti, ref conflict))
                            {
                                List <TranslationItem[]> lst  = duplicateTranslations[lang];
                                TranslationItem[]        pair = new TranslationItem[2] {
                                    ti, conflict
                                };

                                lst.Add(pair);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }

            tvResults.Nodes.Clear();

            foreach (KeyValuePair <string, List <TranslationItem[]> > kvp in duplicateTranslations)
            {
                TreeNode langNode = tvResults.Nodes.Add(string.Format("{0} - {1} conflict(s) found", kvp.Key, kvp.Value.Count));

                List <TranslationItem[]> lst = null;

                try
                {
                    lst = kvp.Value.ToList();
                    lst.Sort(CompareSort);
                }
                catch
                {
                }

                foreach (TranslationItem[] cds in lst)
                {
                    TreeNode conflictNode = langNode.Nodes.Add(cds[0].StringName);

                    conflictNode.Nodes.Add(cds[0].ToString());
                    conflictNode.Nodes.Add(cds[1].ToString());
                }
            }

            //tvResults.ExpandAll();
        }