Esempio n. 1
0
        static public PoFile CreatePofileFromLocalizationCSV(LocalizationFile localizationFile, string Language)
        {
            PoFile      RetrunPoFile = new PoFile();
            CultureInfo LanguageInfo = new CultureInfo(Language);

            foreach (LocalizationFileLanguageListValues Values in localizationFile.LanguageValues)
            {
                string NewValue = Values.GetValueFromLanguage(LanguageInfo);
                if (NewValue != "--1")
                {
                    PoFileValues poFileValue = new PoFileValues();
                    poFileValue.Key     = Values.Key;
                    poFileValue.msgctxt = "\"," + Values.Key + "\"";
                    if (poFileValue.msgctxt.Substring(0, 1) == "\"")
                    {
                        poFileValue.msgctxt = poFileValue.msgctxt.Substring(1, poFileValue.msgctxt.Length - 1);
                    }

                    if (poFileValue.msgctxt.Substring(poFileValue.msgctxt.Length - 1) == "\"")
                    {
                        poFileValue.msgctxt = poFileValue.msgctxt.Remove(poFileValue.msgctxt.Length - 1);
                    }

                    poFileValue.msgstr = "\"" + NewValue + "\"";
                    if (poFileValue.msgstr.Substring(0, 1) == "\"")
                    {
                        poFileValue.msgstr = poFileValue.msgstr.Substring(1, poFileValue.msgstr.Length - 1);
                    }

                    if (poFileValue.msgstr.Substring(poFileValue.msgstr.Length - 1) == "\"")
                    {
                        poFileValue.msgstr = poFileValue.msgstr.Remove(poFileValue.msgstr.Length - 1);
                    }

                    poFileValue.SourceLocation = Values.SourceLocation;
                    poFileValue.msgid          = Values.SourceValue;

                    RetrunPoFile.Values.Add(poFileValue);
                }
            }

            return(RetrunPoFile);
        }
Esempio n. 2
0
        static public LocalizationFile CombineLocalizationFile(LocalizationFile File_01, LocalizationFile File_02, bool UpdateKeys = false)
        {
            LocalizationFile NewLocalizationFileInfo = new LocalizationFile();

            NewLocalizationFileInfo.KeyCell            = File_01.KeyCell;
            NewLocalizationFileInfo.SourceLocationCell = File_01.SourceLocationCell;
            NewLocalizationFileInfo.SourceCell         = File_01.SourceCell;
            NewLocalizationFileInfo.Languages          = File_01.Languages;

            foreach (LocalizationFileLanguageListValues item in File_01.LanguageValues)
            {
                string CheckValue = item.SourceValue.Trim();

                if (item.Key == "D6A0199D462519E233F60DBDA1B604B2")
                {
                    Console.WriteLine("");
                }

                LocalizationFileLanguageListValues FindValue = File_02.LanguageValues.Find(x => x.SourceValue.Trim() == CheckValue);
                if (FindValue != null)
                {
                    foreach (var Value_source in item.ListValues)
                    {
                        foreach (var Value_combine in FindValue.ListValues)
                        {
                            if (Value_source.CultureInfo.DisplayName == Value_combine.CultureInfo.DisplayName)
                            {
                                if (Value_source.Value == "" && Value_combine.Value != "" && Value_source.SourceValue != Value_combine.Value)
                                {
                                    Value_source.Value = Value_combine.Value;
                                }
                                break;
                            }
                        }
                    }

                    NewLocalizationFileInfo.LanguageValues.Add(item);
                }
                else
                {
                    NewLocalizationFileInfo.LanguageValues.Add(item);
                }
            }


            if (UpdateKeys)
            {
                LocalizationFile NewLocalizationFileInfoKey = new LocalizationFile();
                NewLocalizationFileInfoKey.KeyCell            = File_01.KeyCell;
                NewLocalizationFileInfoKey.SourceLocationCell = File_01.SourceLocationCell;
                NewLocalizationFileInfoKey.SourceCell         = File_01.SourceCell;
                NewLocalizationFileInfoKey.Languages          = File_01.Languages;

                foreach (LocalizationFileLanguageListValues ItemUpdate in NewLocalizationFileInfo.LanguageValues)
                {
                    LocalizationFileLanguageListValues FindKey = File_02.LanguageValues.Find(x => x.Key == ItemUpdate.Key);
                    if (FindKey != null)
                    {
                        foreach (var Value_source in ItemUpdate.ListValues)
                        {
                            foreach (var Value_combine in FindKey.ListValues)
                            {
                                if (Value_source.CultureInfo.DisplayName == Value_combine.CultureInfo.DisplayName)
                                {
                                    Value_source.Value = Value_combine.Value;
                                    NewLocalizationFileInfo.LanguageValues.Add(ItemUpdate);
                                    break;
                                }
                            }
                        }
                    }
                }

                return(NewLocalizationFileInfoKey);
            }

            return(NewLocalizationFileInfo);
        }