コード例 #1
0
        public void AddTranslationItem(TranslationItem translationItem)
        {
            if (string.IsNullOrEmpty(translationItem.Name))
                throw new InvalidOperationException("Cannot add translationitem without name");

            translationItems.Add(translationItem);
        }
コード例 #2
0
        public void AddTranslationItemIfNotExist(TranslationItem translationItem)
        {
            if (string.IsNullOrEmpty(translationItem.Name))
            {
                throw new InvalidOperationException("Cannot add translationitem without name");
            }

            TranslationItem ti = GetTranslationItem(translationItem.Name, translationItem.Property);

            if (ti == null)
            {
                if (translationItem.Property == "ToolTipText")
                {
                    ti = GetTranslationItem(translationItem.Name, "Text");
                    if (ti == null || translationItem.Value != ti.Value)
                    {
                        translationItems.Add(translationItem);
                    }
                }
                else
                {
                    translationItems.Add(translationItem);
                }
            }
            else
            {
                Debug.Assert(ti.Value == translationItem.Value);
            }
        }
コード例 #3
0
        public void AddTranslationItem(TranslationItem translationItem)
        {
            if (string.IsNullOrEmpty(translationItem.Name))
            {
                throw new InvalidOperationException("Cannot add translationitem without name");
            }

            translationItems.Add(translationItem);
        }
コード例 #4
0
        public void AddTranslationItemIfNotExist(TranslationItem translationItem)
        {
            if (string.IsNullOrEmpty(translationItem.Name))
                throw new InvalidOperationException("Cannot add translationitem without name");

            TranslationItem ti = GetTranslationItem(translationItem.Name, translationItem.Property);
            if (ti == null)
                translationItems.Add(translationItem);
            else
                Debug.Assert(ti.Value == translationItem.Value);
        }
コード例 #5
0
        public string TranslateItem(string category, string item, string property, string defaultValue)
        {
            TranslationCategory tc = GetTranslationCategory(category);

            if (tc == null)
            {
                return(defaultValue);
            }
            TranslationItem ti = tc.GetTranslationItem(item, property);

            return(ti == null || string.IsNullOrEmpty(ti.Value) ? defaultValue : ti.Value);
        }
コード例 #6
0
ファイル: Translation.cs プロジェクト: antis81/gitextensions
        public string TranslateItem(string category, string item, string property, string defaultValue)
        {
            TranslationCategory tc = GetTranslationCategory(category);

            if (tc == null)
            {
                return(defaultValue);
            }
            TranslationItem ti = tc.GetTranslationItem(item, property);

            if (ti == null)
            {
                return(defaultValue);
            }
            else
            {
                return(ti.Value);
            }
        }
コード例 #7
0
 public TranslationItemWithCategory(string category, TranslationItem item)
 {
     Category = category;
     _item = item;
 }
コード例 #8
0
 public TranslationItemWithCategory()
 {
     _item = new TranslationItem();
 }
コード例 #9
0
        private void SaveAs()
        {
            var foreignTranslation = new Translation { GitExVersion = GitCommands.Settings.GitExtensionsVersionString, LanguageCode = GetSelectedLanguageCode() };
            foreach (TranslateItem translateItem in translate)
            {
                string value = translateItem.TranslatedValue ?? String.Empty;
                TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property,
                    translateItem.NeutralValue, value);
                ti.Status = translateItem.Status;
                if (ti.Status == TranslationType.Obsolete &&
                    (String.IsNullOrEmpty(value) || String.IsNullOrEmpty(translateItem.NeutralValue)))
                    continue;
                if (string.IsNullOrEmpty(value))
                {
                    if (ti.Status == TranslationType.Translated || ti.Status == TranslationType.New)
                        ti.Status = TranslationType.Unfinished;
                }
                else
                {
                    // TODO: Support in form
                    if (ti.Status == TranslationType.Unfinished)
                        ti.Status = TranslationType.Translated;
                }
                foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti);
            }

            using (var fileDialog =
                new SaveFileDialog
                    {
                        Title = saveAsText.Text,
                        FileName = translations.Text + ".xml",
                        Filter = saveAsTextFilter.Text + "|*.xml",
                        DefaultExt = ".xml",
                        AddExtension = true
                    })
            {

                if (fileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    TranslationSerializer.Serialize(foreignTranslation, fileDialog.FileName);
                    changesMade = false;
                }
            }
        }
コード例 #10
0
ファイル: FormTranslate.cs プロジェクト: Nehle/gitextensions
        private void SaveAs()
        {
            var foreignTranslation = new Translation { LanguageCode = GetSelectedLanguageCode() };
            if (foreignTranslation.LanguageCode != null)
            {
                foreach (TranslateItem translateItem in translate)
                {
                    //Item is not translated (yet), skip it
                    if (string.IsNullOrEmpty(translateItem.TranslatedValue))
                        continue;

                    TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property, translateItem.TranslatedValue);
                    foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti);
                }
            }
            else
            {
                // English language
                foreach (TranslateItem translateItem in translate)
                {
                    TranslationItem ti = new TranslationItem(translateItem.Name, translateItem.Property, translateItem.NeutralValue);
                    foreignTranslation.FindOrAddTranslationCategory(translateItem.Category).AddTranslationItem(ti);
                }
            }

            var fileDialog =
                new SaveFileDialog
                    {
                        Title = saveAsText.Text,
                        FileName = translations.Text + ".xml",
                        Filter = saveAsTextFilter.Text + "|*.xml",
                        DefaultExt = ".xml",
                        AddExtension = true
                    };

            if (fileDialog.ShowDialog(this) == DialogResult.OK)
            {
                TranslationSerializer.Serialize(foreignTranslation, fileDialog.FileName);
                changesMade = false;
            }
        }