ReadPo() public method

public ReadPo ( ) : List
return List
Exemplo n.º 1
0
        private void readPOToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".po";
            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                PoReader       reader  = new PoReader(dialog.FileName);
                List <PoEntry> entries = reader.ReadPo();
                ApplyPo        applyPo = new ApplyPo();
                applyPo.Apply(entries, resourceDirectory, new StringWriter());
                PopulateListView();
            }
        }
Exemplo n.º 2
0
        private void SynchronizePoFile(string resxDirectory, string poDirectory, string baseName, CultureInfo culture, string programName, string email, string version, TextWriter statusOutput)
        {
            ResourceDirectory resourceDirectory = new ResourceDirectory();

            statusOutput.WriteLine("Reading RESX directory '{0}' for culture '{1}'", resxDirectory, culture.Name);
            resourceDirectory.ReadFiles(resxDirectory, culture);
            resourceDirectory.ReadResources();

            foreach (var resX in resourceDirectory.AllFiles)
            {
                statusOutput.WriteLine("   {0}", resX);
            }
            statusOutput.WriteLine();

            string cultureName = culture.Name;

            if (cultureName.EndsWith("-NO"))
            {
                cultureName = cultureName.Substring(0, 2);
            }
            cultureName = cultureName.Replace("-", "_");

            string poFileName = Path.Combine(poDirectory, baseName + "-" + cultureName + ".po");

            statusOutput.WriteLine("Reading PO file '{0}' for culture '{1}'", poFileName, culture.Name);
            PoReader       reader  = new PoReader(poFileName);
            List <PoEntry> entries = reader.ReadPo();
            ApplyPo        applyPo = new ApplyPo();

            applyPo.Apply(entries, resourceDirectory, statusOutput);

            resourceDirectory.WriteResources();

            PoWriterAttributes attributes = new PoWriterAttributes()
            {
                Name     = programName,
                Email    = email,
                Version  = version,
                writePOT = false
            };

            PoWriter potWriter = new PoWriter(poFileName, attributes);

            potWriter.WritePot(resourceDirectory);
        }
Exemplo n.º 3
0
        private void SynchronizePoFile(string resxDirectory, string poDirectory, string baseName, CultureInfo culture, string programName, string email, string version, TextWriter statusOutput)
        {
            ResourceDirectory resourceDirectory = new ResourceDirectory();

            statusOutput.WriteLine("Reading RESX directory '{0}' for culture '{1}'", resxDirectory, culture.Name);
            resourceDirectory.ReadFiles(resxDirectory, culture);
            resourceDirectory.ReadResources();

            foreach (var resX in resourceDirectory.AllFiles) {
                statusOutput.WriteLine("   {0}", resX);
            }
            statusOutput.WriteLine();

            string cultureName = culture.Name;
            if (cultureName.EndsWith("-NO"))
                cultureName = cultureName.Substring(0, 2);
            cultureName = cultureName.Replace("-", "_");

            string poFileName = Path.Combine(poDirectory, baseName + "-" + cultureName + ".po");

            statusOutput.WriteLine("Reading PO file '{0}' for culture '{1}'", poFileName, culture.Name);
            PoReader reader = new PoReader(poFileName);
            List<PoEntry> entries = reader.ReadPo();
            ApplyPo applyPo = new ApplyPo();
            applyPo.Apply(entries, resourceDirectory, statusOutput);

            resourceDirectory.WriteResources();

            PoWriterAttributes attributes = new PoWriterAttributes() {
                Name = programName,
                Email = email,
                Version = version,
                writePOT = false
            };

            PoWriter potWriter = new PoWriter(poFileName, attributes);
            potWriter.WritePot(resourceDirectory);
        }
Exemplo n.º 4
0
 private void readPOToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OpenFileDialog dialog = new OpenFileDialog();
     dialog.DefaultExt = ".po";
     if (dialog.ShowDialog(this) == DialogResult.OK) {
         PoReader reader = new PoReader(dialog.FileName);
         List<PoEntry> entries = reader.ReadPo();
         ApplyPo applyPo = new ApplyPo();
         applyPo.Apply(entries, resourceDirectory, new StringWriter());
         PopulateListView();
     }
 }
Exemplo n.º 5
0
        public void ReadSamplePoEntries()
        {
            PoReader reader = new PoReader(GetTestFile("SamplePo.po"));
            List<PoEntry> entries = reader.ReadPo();
            StringWriter writer = new StringWriter();

            foreach (PoEntry entry in entries) {
                writer.WriteLine("====Entry===");
                writer.WriteLine("English: '{0}'", entry.NonLocalized);
                writer.WriteLine("Translated: '{0}'", entry.Localized);
                writer.WriteLine("Locations:");
                foreach (PoLocation location in entry.Locations) {
                    writer.WriteLine("    {0},{1}", location.FileName, location.Name);
                }
            }

            string result = writer.ToString();
            string expected =
            @"====Entry===
            English: 'Purple Pen is free software and may be copied and shared.'
            Translated: 'Purple Pen est un logiciel libre et peut être copié et partagé.'
            Locations:
            AboutForm.resx,freeLabel.Text
            ====Entry===
            English: 'View Full License'
            Translated: 'Voir la licence complète'
            Locations:
            AboutForm.resx,okButton.Text
            AddCourse.resx,okButton.Text
            ====Entry===
            English: 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, '
            Translated: 'CE LOGICIEL EST FOURNI ""TEL QUEL"" PAR LES DÉTENTEURS DU COPYRIGHT ET PAR LES CONTRIBUTEURS. TOUTES GARANTIES EXPLICITES OU IMPLICITES (INCLUANT, MAIS '
            Locations:
            AboutForm.resx,disclaimerLabel.Text
            ";

            Assert.AreEqual(expected, result);
        }