All Projects → fmuecke → XliffParser

fmuecke / XliffParser

Licence: BSD-2-Clause License
XLIFF (XML Localization Interchange File Format) Parser Library

Programming Languages

C#
18002 projects
smalltalk
420 projects
Batchfile
5799 projects

XliffParser

NuGet version

This library is intended as a thin layer above the original markup to help access the contents of XLIFF (XML Localization Interchange File Format) files.

Its main purposes are:

  • reading values from a XLIFF file
  • changing values inside a XLIFF file
  • exporting translation data to C# resource files (resx)
  • updating XLIFF file from C# resource files (resx)

More information on XLIFF can be found here:

Available on nuget.org

To install XliffParser, run the following command in the Package Manager Console

Install-Package fmdev.XliffParser

Examples

Reading values from a XLIFF file

var doc = new XliffParser.XlfDocument(fileName);
var xlfFile = doc.Files.Single();
foreach (var u in xlfFile.TransUnits)
{
    // id | source | target | target state
    Console.WriteLine("{0}|{1}|{2}", u.Id, u.Source, u.Target, u.Optional.TargetState);
}

Changing values inside a XLIFF file

var unit = xlfFile.AddTransUnit("MyResourceId", "some resouce string", "my awesome translation");
unit.Optional.TargetState = "translated";
unit.Optional.AddNote("No comment!", "XliffParser");
doc.Save();

Exporting translation data to C# resource files (resx)

doc.SaveAsResX();

Updating XLIFF file from C# resource files (resx)

var result = doc.UpdateFromSource();
Console.WriteLine("updated: {0}, added: {1}, removed: {2}",
    result.UpdatedItems.Count(), result.AddedItems.Count(), result.RemovedItems.Count());
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].