Generic Projects

Babylon is not limited to .NET or Angular. It can also be used to localize projects in any other development environment by using a ResourcesProvider to load and write strings from and to a resource store. Babylon has build-in ResourcesProviders  for JSON, XML, XLIFF and Java .properties files. By customizing an existing provider or by writing a new provider, strings can be loaded and saved in any way your project requires.

XML ResourcesProvider

The provider will read all XML files in the base directory and treat them as files containing string resources. Files are named using the pattern <filename>.[<culture code=code>].xml. The provider assumes invariant strings are contained in a file with no culture code in the file name (e.g. strings.xml). All files containing culture codes (e.g. strings.de-DE.xml) will be treated as translations. Strings not present in the invariant file are ignored. Relative paths are fully supported. Subfolders of the base directory are also processed. The name of the subfolder becomes part of the resource name and therefore all translations of an invariant file must be placed in the same folder. Comments are supported.

Source code available on Github.


XLIFF ResourcesProvider

The provider will read all XLIFF 1.2 files in the selected base directory and all folders underneath it. Files are named using the pattern <filename>.[<culture code=code>].xlf. The provider assumes invariant strings are contained in a file with no culture code in the file name (e.g. strings.xlf). All files containing culture codes (e.g. strings.de-DE.json) will be treated as translations. The source language of the invariant file must match the Babylon.NET's Solution invariant locale. Strings not present in the invariant file are ignored. Relative paths are fully supported. Comments are not supported.

Source code available on Github.


JSON ResourcesProvider

The provider will read all JSON files in the base directory and treat them as files containing string resources. Files are named using the pattern <filename>.[<culture code=code>].json. The provider assumes invariant strings are contained in a file with no culture code in the file name (e.g. strings.json). All files containing culture codes (e.g. strings.de-DE.json) will be treated as translations. Strings not present in the invariant file are ignored. Relative paths are fully supported. Subfolders of the base directory are also processed. The name of the subfolder becomes part of the resource name and therefore all translations of an invariant file must be placed in the same folder. Comments are not supported.

Source code available on Github.


Java .properties ResourcesProvider

The provider will read all Java .properties files in the base directory and treat them as files containing string resources. The provider assumes that invariant strings are contained in a file with no culture codes in the file name (e.g. strings.properties). All files containing culture codes of the form _culturecode-countrycode (e.g. strings_de-DE.json) will be treated as translations. Strings not present in the invariant file are ignored. Relative paths are fully supported. Subfolders of the base directory are also processed. The name of the subfolder becomes part of the resource name and therefore all translations of an invariant file must be placed in the same folder. Only the default ISO-8859-1 (Latin1) encoding is supported. No escaping will be done. Any comments or other lines in the files will be stripped. Comments are not supported.

Source code available on Github.


Writing a Custom ResourcesProvider

A ResourcesProvider is a plugin for Babylon.NET to read and write string resources from and to the string repository of a software project. Strings generally reside in files but can also reside in a database, in a cloud storage or be kept in some other form. If your project spans several development environments having different localization requirements, a ResourcesProvider can also be used to read and write string resources into several different formats and this way combining all strings into one single Babylon.NET solution. This greatly simplifies localization of complex projects.                                     

The easiest way to develop a new ResourcesProvider is to download the source code from an existing ResourcesProvider and modify it to your needs. To implement the IResourceProvider interface reference the ResourceProvider.dll included in every Babylon.NET installation. The ResourcesProvider assembly also defines the StringResource class which represents one string and all its translations.

To install a ResourcesProvider simply copy the assembly to the ResourceProviders subfolder of the Babylon.NET installation folder along with all assemblies and configuration files needed.

If you need help developing a ResourcesProvider please don't hesitate to contact us at support@redpin.eu. Too busy to write your own ResourcesProvider? Let us write it for you. Just drop us a few lines with what you need and we will send you a quote.

If you think your ResourcesProvider could be of interest to other developers and are willing to share it (source code must be shared as well) please writes us. If we like your ResourcesProvider and include it in Babylon.NET, we will reward you with a free single user license for Babylon.NET.

Source code available on Github.