Difference between revisions of "LRM resx Support"

From Lingoport Wiki
Jump to: navigation, search
(Example of Supported .resx Files)
(Example of .resx Files)
Line 48: Line 48:
 
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
 
</resheader>
 
</resheader>
'''<data name="CARO_CAROPTI_100" xml:space="preserve"><value>Car Option</value></data>
+
'''<data name="CARO_CAROPTI_100" xml:space="preserve"><value>Car Option</value></data>'''
<data name="COMM_THISSHO_1" xml:space="preserve"><value>this should be detected</value></data>'''
+
'''<data name="COMM_THISSHO_1" xml:space="preserve"><value>this should be detected</value></data>'''
 
</root>
 
</root>
   

Revision as of 15:42, 23 September 2016

The .Net framework provides for a LRM supports .resx files. See https://msdn.microsoft.com/en-us/library/ekyft91f(v=vs.100).aspx .

Locale File Extensions

  • The resx files follow this naming convention: filename.<language>.resx or filename.<language>-<country>.resx. For example, resources.resx or resources.en.resx for a base file, resources.fr.resx or resources.fr-FR.resx, etc.
  • If you can, avoid duplicate file names. Duplications incur more prep kits than necessary.

Example of .resx Files

 <?xml version="1.0" encoding="UTF-8"?>
 <root>
   <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
       <xsd:element msdata:IsDataSet="true" name="root">
           <xsd:complexType>
               <xsd:choice maxOccurs="unbounded">
                   <xsd:element name="data">
                       <xsd:complexType>
                           <xsd:sequence>
                               <xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string" />
                               <xsd:element minOccurs="0" msdata:Ordinal="2" name="comment" type="xsd:string" />
                           </xsd:sequence>
                           <xsd:attribute msdata:Ordinal="1" name="name" type="xsd:string" />
                           <xsd:attribute msdata:Ordinal="3" name="type" type="xsd:string" />
                           <xsd:attribute msdata:Ordinal="4" name="mimetype" type="xsd:string" />
                       </xsd:complexType>
                   </xsd:element>
                   <xsd:element name="resheader">
                       <xsd:complexType>
                           <xsd:sequence>
                               <xsd:element minOccurs="0" msdata:Ordinal="1" name="value" type="xsd:string" />
                           </xsd:sequence>
                           <xsd:attribute name="name" type="xsd:string" use="required" />
                       </xsd:complexType>
                   </xsd:element>
               </xsd:choice>
           </xsd:complexType>
       </xsd:element>
   </xsd:schema>
   <resheader name="resmimetype">
       <value>text/microsoft-resx</value>
   </resheader>
   <resheader name="version">
       <value>1.3</value>
   </resheader>
   <resheader name="reader">
       <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
       <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <value>Car Option</value>
   <value>this should be detected</value>
 </root>

Simple is Best

A file with one key value per line, with some possible semantics in the key, is the preferred way to have .json resource bundles. There is no structure (no objects) to the file, so changing keys, moving them around, does not affect whatever outstanding translation will be returned at a later date with a different structure.

resources_en.json
{
 "site_heading": "Where can I find more information on the site?",
 "site_subHeading2": "Search",
 "enableGeo": "Enable location services in your browser to load local help results.",
 "findButton": "Find",
 "gettingStarted_title": "Getting Started",
 "gettingStarted_subHeading": "Here are the main things you need to know as you
get started.",
 "logging_off_account": "Log off"
}

If you want complexity

Caveat JSON structure changes can lead to problems with project on-boarded for file deltas (v. Full Files).

In what format should JSON Files be for LRM Handling ?

Arrays are not allowed in the context of JSON files as resource bundles

String references in the code, from an i18n point of view, is unmanageable for JSON arrays. In addition, many L10n vendors do not support JSON arrays. (Sample JSON files are located in	LRM-Server-2.1/samples/JSON_Examples):

There is only one key/value per line

  • Valid
 "key1":"This is my value for key1",
 "key2":"This is my value for key2"
  • Invalid
 "key1":"This is my value for key1","key2":"This is my value for key2"

End-object character (curly bracket) may not exist on the same line as a key/value

  • Valid
 "keys": {
  "key1":"This is my value for key1"
 }
  • Invalid
 "keys": {
     "key1":"This is my value for key1"}

Values associated with a key must be a string

Numeric and boolean values are not allowed
  • Valid
 "key1":"0"
  • Invalid
 "key1":0
 "key1": true

Sample LRM Project Definition File for .json

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<lrmconf>
 <model-version>3.0.18</model-version>
 <project-name>search</project-name>
 <project-desc>Search project</project-desc>
 <group-name>Lingoport</group-name>
 <top-level-dir>/var/lib/jenkins/jobs/Lingoport.search/workspace</top-level-dir>
 <detect-errors>
   <missed-trans-error>0</missed-trans-error>
   <parameter-mismatch-error>1</parameter-mismatch-error>
 <track-back-locale>br</track-back-locale>
 <target-locales>
   <locale>es</locale>
   <locale>fr</locale>
   <locale>ja</locale>
 </target-locales>
 <default-locale>en</default-locale>
 <resource-extensions>
   <resource-extension>
     <extension>json</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[\{\w+\}|%[ds]]]></parameter-regex-pattern>
   </resource-extension>
 </resource-extensions>
 <dirset>
   <includes>
     <include-dir>**/**</include-dir>
   </includes>
   <excludes>
     <exclude-dir-file/>
     <exclude-dir-file>**/*_eo.json</exclude-dir-file>
     <exclude-dir-file>**/*_eo__*.json</exclude-dir-file>
     <exclude-dir-file>**/*_br.json</exclude-dir-file>
     <exclude-dir-file>**/LRMScans/**</exclude-dir-file>
     <exclude-dir-file>**/GlobalyzerScans/**</exclude-dir-file>
     <exclude-dir-file>**/sonar-project.properties</exclude-dir-file>
   </excludes>
 </dirset>
 </lrmconf>