ResxConverter is a tool that helps convert resx files to any format.
ResxConverter is shipped into three main packages.
Both the Cake.ResxConverter and CLI packages include all the available converters, namely support for conversion to iOS and Android resource files.
ResxConverter.Core | ResxConverter.CLI | ResxConverter.Mobile |
---|---|---|
ResxConverter can be used from the command line via the ResxConverter.CLI
package.
Install-Package ResxConverter.CLI
On the command line, converters can be invoked as follows:
ResxConverter.CLI android ./resources ./generated
For complete usage information invoke the CLI without any arguments.
ResxConverter core interfaces are defined in the ResxConverter.Core
package.
Install-Package ResxConverter.Core
The library can be extended by defining new types of outputs. To that end, a new IResxConverterOutput
should be defined.
public class CustomResxOutput : IResxConverterOutput
{
public void Dispose() { ... }
public void WriteComment(string comment) { ... }
public void WriteString(ResxString stringElement) { ... }
}
Note that outputs must implement IDisposable
and they will be disposed after all content is written.
ResxConverter aggregates content by culture. This means that a new IResxConverterOutput
is requested for each culture being processed from the source resx files. Outputs are created via the IResxConverterOutputFactory
interface.
public interface IResxConverterOutputFactory
{
IResxConverterOutput Create(string culture, string outputFolder);
}
You can define a custom factory or reuse the built in ResxConverterOutputFactory
that accepts a lambda. Finally, you use the factory to create an instance of ResxConverter
.
var converter = new ResxConverter(new ResxConverterOutputFactory((culture, outputFolder) => new CustomResxOutput(outputFolder, culture)));