db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1367230 - in /db/derby/code/trunk/java: build/org/apache/derbyBuild/MessageBuilder.java engine/org/apache/derby/loc/messages.xml
Date Mon, 30 Jul 2012 19:19:41 GMT
Author: rhillegas
Date: Mon Jul 30 19:19:41 2012
New Revision: 1367230

URL: http://svn.apache.org/viewvc?rev=1367230&view=rev
Log:
DERBY-5878: Add ability to add comments for translators to the message descriptors in messages.xml.

Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBuilder.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBuilder.java?rev=1367230&r1=1367229&r2=1367230&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBuilder.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/MessageBuilder.java Mon Jul 30 19:19:41
2012
@@ -560,7 +560,8 @@ public class MessageBuilder extends Task
         String        rawText = squeezeText( getFirstChild( message, "text" ) );
         String        propertyText = escapePropertiesText( rawText );
         int             parameterCount = countParameters( rawText );
-        String[]     args = getArgs( message );
+        String[]     comments = getOptionalSubElements( message, "comment" );
+        String[]     args = getOptionalSubElements( message, "arg" );
 
         if ( parameterCount != args.length )
         {
@@ -586,6 +587,16 @@ public class MessageBuilder extends Task
         ditaWriter.endTag();
 
         propertiesPW.println( "" );
+        
+        if ( comments.length != 0 )
+        {
+            for ( int i = 0; i < comments.length; i++ )
+            {
+                propertiesPW.println( "# " + comments[ i ] );
+            }
+            propertiesPW.println( "#" );
+        }
+        
         if ( args.length != 0 )
         {
             propertiesPW.println( "# Arguments:" );
@@ -613,21 +624,21 @@ public class MessageBuilder extends Task
 
     /**
      * <p>
-     * Get all of the human-readable parameter names out of the message element.
+     * Get some optional sub-elements.
      * </p>
      */
-    private String[]    getArgs( Element message )
+    private String[]    getOptionalSubElements( Element message, String subElementTag )
         throws Exception
     {
-        NodeList   args = message.getElementsByTagName( "arg" );
-        int             argCount = args.getLength();
-        String[]    retval = new String[ argCount ];
+        NodeList   options = message.getElementsByTagName( subElementTag );
+        int             count = options.getLength();
+        String[]    retval = new String[ count ];
 
-        for ( int i = 0; i < argCount; i++ )
+        for ( int i = 0; i < count; i++ )
         {
-            Element     arg = (Element) args.item( i );
+            Element     option = (Element) options.item( i );
             
-            retval[ i ] = squeezeText( arg );
+            retval[ i ] = squeezeText( option );
         }
 
         return retval;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=1367230&r1=1367229&r2=1367230&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Mon Jul 30 19:19:41
2012
@@ -26,6 +26,7 @@ information:
 
   * Name of the message - for most messages, this encodes a SQLState
   * Message text returned to the user
+  * Optional comments to help translators understand how the message is used
   * Human-readable names for message arguments
 
 Message argument names should be listed in numeric order rather than



Mime
View raw message