Importing from existing resource files

From Lime 49 Wiki
Jump to: navigation, search

ResourceBlender can import translations from existing .properties, .resx or .po files. Click Resources->Import from ResourceBlender Express or Import from the navigation menu in ResourceBlender.NET to get started.

Files to import can be specified individually or as a group. If the selection contains zip files, they will be automatically extracted before import. The only requirement before importing is that an application has been added into which the bundles can be imported. Depending on the format of the resources being imported, the filename of the file (or each file if uploading a zip archive) will be used to determine the name of the bundle and language of the resources contained within it.

Note: All available languages from the uploaded files will be imported, but only languages which have been included with an application will be visible when editing translations or generating resources.

If Add languages not currently used by the application is checked, languages which are present in the files being imported but not in the application into which you're importing will be added so they do not need to be added from the Edit Application window.

Contents

Importing from .properties

Files are imported using the filename as the source for both the bundle name and the language. ResourceBlender expects files named BundleName_language-code.properties and each element in the file to be represented as ElementName=Translation.

For example: If a zip file containing mybundle_en.properties and mybundle_de.properties is uploaded, ResourceBlender will first add a bundle called mybundle to the application if it does not already exist.

Elements will then be loaded from the files and resources will be created from the translations in each file that was uploaded. If an element does not exist, it will be created. Otherwise, ResourceBlender will try to find an existing resource by searching for an exact match for the translation in the file's language, then use the translation in the file to update the existing resource.

Scenario

For example: A file called anotherbundle_de.properties containing the following lines is imported into an application.

startapplication=Program starten

quitapp=Program schliessen

The German language (language code=de) and a bundle called anotherbundle have already been added to the application. There is an element called startapplication, but the resource used has no German translation and there is no element called exitapplication.

Result

Java files are read line by line with an equals (=) separating the element name and translation, so ResourceBlender starts with the element called startapplication. This elemnt's resource had no German translation, so one is added. If there had already been a German translation, it would be replaced by the one in the file.

The next element is quitapp. The element does not exist, so a new element is created and the German translation in the file (Program schliessen) is added to create a new resource.

If German had not been added as a language for the application, the translations would still have been added to the database, but they would not be visible when editing translations or generating resources.

Importing from .resx files

The filename is used as the source for both the bundle name and language of the resources in the file. ResourceBlender expects files named BundleName.language-code.resx and the file itself to conform the .resx format specification. Ie: There must be a <root> node, and each element must be contained within the following format:.

<data name="ElementName">

<value>Translation</value>

</data>

The import process is the same as with .properties (see the scenario above), but the format of the file is different.

If Treat files whose filename contains no culture as the default language is checked, files with no language code before the extension (eg: BundleName.resx instead of BundleName.en-GB.resx) will be treated as the default language for the application into which you are importing.

Importing from .po files

The names of the PO files inside the zip are used to determine the bundle names and languages of the resources they contain. If uploading individually, a random bundle name will be generated. To upload to a specific bundle, create a folder for that bundle inside the archive. ResourceBlender expects an archived structured as whatever.zip/BundleName/language-code.po and the file itself to conform the .po format specification.

For more information about the structure of .po files, see GNU PO Format.


Filtering By Element Name

When importing .resx or .properties files, if a filter is entered, only elements containing it will be imported. This can be usefl when importing generated .resx files as they often contain meta-data such as positioning information.

Note: Elements can only be filtered when importing from .resx or .properties.

Personal tools