Difference between revisions of "Supported Resource Bundles"

From Lingoport Wiki
Jump to: navigation, search
(Resource Extensions)
 
(110 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
== What resource file types are supported by Localyzer?==
== .properties ==
 
  +
=== Standard Localyzer extensions ===
The encoding of a .properties file is ISO-8859-1, also known as Latin-1. All non-Latin-1 characters must be entered by using Unicode escape characters, e. g. \uHHHH where HHHH is a hexadecimal index of the character in the Unicode character set. This allows for using .properties files as resource bundles for localization. A non-Latin-1 text file can be converted to a correct .properties file by using the native2ascii tool that is shipped with the JDK or by using a tool, such as po2prop, that manages the transformation from a bilingual localization format into .properties escaping.
 
  +
<ul>
For more information, please refer to : http://en.wikipedia.org/wiki/.properties
 
  +
<li><b>[[LRM html Support | .htm and .html]]</b> files using the [[LRM_html_Support#html_parser_type | ''html'']] parser</li>
=== Resource Manager Configuration ===
 
  +
<li><b>[[LRM JSON Support | .json]]</b> (Mostly JavaScript, and other programming languages) using the [[LRM_JSON_Support#json_parser_type | ''json'']] parser</li>
Typical .xml definition for projects with .properties files.
 
  +
<li><b>[[LRM msg Support|.msg]]</b> (C, C++, ...) using the [[LRM_msg_Support#msg_parser_type|''msg'']] parser</li>
  +
<li><b>[[LRM po Support|.po]]</b> files using the [[LRM_po_Support#po_parser_type|''po'']] parser</li>
  +
<li> <b>[[ LRM Properties Support| .properties]]</b> files (Java-type resources) using [[LRM_Properties_Support#properties_parser_type|''properties'']] parser</li>
  +
<li><b>[[ LRM resx Support| .resx]]</b> files (used in the .Net world) using [[LRM_resx_Support#xml_parser_type_using_ResxParser.xml_format_definition|''xml'']] parser and the ResxParser.xml format definition</li>
  +
<li><b>[[LRM rc Support|.rc]]</b> (Delphi, ...) using the [[LRM_rc_Support#rc_parser_type|''rc'']] parser</li>
  +
<li><b>[[LRM rjs Support|.rjs]]</b> (for JavaScript) using the [[LRM_rjs_Support#js_parser_type|''js'']] parser</li>
  +
<li> <b>[[LRM rxml Support|.rxml]]</b> using the [[LRM_rxml_Support#xml_parser_type_using_RxmlParser.xml_format_definition|''xml'']] parser and the RxmlParser.xml format definition)</li>
  +
<li><b>[[LRM strings Support|.strings]]</b> (Mobile iOS) using the [[LRM_strings_Support#strings_parser_type|''strings'']] parser</li>
  +
<li><b>[[LRM Android Support | strings.xml]]</b> (Android) using the [[LRM_Android_Support#xml_parser_type_using_AndroidParser.xml_format_definition|''xml'']] parser and the AndroidParser.xml format definition</li>
  +
<li><b>[[LRM text Support | .txt]]</b> files using the [[LRM_text_Support|''text'']] parser</li>
  +
<li><b>[[LRM yaml Support | .yaml, .yml]]</b> using the [[LRM_yaml_Support#Yaml_Parser|''yaml'']] parser</li>
  +
<li><b>[[LRM xhtml Support | .dita, .ditamap]]</b> using the [[LRM xhtml Support|''xhtml'']] parser and the [[Subfolder under locale folder|''Subfolder under locale folder'']] settings</li>
  +
</ul>
   
  +
=== Unique Extensions ===
<pre?
 
  +
Any file extension can be handled by Localyzer as long as the corresponding parser type is defined. The file must be able to be parsed correctly by the defined parser type or an error will occur. The parser types are:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
<lrmconf>
+
<ul>
  +
<li><b>[[LRM_Binary_Support| ''binary'']]</b> parser</li>
<model-version>2.0.12</model-version>
 
  +
<li><b>[[LRM_html_Support#html_parser_type | ''html'']]</b> parser</li>
<project-name>com.company.project</project-name>
 
  +
<li><b>[[LRM_rjs_Support#js_parser_type|''js'']]</b> parser</li>
<project-desc>This is a sample LRM Project definition file, configured to support Java properties files</project-desc>
 
  +
<li><b>[[LRM_JSON_Support#json_parser_type | ''json'']]</b> parser </li>
<!--group-name contains either the company name or the group name-->
 
  +
<li><b>[[LRM_msg_Support#msg_parser_type|''msg'']]</b> parser</li>
<group-name>SVNFTP</group-name>
 
  +
<li><b>[[LRM_po_Support#po_parser_type|''po'']]</b> parser</li>
<top-level-dir>/var/lib/jenkins/jobs/SVNFTP.com.company.project/workspace</top-level-dir>
 
  +
<li><b>[[LRM_Properties_Support#properties_parser_type|''properties'']]</b> parser</li>
<detect-errors>
 
  +
<li><b>[[LRM_rc_Support#rc_parser_type|''rc'']]</b> parser</li>
<!--If set to '0' (false), then the 'missed translation' error will not be triggered-->
 
  +
<li><b>[[LRM_strings_Support#strings_parser_type|''strings'']]</b> parser</li>
<missed-trans-error>0</missed-trans-error>
 
  +
<li><b>[[LRM_text_Support|''text'']]</b> parser</li>
<parameter-mismatch-error>1</parameter-mismatch-error>
 
  +
<li><b>[[LRM_XML_Support|xml]]</b> parser</li>
</detect-errors>
 
  +
<li><b>[[LRM_yaml_Support|yaml]]</b> parser</li>
<pseudo-locale>eo</pseudo-locale>
 
  +
</ul>
<target-locales>
 
  +
<locale>fr</locale>
 
  +
== Localyzer Configuration ==
<locale>de_DE</locale>
 
  +
Localyzer creates projects using a [[Terms_and_Definitions#projectdefn|Project Definition XML]] file that contains information about the resources and types for translation and then calling the [[LRM_Commands_Reference#Project_Commands| Create Project Command]]. Here is a typical .xml definition for projects with .properties files.
<locale>slv</locale>
 
  +
<locale>nob_NO_UNI</locale>
 
  +
Note-a project should be created using '''either''' the project definition file directly or through the Jenkins LRM Plugin.
<locale>zh_Hant</locale>
 
  +
<locale>ZHT_Hans</locale>
 
  +
=== Project Info ===
</target-locales>
 
  +
Project information includes the following:
<resource-extension>
 
  +
* Project Name - the repository name. This '''cannot be changed''' once the project is created.
<extension>properties</extension>
 
  +
* Project desc - description, if any, for the project
<file-name-pattern>*_l_c_v</file-name-pattern>
 
  +
* Group Name - the owner of the repository. This '''cannot be changed''' once the project is created.
<!--If the base resource files use the file-name-pattern in their name -->
 
  +
* Top Level Directory - The top level directory is an absolute path. Usually it is something like '''<code>/var/lib/jenkins/jobs/Acme.wiley/workspace</code>'''. There are times where there is 1 repository for multiple projects. In this case the top level directory may be '''<code>/var/lib/jenkins/jobs/Acme.wiley/workspace/wileyProject1</code>'''. This value '''cannot be changed''' once the project is created.
<!--then set use-pattern-on-dflt-locale to 1, if not then set to 0-->
 
  +
<use-pattern-on-dflt-locale>1</use-pattern-on-dflt-locale>
 
  +
==== ProjectDefinition.xml example ====
<file-location-pattern/>
 
  +
This example is the project info for the ''wiley'' repository under the ''Acme'' group. (Under git, ''Acme'' would be the owner of the ''wiley'' repo)
<use-location-pattern-on-dflt-locale>0</use-location-pattern-on-dflt-locale>
 
  +
&lt;project-name&gt;wiley&lt;/project-name&gt;
<base-file-encoding>UTF-8</base-file-encoding>
 
  +
&lt;project-desc&gt;Wiley Project&lt;/project-desc&gt;
<localized-file-encoding>UTF-8</localized-file-encoding>
 
  +
&lt;group-name&gt;Acme&lt;/group-name&gt;
<!--Default pattern for properties is '![CDATA[\{\d+\}|%[ds]]]'-->
 
  +
&lt;top-level-dir&gt;/var/lib/jenkins/jobs/Acme.wiley/workspace&lt;/top-level-dir&gt;
<parameter-regex-pattern><![CDATA[\{\w+\}|%[ds]]]></parameter-regex-pattern>
 
  +
</resource-extension>
 
  +
=== Detect Errors Flags ===
</resource-extensions>
 
  +
These flags direct Localyzer on the types of errors to detect.
</lrmconf>
 
  +
* Missed Translations - If set to ''1'', then a ''Missed Translation'' error will occur if the base resource file text is the same as the translated file text. Usually this flag is set to '''0'''.
</pre>
 
  +
* Parameter Mismatch Error - If set to ''1'' then a ''Parameter Mismatch'' error will occur if the parameters in the translated file do not match the base resource file parameters.
  +
  +
==== ProjectDefinition.xml example ====
  +
A project setup with the following detect error flags will not detect missed translations but will detect parameter mismatch errors.
  +
  +
&lt;detect-errors&gt;
  +
&lt;missed-trans-error&gt;0&lt;/missed-trans-error&gt;
  +
&lt;parameter-mismatch-error&gt;1&lt;/parameter-mismatch-error&gt;
  +
&lt;detect-errors&gt;
  +
  +
=== Locales ===
  +
  +
There are 3 types of java locales, that can be defined in a project:
  +
* Pseudo Locale - The locale for the project's pseudo-locale files.
  +
* Target locales - Must be exclusive of the project's base and pseudo-locales.
  +
* Base Locale - The locale of the project's base resource file.
  +
  +
==== ProjectDefinition.xml example ====
  +
The following defines ''eo'' as the pseudo-locale, ''en'' as the base locale and ''fr_FR'', ''de_DE'' (case sensitive) as the target locales. The locales defined are in the format of a java locale (using underscores) and may not reflect the name of the resource files. The file name patterns are defined [[Supported_Resource_Bundles#Resource_Extensions|here]].
  +
  +
&lt;pseudo-locale&gt;eo&lt;/pseudo-locale&gt;
  +
&lt;target-locales&gt;
  +
&lt;locale&gt;fr_FR&lt;/locale&gt;
  +
&lt;locale&gt;de_DE&lt;/locale&gt;
  +
&lt;/target-locales&gt;
  +
&lt;default-locale&gt;en&lt;/default-locale&gt;
  +
  +
=== Resource Extensions ===
  +
A Localyzer project can have multiple extensions defined. The information need per extension is:
  +
* '''extension''' - this can be one of the [[Supported_Resource_Bundles#Standard_LRM_extensions|Localyzer standard extensions]] or a [[Supported_Resource_Bundles#Unique_Extensions|unique extension]].
  +
* '''parser-type''' - A parser-type is required for unique extension.
  +
* '''file name pattern''' - if applicable, this is the pattern for the name of project's resource files. For example, the translated file names ''file1_zh-Hans_HK.rc'', ''file1_fr.rc'' and ''file1_de-de.rc'' would have the pattern ''*_l-c_v''. Where ''l'' is the language, ''c'' is the country/script and ''v'' is the variant/region.
  +
* '''use name pattern on default locale flag'''- If the base resource files use the file-name-pattern in their name then this flag is ''1'' otherwise ''0''. For example, the base resource file ''file1.rc'' does not have a pattern so the flag would be ''0''.
  +
* '''file location pattern''' - if applicable, this is the pattern for the folders containing the resource files. These folder can be of 2 types:
  +
** Language pattern - For example, ''*-l_c_v'' where the folder containing the English resource files could be ''values-en''.
  +
** Microsoft LCID code pattern - For example, ''*_LCID'' where the folder containing the English(US) (en_us) resource files could be ''values_1033''.
  +
:The location pattern may contain a wildcard for directory names. These are all valid location patterns:
  +
:* ''*-l-c-v/*/*'' - directory depth is 3
  +
:* ''*-l-c-v/some*folder'' - directory depth is 2
  +
:* ''*_LCID/*/*/locales'' - directory depth is 4
  +
:The location pattern '''can not''' contain wildcards for directory depth (**). These are '''invalid''' location patterns:
  +
:* ''*-l-c-v/**'' (INVALID)
  +
:* ''*-l-c-v/**/locales'' (INVALID)
  +
* '''use location pattern on default locale flag''' - If the folder, containing the base resource files, use the pattern then this flag is ''1'' otherwise ''0''.
  +
* '''encoding''' for the base and non-base resource files - Usually this will be UTF-8.
  +
* '''parameter-regex-pattern''' - This defines the regex pattern for parameters such as formatting and messaging.
  +
  +
==== ProjectDefinition.xml example ====
  +
The following will define the following directory structure.
  +
  +
src
  +
: resources
  +
:: ''file1_en-US.xml''
  +
:: ''file1_fr-FR.xml''
  +
:: ''file1_de-DE.xml''
  +
: values
  +
:: ''example.resx''
  +
: values-1033
  +
:: ''example.resx''
  +
: values-1036
  +
:: ''example.resx''
  +
  +
&lt;resource-extensions&gt;
  +
&lt;resource-extension&gt;
  +
&lt;extension&gt;resx&lt;/extension&gt;
  +
&lt;file-name-pattern/&gt;
  +
&lt;use-pattern-on-dflt-locale&gt;0&lt;/use-pattern-on-dflt-locale&gt;
  +
&lt;file-location-pattern&gt;*-LCID&lt;/file-location-pattern&gt;
  +
&lt;use-location-pattern-on-dflt-locale&gt;0&lt;/use-location-pattern-on-dflt-locale&gt;
  +
&lt;base-file-encoding&gt;UTF-8&lt;/base-file-encoding&gt;
  +
&lt;localized-file-encoding&gt;UTF-8&lt;/localized-file-encoding&gt;
  +
&lt;parameter-regex-pattern&gt;&lt;![CDATA[%[ds]|%\d+\$[ds]|%\{\w+\}]]&gt;&lt;/parameter-regex-pattern&gt;
  +
&lt;/resource-extension&gt;
  +
&lt;resource-extension&gt;
  +
&lt;extension&gt;xml&lt;/extension&gt;
  +
&lt;file-name-pattern&gt;*_l-c-v&lt;/file-name-pattern&gt;
  +
&lt;use-pattern-on-dflt-locale&gt;1&lt;/use-pattern-on-dflt-locale&gt;
  +
&lt;file-location-pattern/&gt;
  +
&lt;use-location-pattern-on-dflt-locale&gt;0&lt;/use-location-pattern-on-dflt-locale&gt;
  +
&lt;base-file-encoding&gt;UTF-8&lt;/base-file-encoding&gt;
  +
&lt;localized-file-encoding&gt;UTF-8&lt;/localized-file-encoding&gt;
  +
&lt;parameter-regex-pattern&gt;&lt;![CDATA[%d|%s|%\d+\$s|%\d+\$d|%\{\w+\}]]&gt;&lt;/parameter-regex-pattern&gt;
  +
&lt;/resource-extension&gt;
  +
&lt;/resource-extensions&gt;
  +
  +
=== Include/Exclude Files/Directories ===
  +
The include portion of the project definition can be used to include folder or files from the search for resource files. The default is all folders and files will be included.
  +
  +
The exclude portion of the project definition can be used to exclude folder or files from the search for resource files. The default is that no folders/files will be excluded.
  +
  +
==== ProjectDefinition.xml example ====
  +
The following definition directs the search to only those resource files with ''src'' as a top-level directory. Any resource files under a ''test'' folder will be ignored as well as the ''config.properties'' file.
  +
  +
&lt;dirset&gt;
  +
&lt;includes&gt;
  +
&lt;include-dir-file&gt;**/src/**&lt;/include-dir-file&gt;
  +
&lt;/includes&gt;
  +
&lt;excludes&gt;
  +
&lt;exclude-dir-file&gt;**/test/**&lt;/exclude-dir-file&gt;
  +
&lt;exclude-dir-file&gt;**/config.properties&lt;/exclude-dir-file&gt;
  +
&lt;/excludes&gt;
  +
&lt;/dirset&gt;

Latest revision as of 19:53, 9 July 2021

What resource file types are supported by Localyzer?

Standard Localyzer extensions

Unique Extensions

Any file extension can be handled by Localyzer as long as the corresponding parser type is defined. The file must be able to be parsed correctly by the defined parser type or an error will occur. The parser types are:

Localyzer Configuration

Localyzer creates projects using a Project Definition XML file that contains information about the resources and types for translation and then calling the Create Project Command. Here is a typical .xml definition for projects with .properties files.

Note-a project should be created using either the project definition file directly or through the Jenkins LRM Plugin.

Project Info

Project information includes the following:

  • Project Name - the repository name. This cannot be changed once the project is created.
  • Project desc - description, if any, for the project
  • Group Name - the owner of the repository. This cannot be changed once the project is created.
  • Top Level Directory - The top level directory is an absolute path. Usually it is something like /var/lib/jenkins/jobs/Acme.wiley/workspace. There are times where there is 1 repository for multiple projects. In this case the top level directory may be /var/lib/jenkins/jobs/Acme.wiley/workspace/wileyProject1. This value cannot be changed once the project is created.

ProjectDefinition.xml example

This example is the project info for the wiley repository under the Acme group. (Under git, Acme would be the owner of the wiley repo)

<project-name>wiley</project-name>
<project-desc>Wiley Project</project-desc>
<group-name>Acme</group-name>
<top-level-dir>/var/lib/jenkins/jobs/Acme.wiley/workspace</top-level-dir>

Detect Errors Flags

These flags direct Localyzer on the types of errors to detect.

  • Missed Translations - If set to 1, then a Missed Translation error will occur if the base resource file text is the same as the translated file text. Usually this flag is set to 0.
  • Parameter Mismatch Error - If set to 1 then a Parameter Mismatch error will occur if the parameters in the translated file do not match the base resource file parameters.

ProjectDefinition.xml example

A project setup with the following detect error flags will not detect missed translations but will detect parameter mismatch errors.

<detect-errors>
  <missed-trans-error>0</missed-trans-error>
  <parameter-mismatch-error>1</parameter-mismatch-error>
<detect-errors>

Locales

There are 3 types of java locales, that can be defined in a project:

  • Pseudo Locale - The locale for the project's pseudo-locale files.
  • Target locales - Must be exclusive of the project's base and pseudo-locales.
  • Base Locale - The locale of the project's base resource file.

ProjectDefinition.xml example

The following defines eo as the pseudo-locale, en as the base locale and fr_FR, de_DE (case sensitive) as the target locales. The locales defined are in the format of a java locale (using underscores) and may not reflect the name of the resource files. The file name patterns are defined here.

 <pseudo-locale>eo</pseudo-locale>
 <target-locales>
   <locale>fr_FR</locale>
   <locale>de_DE</locale>
 </target-locales>
 <default-locale>en</default-locale>

Resource Extensions

A Localyzer project can have multiple extensions defined. The information need per extension is:

  • extension - this can be one of the Localyzer standard extensions or a unique extension.
  • parser-type - A parser-type is required for unique extension.
  • file name pattern - if applicable, this is the pattern for the name of project's resource files. For example, the translated file names file1_zh-Hans_HK.rc, file1_fr.rc and file1_de-de.rc would have the pattern *_l-c_v. Where l is the language, c is the country/script and v is the variant/region.
  • use name pattern on default locale flag- If the base resource files use the file-name-pattern in their name then this flag is 1 otherwise 0. For example, the base resource file file1.rc does not have a pattern so the flag would be 0.
  • file location pattern - if applicable, this is the pattern for the folders containing the resource files. These folder can be of 2 types:
    • Language pattern - For example, *-l_c_v where the folder containing the English resource files could be values-en.
    • Microsoft LCID code pattern - For example, *_LCID where the folder containing the English(US) (en_us) resource files could be values_1033.
The location pattern may contain a wildcard for directory names. These are all valid location patterns:
  • *-l-c-v/*/* - directory depth is 3
  • *-l-c-v/some*folder - directory depth is 2
  • *_LCID/*/*/locales - directory depth is 4
The location pattern can not contain wildcards for directory depth (**). These are invalid location patterns:
  • *-l-c-v/** (INVALID)
  • *-l-c-v/**/locales (INVALID)
  • use location pattern on default locale flag - If the folder, containing the base resource files, use the pattern then this flag is 1 otherwise 0.
  • encoding for the base and non-base resource files - Usually this will be UTF-8.
  • parameter-regex-pattern - This defines the regex pattern for parameters such as formatting and messaging.

ProjectDefinition.xml example

The following will define the following directory structure.

src

resources
file1_en-US.xml
file1_fr-FR.xml
file1_de-DE.xml
values
example.resx
values-1033
example.resx
values-1036
example.resx
<resource-extensions>
   <resource-extension>
     <extension>resx</extension>
     <file-name-pattern/>
     <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale>
     <file-location-pattern>*-LCID</file-location-pattern>
     <use-location-pattern-on-dflt-locale>0</use-location-pattern-on-dflt-locale>
     <base-file-encoding>UTF-8</base-file-encoding>
     <localized-file-encoding>UTF-8</localized-file-encoding>
     <parameter-regex-pattern><![CDATA[%[ds]|%\d+\$[ds]|%\{\w+\}]]></parameter-regex-pattern>
   </resource-extension>
   <resource-extension>
     <extension>xml</extension>
     <file-name-pattern>*_l-c-v</file-name-pattern>
     <use-pattern-on-dflt-locale>1</use-pattern-on-dflt-locale>
     <file-location-pattern/>
     <use-location-pattern-on-dflt-locale>0</use-location-pattern-on-dflt-locale>
     <base-file-encoding>UTF-8</base-file-encoding>
     <localized-file-encoding>UTF-8</localized-file-encoding>
     <parameter-regex-pattern><![CDATA[%d|%s|%\d+\$s|%\d+\$d|%\{\w+\}]]></parameter-regex-pattern>
   </resource-extension>
</resource-extensions>

Include/Exclude Files/Directories

The include portion of the project definition can be used to include folder or files from the search for resource files. The default is all folders and files will be included.

The exclude portion of the project definition can be used to exclude folder or files from the search for resource files. The default is that no folders/files will be excluded.

ProjectDefinition.xml example

The following definition directs the search to only those resource files with src as a top-level directory. Any resource files under a test folder will be ignored as well as the config.properties file.

 <dirset>
   <includes>
     <include-dir-file>**/src/**</include-dir-file>
   </includes>
   <excludes>
     <exclude-dir-file>**/test/**</exclude-dir-file>
     <exclude-dir-file>**/config.properties</exclude-dir-file>
   </excludes>
 </dirset>