Difference between revisions of "LRM Properties Support"
(→Example of Project Definition File) |
(→Example of Project Definition File) |
||
Line 59: | Line 59: | ||
<group-name>acme</group-name> |
<group-name>acme</group-name> |
||
<project-name>DemoJava</project-name> |
<project-name>DemoJava</project-name> |
||
− | <project-desc>This is a sample LRM Project definition file, configured |
+ | <project-desc>This is a sample LRM Project definition file, configured to support Java properties files</project-desc> |
− | o support Java properties files</project-desc> |
||
<!-- Example, linux --> |
<!-- Example, linux --> |
||
<!--<top-level-dir>/var/lib/job/workspace/acme/source</top-level-dir>--> |
<!--<top-level-dir>/var/lib/job/workspace/acme/source</top-level-dir>--> |
||
− | |||
<!-- Example, windows --> |
<!-- Example, windows --> |
||
<top-level-dir>C:\acme\source</top-level-dir> |
<top-level-dir>C:\acme\source</top-level-dir> |
||
<detect-errors> |
<detect-errors> |
||
− | <!-- if set to '0' (false), then the 'missed translation' error will |
+ | <!-- if set to '0' (false), then the 'missed translation' error will not be triggered |
− | not be triggered |
||
if the non-base file has the same text as the base file. |
if the non-base file has the same text as the base file. |
||
+ | Missed Translation error will still occur if the base file has a different key or if |
||
− | |||
− | Missed Translation error will still occur if the base fi |
||
− | le has a different key or if |
||
the base file has changed since it was last prepped. --> |
the base file has changed since it was last prepped. --> |
||
− | |||
<missed-trans-error>0</missed-trans-error> |
<missed-trans-error>0</missed-trans-error> |
||
<parameter-mismatch-error>1</parameter-mismatch-error> |
<parameter-mismatch-error>1</parameter-mismatch-error> |
||
</detect-errors> |
</detect-errors> |
||
− | <!--If you wish to create Track Back resource files, enter the Track Back |
+ | <!--If you wish to create Track Back resource files, enter the Track Back locale such as `br`--> |
+ | <!--The track back locale is mutually exclusive of the base (default) locale, target locales and pseudo-locale--> |
||
− | cale such as `br`--> |
||
− | <!--The track back locale is mutually exclusive of the base (default) locale |
||
− | , target locales and pseudo-locale--> |
||
<track-back-locale>br</track-back-locale> |
<track-back-locale>br</track-back-locale> |
||
<!--If you wish to pseudo-localized your files enter a pseudo-locale--> |
<!--If you wish to pseudo-localized your files enter a pseudo-locale--> |
||
− | <!--The pseudo-locale is mutually exclusive of the base (default) locale and |
+ | <!--The pseudo-locale is mutually exclusive of the base (default) locale and target locales--> |
− | target locales--> |
||
<pseudo-locale>eo</pseudo-locale> |
<pseudo-locale>eo</pseudo-locale> |
||
− | <!--Target locales are the locales where the corresponding resource |
+ | <!--Target locales are the locales where the corresponding resource files will be translated. --> |
− | s will be translated. --> |
||
<!--These target locales are mutually exclusive of the default locale--> |
<!--These target locales are mutually exclusive of the default locale--> |
||
+ | <target-locales> <!-- set which locales are targeted for translation. --> |
||
− | |||
− | <target-locales> <!-- set which locales are targeted for translation. -- |
||
− | > |
||
<locale>fr_FR</locale> <!-- French for France --> |
<locale>fr_FR</locale> <!-- French for France --> |
||
<locale>fr_CA</locale> <!-- French Canadian --> |
<locale>fr_CA</locale> <!-- French Canadian --> |
||
<locale>es_MX</locale> |
<locale>es_MX</locale> |
||
</target-locales> |
</target-locales> |
||
− | <!--Default locale is the base locale. This is the locale where |
+ | <!--Default locale is the base locale. This is the locale where corresponding resource files will not be translated.--> |
− | nding resource files will not be translated.--> |
||
<!--The default locale is mutually exclusive of the target locales--> |
<!--The default locale is mutually exclusive of the target locales--> |
||
− | <default-locale>en_US</default-locale> <!-- delineates which locale to |
+ | <default-locale>en_US</default-locale> <!-- delineates which locale to translate from --> |
− | ranslate from --> |
||
<resources-extensions> |
<resources-extensions> |
||
<!-- although only 1 resource extension is present in this file, |
<!-- although only 1 resource extension is present in this file, |
||
kits support multiple resource extensions. This necessitates both a |
kits support multiple resource extensions. This necessitates both a |
||
"<resource-extensions>" and "<resource-extension>" tag --> |
"<resource-extensions>" and "<resource-extension>" tag --> |
||
− | <!--The file-name-pattern and/or file-location-pattern indicate the |
+ | <!--The file-name-pattern and/or file-location-pattern indicate the pattern of the--> |
+ | <!--localized file names (file-name-pattern) and the localized folder names (file-location-pattern).--> |
||
− | ern of the--> |
||
− | <!-- |
+ | <!--If the names contain the locale then a pattern of 1,c and v will be used.--> |
− | (file-location-pattern).--> |
||
− | <!--If the names contain the locale then a pattern of 1,c and v will be used |
||
− | .--> |
||
<!--If the names contain the Locale ID then LCID will be used.--> |
<!--If the names contain the Locale ID then LCID will be used.--> |
||
<!--Example pattern using locale--> |
<!--Example pattern using locale--> |
||
− | <!-- If your localized resource files use their locale in their names then |
+ | <!-- If your localized resource files use their locale in their names then the locale pattern will--> |
+ | <!-- be used where l stands for language; c for country; v for variant; and the characters between--> |
||
− | the locale pattern will--> |
||
− | <!-- be used where l stands for language; c for country; v for variant; and |
||
− | the characters between--> |
||
<!-- are used as the separator characters.--> |
<!-- are used as the separator characters.--> |
||
<!-- <file-name-pattern>*_l_c_v</file-name-pattern>--> |
<!-- <file-name-pattern>*_l_c_v</file-name-pattern>--> |
||
<!--Example pattern using LCID (locale ID)--> |
<!--Example pattern using LCID (locale ID)--> |
||
− | <!-- If your resource files are under a folder named 'resources' with an |
+ | <!-- If your resource files are under a folder named 'resources' with an LCID suffix separated by an--> |
− | ID suffix separated by an--> |
||
<!-- underscore, then the pattern would be:--> |
<!-- underscore, then the pattern would be:--> |
||
<!-- <file-location-pattern>resources_LCID</file-location-pattern>--> |
<!-- <file-location-pattern>resources_LCID</file-location-pattern>--> |
||
Line 129: | Line 109: | ||
<file-name-pattern>*_l_c_v</file-name-pattern> |
<file-name-pattern>*_l_c_v</file-name-pattern> |
||
<!-- the tag below, when set to 1, will cause LRM to expect |
<!-- the tag below, when set to 1, will cause LRM to expect |
||
− | the locale to be specified within the filename of res. |
+ | the locale to be specified within the filename of res.properties files --> |
+ | <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale> |
||
− | operties files --> |
||
− | <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale> |
||
− | |||
<file-location-pattern></file-location-pattern> |
<file-location-pattern></file-location-pattern> |
||
<!-- There is no file location pattern --> |
<!-- There is no file location pattern --> |
||
− | <use-location-pattern-on-dflt-locale>0</use-location-pattern-on-dflt- |
+ | <use-location-pattern-on-dflt-locale>0</use-location-pattern-on-dflt-locale> |
− | cale> |
||
<base-file-encoding>UTF-8</base-file-encoding> |
<base-file-encoding>UTF-8</base-file-encoding> |
||
<localized-file-encoding>UTF-8</localized-file-encoding> |
<localized-file-encoding>UTF-8</localized-file-encoding> |
||
<!--Default pattern for properties is '![CDATA[\{\d+\}|%[ds]]]'--> |
<!--Default pattern for properties is '![CDATA[\{\d+\}|%[ds]]]'--> |
||
− | <parameter-regex-pattern><![CDATA[\{\w+\}|%[ds]]]></parameter-regex- |
+ | <parameter-regex-pattern><![CDATA[\{\w+\}|%[ds]]]></parameter-regex-pattern> |
− | tern> |
||
</resource-extension> |
</resource-extension> |
||
</resources-extensions> |
</resources-extensions> |
||
<dirset> |
<dirset> |
||
− | <!--Define the search patterns to include and/or exclude. (Uses Apache |
+ | <!--Define the search patterns to include and/or exclude. (Uses Apache Ant pattern search).--> |
− | t pattern search).--> |
||
<!--Examples: --> |
<!--Examples: --> |
||
− | <!-- A. '**/*.properties' matches all .properties files/dirs in a |
+ | <!-- A. '**/*.properties' matches all .properties files/dirs in a directory tree.--> |
+ | <!-- B. 'test/a??.resx' matches all files/dirs which start with an 'a', --> |
||
− | tory tree.--> |
||
− | <!-- |
+ | <!-- then two more characters and then '.resx', in a directory called test.--> |
− | --> |
||
− | <!-- then two more characters and then '.resx', in a directory call |
||
− | ed test.--> |
||
<!-- C. '**' matches everything in a directory tree. --> |
<!-- C. '**' matches everything in a directory tree. --> |
||
− | <!-- '**/source/**/XYZ*' matches all files/dirs which start with ' |
+ | <!-- '**/source/**/XYZ*' matches all files/dirs which start with 'XYZ'--> |
+ | <!-- and where there is a parent directory called source (e.g. 'abc/source/def/ghi/XYZ123'). --> |
||
− | YZ'--> |
||
− | <!-- and where there is a parent directory called source (e.g. 'abc |
||
− | /source/def/ghi/XYZ123'). --> |
||
<includes> |
<includes> |
||
<!--Directories to include in the search for base resource files --> |
<!--Directories to include in the search for base resource files --> |
||
Line 177: | Line 147: | ||
<exclude-dir-file>**/acceptance-test.properties</exclude-dir-file> |
<exclude-dir-file>**/acceptance-test.properties</exclude-dir-file> |
||
<exclude-dir-file>**/adminClient.properties</exclude-dir-file> |
<exclude-dir-file>**/adminClient.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/api-acceptance-service-accounts.properties</exclude |
+ | <exclude-dir-file>**/api-acceptance-service-accounts.properties</exclude-dir-file> |
− | -dir-file> |
||
<exclude-dir-file>**/api-acceptance-users.properties</exclude-dir-file> |
<exclude-dir-file>**/api-acceptance-users.properties</exclude-dir-file> |
||
<exclude-dir-file>**/api-production-users.properties</exclude-dir-file> |
<exclude-dir-file>**/api-production-users.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/api-reference-users.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/api-staging-users.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/application.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/catalina.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/component.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/config.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/features.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/grinder.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/integration.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/logging.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/media-type-mappings.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/quartz.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/remus.lasic.properties</exclude-dir-file> |
||
− | <exclude-dir-file>**/template.lasic.properties</exclude-dir-file> |
||
− | |||
</excludes> |
</excludes> |
||
</dirset> |
</dirset> |
Revision as of 16:20, 2 February 2017
Contents
How to setup LRM for .properties
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. For more information, please refer to : http://en.wikipedia.org/wiki/.properties
Naming Conventions
For optimum use of LRM, we strongly recommend that base files be named uniquely. If you have two files for instance, do not name them both resources.properties
. Name them something different, like resources.properties
and messages.properties
Properties files are used by applications written in many programming languages, such as Java. Java for instance has a full fledged standard infrastructure to handle resources (strings mostly) from properties files. Typically, an application will have many .properties
base files located under different directories. The base file typically does not have a locale suffix as it serves as the default locale when resources are missing in another locale.
See https://docs.oracle.com/javase/tutorial/essential/environment/properties.html .
For a base file named resources.properties
, the corresponding French file will be in the same directory and the locale will be added to the file name: resources_fr.properties
.
For example, for a few locales, the directory structure and file names would be:
messages.properties messages_de.properties messages_es.properties messages_fr.properties messages_ru.properties messages_zh.properties
The bold file is the base file (U.S. English in this instance) translated into German, Spanish, French, Russian, and Chinese.
Example of .properties
byTheFollowingAdministrator= by the following administrator: {0} artifactChangeNotification.Ownership=the request for notification of any change to a {0} you own. firstLastName={0} {1} user.confirm.delete=Are you sure you want to delete {0}?\\n\\nTHERE IS NO UNDO for deleting Users. user.editor.save.error=<strong>The User could not be saved.</strong><br/>\ Please correct the errors identified below and click one of the "Save" buttons.<br/> # # bind and validation errors # User.invalidValueError.name=User Name must be a valid email address.
Note:
- \ at the end of a string means the following line is part of that string, as in
user.editor.save.error=<strong>The User could not be saved.</strong><br/>\ Please correct the errors identified below and click one of the "Save" buttons.<br/>
- Parameters are typically numbers in braces, as in
firstLastName={0} {1}
- Comments are specified with a # sign at the beginning of the line
# bind and validation errors
Example of Project Definition File
<?xml version="1.0" encoding="UTF-8"?> <lrmconf> <model-version>2.0.11</model-version> <group-name>acme</group-name> <project-name>DemoJava</project-name> <project-desc>This is a sample LRM Project definition file, configured to support Java properties files</project-desc> <top-level-dir>C:\acme\source</top-level-dir> <detect-errors> <missed-trans-error>0</missed-trans-error> <parameter-mismatch-error>1</parameter-mismatch-error> </detect-errors> <track-back-locale>br</track-back-locale> <pseudo-locale>eo</pseudo-locale> <target-locales> <locale>fr_FR</locale> <locale>fr_CA</locale> <locale>es_MX</locale> </target-locales> <default-locale>en_US</default-locale> <resources-extensions> <resource-extension> <extension>properties</extension> <file-name-pattern>*_l_c_v</file-name-pattern> <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale> <file-location-pattern></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[\{\w+\}|%[ds]]]></parameter-regex-pattern> </resource-extension> </resources-extensions> <dirset> <includes> </includes> <excludes> <exclude-dir-file>**/src/test/**</exclude-dir-file> <exclude-dir-file>**/bin/**</exclude-dir-file> <exclude-dir-file>**/target/**</exclude-dir-file> <exclude-dir-file>**/.sonar-ide.properties</exclude-dir-file> <exclude-dir-file>**/sonar-project.properties</exclude-dir-file> <exclude-dir-file>**/test.properties</exclude-dir-file> <exclude-dir-file>**/acceptance-test.properties</exclude-dir-file> <exclude-dir-file>**/adminClient.properties</exclude-dir-file> <exclude-dir-file>**/api-acceptance-service-accounts.properties</exclude-dir-file> <exclude-dir-file>**/api-acceptance-users.properties</exclude-dir-file> <exclude-dir-file>**/api-production-users.properties</exclude-dir-file> </excludes> </dirset> </lrmconf>