Beispiel #1
0
 public void AddPoFileSource(PoFile ToAddPofile)
 {
     foreach (PoFileValues Value in ToAddPofile.Values)
     {
         LocalizationFileLanguageListValues NewLanguageListValues = new LocalizationFileLanguageListValues(Value);
         LanguageValues.Add(NewLanguageListValues);
     }
 }
Beispiel #2
0
 public void CombinePoFile(PoFile ToAddPofile, LanguageCell Language)
 {
     foreach (PoFileValues Value in ToAddPofile.Values)
     {
         CultureInfo NewcultureInfo = new CultureInfo(Language.Language);
         LocalizationFileLanguageListValues NewLanguageListValues = new LocalizationFileLanguageListValues(Value, NewcultureInfo, Language.Cell);
         LanguageValues.Add(NewLanguageListValues);
     }
 }
 /// <summary>
 /// Convert Po-File To Csv-File
 /// </summary>
 /// <param name="ToConvertPoFile">Pofile structur</param>
 /// <param name="CsvFile">To Save CSV-File</param>
 static public void ConvertAndSavePoToCsv(PoFile ToConvertPoFile, FileInfo CsvFile)
 {
     using (System.IO.StreamWriter file = new System.IO.StreamWriter(CsvFile.FullName))
     {
         foreach (PoFileValues Value in ToConvertPoFile.Values)
         {
             file.WriteLine(Value.ExportCsvString());
         }
     }
 }
Beispiel #4
0
 public void AddPoFile(PoFile ToAddPofile, LanguageCell Language)
 {
     foreach (PoFileValues Value in ToAddPofile.Values)
     {
         CultureInfo NewcultureInfo = new CultureInfo(Language.Language);
         LocalizationFileLanguageListValues NewLanguageListValues = new LocalizationFileLanguageListValues(Value, NewcultureInfo, Language.Cell);
         LocalizationFileLanguageListValues TranslateValue        = LanguageValues.Find(x => x.Key == NewLanguageListValues.Key);
         if (TranslateValue != null)
         {
             foreach (var item in NewLanguageListValues.ListValues)
             {
                 TranslateValue.ListValues.Add(item);
             }
         }
     }
 }
        static public PoFile CombinePoFiles(PoFile SourceFile, PoFile ToCombine)
        {
            PoFile RetrunPoFile = new PoFile();

            foreach (PoFileValues Values in SourceFile.Values)
            {
                PoFileValues FindValue = ToCombine.Values.Find(x => x.Key == Values.Key);
                if (FindValue != null)
                {
                    Values.msgstr = FindValue.msgstr;
                }
                RetrunPoFile.Values.Add(Values);
            }

            return(RetrunPoFile);
        }
        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);
        }
        static public PoFile ConvertCsvToPoFile(FileInfo CsvFile)
        {
            PoFile RetrunPoFile = new PoFile();

            if (CsvFile.Exists)
            {
                string   AllData    = File.ReadAllText(CsvFile.FullName);
                string[] DataValues = AllData.Split(new[] { "\n" }, StringSplitOptions.None);
                foreach (string Data in DataValues)
                {
                    PoFileValues poFileValue = new PoFileValues(Data, true);
                    if (poFileValue.valid)
                    {
                        RetrunPoFile.Values.Add(poFileValue);
                    }
                }
            }
            return(RetrunPoFile);
        }