Difference between revisions of "LRM Android Support"

From Lingoport Wiki
Jump to: navigation, search
(Example of Project Definition File)
(Example of Project Definition for Resources)
 
(7 intermediate revisions by the same user not shown)
Line 18: Line 18:
   
 
== Example strings.xml File For Android==
 
== Example strings.xml File For Android==
  +
  +
For information on Android string resources see https://developer.android.com/guide/topics/resources/string-resource
   
 
<?xml version="1.0" encoding="utf-8"?>
 
<?xml version="1.0" encoding="utf-8"?>
Line 26: Line 28:
 
<string name="person_activity_title">Person</string>
 
<string name="person_activity_title">Person</string>
 
<string name="label_person_tree_button">View This Tree</string>
 
<string name="label_person_tree_button">View This Tree</string>
  +
<!-- Array Support -->
<string name="label_person_other">Other</string>
 
<string name="label_person_name">Name</string>
+
<string-array name="planets_array">
  +
<item>Mercury</item>
<string name="label_person_details">Details</string>
 
  +
<item>Venus</item>
<!-- Fact detail: -->
 
  +
<item>Earth</item>
<string name="fact_detail_sub_header_reason">Reason This Information Is Correct</string>
 
  +
<item>Mars</item>
<string name="fact_detail_footer_modified">Modified</string>
 
  +
</string-array>
<string name="fact_detail_send_email_chooser">Choose an Email Client</string>
 
  +
<!-- Plural Support -->
<string name="fact_detail_send_email_error_no_client">Email app not found</string>
 
<string name="fact_name_label">Name</string>
+
<plurals name="numberOfSongsAvailable">
  +
<item quantity="one">%d song found.</item>
  +
<item quantity="other">%d songs found.</item>
  +
</plurals>
 
</resources>
 
</resources>
 
== Example of Project Definition File ==
 
   
  +
== ''xml'' parser type using AndroidParser.xml format definition ==
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
 
  +
=== valid Android xml syntax ===
<lrmconf>
 
  +
Files that use the ''xml'' parser and the [[LRM_XML_Support#AndroidParser.xml_structure|AndroidParser.xml]] format definition are expected to have valid Android xml file syntax
<model-version>3.0.18</model-version>
 
  +
<project-name>mobile-android</project-name>
 
  +
=== Android .xml uses the ''xml'' parser type===
<project-desc>Lingoport mobile-android project</project-desc>
 
  +
When defining a project containing LRM Standard Android.xml resource files, there is no need to define a ''&lt;parser-type&gt;'' as the ''xml'' parser will always be used along with the AndroidParser.xml format definition.
<group-name>Lingoport</group-name>
 
  +
<top-level-dir>/var/lib/jenkins/jobs/Lingoport.mobile-android/workspace</top-level-dir>
 
  +
=== unique file extension needs to define ''xml'' parser type. Xml format definition defaults to Android ===
<detect-errors>
 
  +
If a unique file extension is a valid Android xml file, then:
<missed-trans-error>0</missed-trans-error>
 
  +
<ul>
<parameter-mismatch-error>1</parameter-mismatch-error>
 
  +
<li>In the Project definition xml file, ''&lt;parser-type&gt;'' should be ''xml'' </li>
</detect-errors>
 
  +
<li>There is no need to copy over a format definition because the default definition is for Android syntax.
<track-back-locale/>
 
  +
</ul>
<pseudo-locale/>
 
  +
<target-locales>
 
  +
== Example of Project Definition for Resources ==
<locale>de</locale>
 
  +
The following is an example of xml resource file definitions. See [[Supported_Resource_Bundles#Resource_Extensions| resource extensions]] for more information on extensions. The project defintion can also be setup [[On_Boarding_a_project_with_both_LRM_and_Globalyzer#Resource_File_types| using Jenkins]]
<locale>es</locale>
 
  +
<locale>fr</locale>
 
  +
<resource-extensions>
<locale>ja</locale>
 
<locale>zh</locale>
 
</target-locales>
 
<default-locale>en</default-locale>
 
<resource-extensions>
 
 
<resource-extension>
 
<resource-extension>
 
'''&lt;!-- parser-type not needed since .xml is a standard LRM extension that maps to the xml parser type --&gt;'''
 
'''&lt;!-- parser-type not needed since .xml is a standard LRM extension that maps to the xml parser type --&gt;'''
Line 86: Line 85:
 
</resource-extension>
 
</resource-extension>
 
</resource-extensions>
 
</resource-extensions>
<dirset>
 
<includes>
 
<include-dir-file>**/string.xml</include-dir-file>
 
<include-dir-file>**/*.myext</include-dir-file>
 
</includes>
 
<excludes>
 
<exclude-dir-file>**/source/bin/**</exclude-dir-file>
 
</excludes>
 
</dirset>
 
</lrmconf>
 

Latest revision as of 00:33, 9 March 2021

Naming Conventions

Android resources files are named strings.xml. Typically, an Android application will have one strings.xml base file located under a directory named values. The corresponding translated resource bundle will be also named strings.xml and located under a directory named values-fr (for French) at the same level as values.

For example, for a few locales, the directory structure and file names would be:

 res/values/strings.xml
 res/values-de/strings.xml
 res/values-es/strings.xml
 res/values-fr/strings.xml
 res/values-it/strings.xml
 res/values-ja/strings.xml
 res/values-ko/strings.xml
 res/values-pt/strings.xml
 res/values-ru/strings.xml
 res/values-zh/strings.xml

The bold file is the base file (U.S. English in this instance since <default-locale>en</default-locale>) to be translated into German, Spanish, French, Italian, Japanese, Korean, Portugese, Russian, and Chinese.

Example strings.xml File For Android

For information on Android string resources see https://developer.android.com/guide/topics/resources/string-resource

 <?xml version="1.0" encoding="utf-8"?>
 <resources xmlns:tools="http://schemas.android.com/tools">
  <string name="menu_find">Find</string>
  <string name="menu_historical_search">Search Historical Records</string>
  <string name="person_activity_title">Person</string>
  <string name="label_person_tree_button">View This Tree</string>
  <string-array name="planets_array">
       <item>Mercury</item>
       <item>Venus</item>
       <item>Earth</item>
       <item>Mars</item>
   </string-array>
   <plurals name="numberOfSongsAvailable">
       <item quantity="one">%d song found.</item>
       <item quantity="other">%d songs found.</item>
   </plurals>
 </resources>

xml parser type using AndroidParser.xml format definition

valid Android xml syntax

Files that use the xml parser and the AndroidParser.xml format definition are expected to have valid Android xml file syntax

Android .xml uses the xml parser type

When defining a project containing LRM Standard Android.xml resource files, there is no need to define a <parser-type> as the xml parser will always be used along with the AndroidParser.xml format definition.

unique file extension needs to define xml parser type. Xml format definition defaults to Android

If a unique file extension is a valid Android xml file, then:

  • In the Project definition xml file, <parser-type> should be xml
  • There is no need to copy over a format definition because the default definition is for Android syntax.

Example of Project Definition for Resources

The following is an example of xml resource file definitions. See resource extensions for more information on extensions. The project defintion can also be setup using Jenkins

  <resource-extensions>
   <resource-extension>
    <!-- parser-type not needed since .xml is a standard LRM extension that maps to the xml parser type -->
     <extension>xml</extension>
     <file-name-pattern/>
     <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale>
     <file-location-pattern>*-l-c-v</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-extension>     
     <!-- parser-type is required because .myext is not a standard LRM extension -->
     <extension>myext</extension>
     <!-- There is no need to copy over a parser.xml because the default xml parser is for Android files -->
     <parser-type>xml</parser-type>
     <file-name-pattern/>
     <use-pattern-on-dflt-locale>0</use-pattern-on-dflt-locale>
     <file-location-pattern>*-l-c-v</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>