[jboss-svn-commits] JBL Code SVN: r16275 - in labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin: src and 19 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 2 02:52:06 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-11-02 02:52:06 -0400 (Fri, 02 Nov 2007)
New Revision: 16275

Added:
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext.g
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext2.g
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Comment.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/ExtendedGetTextParser.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/GetTextNodeFactory.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Message.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/PortableObject.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Comment.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/ExtendedGetTextParser.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/GetTextNodeFactory.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Message.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/PortableObject.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/i18n.apt
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse/TestGetTextParser.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse2/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse2/TestGetTextParser.java
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/resources/
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/resources/sample.po
Modified:
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
   labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml
Log:
work on gettext port

Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml	2007-11-02 05:27:23 UTC (rev 16274)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/pom.xml	2007-11-02 06:52:06 UTC (rev 16275)
@@ -69,9 +69,32 @@
                     <tagBase>https://svn.jboss.org/repos/labs/labs/jbossbuild/maven-plugins/tags</tagBase>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>antlr-maven-plugin</artifactId>
+                <version>2.0-SNAPSHOT</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>antlr</groupId>
+                        <artifactId>antlr</artifactId>
+                        <version>${antlr.version}</version>
+                    </dependency>
+                </dependencies>
+                <configuration>
+                    <grammars>gettext.g,gettext2.g</grammars>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
+
     <reporting>
         <plugins>
             <plugin>
@@ -209,10 +232,19 @@
             <scope>runtime</scope>
         </dependency>
 
+        <!-- Used in the gettext support -->
+        <!-- todo : eventually that support should become its own package -->
+        <dependency>
+            <groupId>antlr</groupId>
+            <artifactId>antlr</artifactId>
+            <version>${antlr.version}</version>
+        </dependency>
+
     </dependencies>
 
     <properties>
         <batikVersion>1.6</batikVersion>
+        <antlr.version>2.7.6</antlr.version>
     </properties>
 
 </project>
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext.g
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext.g	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext.g	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,199 @@
+header {
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+}
+
+/**
+ * Defines a parser for the GNU gettext PO/POT file formats.
+ * <p/>
+ * This grammar is copied nearly verbatim from the kdesdk project from its po/xml package.  It makes certain
+ * assumptions about the PO/POT structure that are true for DocBook masters, which is what it was intended to
+ * deal with (as is jDocBook, so we can live with those assumptions).
+ */
+class GetTextParser extends Parser;
+
+options {
+    exportVocab=GetText;
+    buildAST=true;
+//    k=2;
+}
+
+tokens {
+    // synthetic tokens
+    PORTABLE_OBJECT;
+    MESSAGE;
+}
+
+{
+    protected AST buildPortableObjectNode(AST messageBlocks) {
+        return #( [PORTABLE_OBJECT, "portable-object"], messageBlocks );
+    }
+
+    protected AST buildMessageBlockNode(String text, AST entries) {
+        return #( [MESSAGE, text], entries );
+    }
+}
+
+/**
+ * Main rule
+ */
+portableObject:
+    mb:messageBlocks {
+        #portableObject = buildPortableObjectNode( #mb );
+    }
+    ;
+
+messageBlocks:
+    ( messageBlock | kdesdkCommentBlock )*
+    ;
+
+kdesdkCommentBlock: (kdesdkComment)+ {
+        #kdesdkCommentBlock = buildMessageBlockNode( "kdesdk-message-block", #kdesdkCommentBlock );
+    }
+    ;
+
+
+/**
+ * A message block defines all the lines related to a single translatable message entry.
+ */
+messageBlock:
+    ( translatorComment | extracedComment | referenceComment | flagComment | prevEntryComment )*
+    ( messageId | messageIdPlural | messageContext )+ messageTranslation ( messageTranslationPlural )* {
+        #messageBlock = buildMessageBlockNode( "message-block", #messageBlock );
+    }
+    ;
+
+translatorComment:
+    TRANSLATOR_COMMENT^ (COMMENT_STRING)?
+    ;
+
+extracedComment:
+    EXTRACTED_COMMENT^ (COMMENT_STRING)?
+    ;
+
+referenceComment:
+    REFERENCE_COMMENT^ (COMMENT_STRING)?
+    ;
+
+flagComment:
+    FLAG_COMMENT^ (COMMENT_STRING)?
+    ;
+
+prevEntryComment:
+    PREV_ENTRY_COMMENT^ ( messageId | messageIdPlural | messageContext | messageTranslation | messageTranslationPlural )
+    ;
+
+kdesdkComment:
+    KDESDK_COMMENT^ ( messageId | messageTranslation )
+    ;
+
+messageId:
+    MSGID^ QUOTED_STRING
+    ;
+
+messageIdPlural:
+    MSGID_PLURAL^ QUOTED_STRING
+    ;
+
+messageContext:
+    MSGCTXT^ QUOTED_STRING
+    ;
+
+messageTranslation:
+    MSGSTR^ ( QUOTED_STRING )?
+    ;
+
+messageTranslationPlural:
+    MSGSTR_PLURAL^ OPEN_BRACKET! INTEGER CLOSE_BRACKET! ( QUOTED_STRING )?
+    ;
+
+
+// **** LEXER ******************************************************************
+
+class GetTextLexer extends Lexer;
+
+options {
+    exportVocab=GetText;
+    k=7;
+    charVocabulary='\u0000'..'\uFFFE';
+    caseSensitive = true;
+}
+
+TRANSLATOR_COMMENT: "#";
+EXTRACTED_COMMENT: "#.";
+REFERENCE_COMMENT: "#:";
+FLAG_COMMENT: "#,";
+PREV_ENTRY_COMMENT: "#|";
+KDESDK_COMMENT: "#~";
+
+MSGID: "msgid";
+MSGID_PLURAL: "msgid-plural";
+MSGCTXT: "msgctxt";
+MSGSTR: "msgstr";
+
+INTEGER: ( '0'..'9' )+;
+OPEN_BRACKET: '[';
+CLOSE_BRACKET: ']';
+
+COMMENT_STRING: (~'\n')*;
+
+QUOTED_STRING:	('"'! (ESC|~'"')* ('"'! (' ' | 't')*! '\n'! { newline(); } (' '! | '\t'!)*))+
+    ;
+
+WS  :   (   ' '
+        |   '\t'
+        |   '\r' '\n' { newline(); }
+        |   '\n'      { newline(); }
+        |   '\r'      { newline(); }
+        )
+        {$setType(Token.SKIP);} //ignore this token
+    ;
+
+
+// copied from example
+protected
+ESC	:	'\\'
+        (	'n'
+        |	'r'
+        |	't'
+        |	'b'
+        |	'f'
+        |	'"'
+        |	'\''
+        |	'\\'
+        |	('0'..'3')
+            (
+                options {
+                    warnWhenFollowAmbig = false;
+                }
+            :	('0'..'9')
+                (
+                    options {
+                        warnWhenFollowAmbig = false;
+                    }
+                :	'0'..'9'
+                )?
+            )?
+        |	('4'..'7')
+            (
+                options {
+                    warnWhenFollowAmbig = false;
+                }
+            :	('0'..'9')
+            )?
+        )
+    ;

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext2.g
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext2.g	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/antlr/gettext2.g	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,161 @@
+header {
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+}
+
+/**
+ * Defines a parser for the GNU gettext PO/POT file formats.
+ * <p/>
+ * This grammar is copied nearly verbatim from the kdesdk project from its po/xml package.  It makes certain
+ * assumptions about the PO/POT structure that are true for DocBook masters, which is what it was intended to
+ * deal with (as is jDocBook, so we can live with those assumptions).
+ */
+class GetTextParser extends Parser;
+
+options {
+    exportVocab=GetText;
+    buildAST=true;
+    k=2;
+}
+
+tokens {
+    MSGID = "msgid";
+    MSGID_PLURAL = "msgid_plural";
+    MSGCTXT = "msgctxt";
+    MSGSTR = "msgstr";
+
+    TRANSLATOR_COMMENT = "#";
+    EXTRACTED_COMMENT = "#.";
+    REFERENCE_COMMENT = "#:";
+    FLAG_COMMENT = "#,";
+    PREV_ENTRY_COMMENT = "#|";
+    KDESDK_COMMENT = "#~";
+
+    OPEN_BRACKET = "[";
+    CLOSE_BRACKET = "]";
+    DOUBLE_QUOTE = "\"";
+
+    // synthetic tokens used during tree construction for logical groupings
+    PORTABLE_OBJECT;
+    MESSAGE;
+}
+
+
+/**
+ * Main rule
+ */
+portableObject:
+    mb:messageBlocks {
+        #portableObject = #( [PORTABLE_OBJECT, "portable-object"], #mb );
+    }
+    ;
+
+messageBlocks:
+    ( messageBlock | kdesdkCommentBlock )*
+    ;
+
+kdesdkCommentBlock: (kdesdkComment)+ {
+        #kdesdkCommentBlock = #( [MESSAGE, "kdesdk-message-block"], #kdesdkCommentBlock );
+    }
+    ;
+
+kdesdkComment:
+    KDESDK_COMMENT^ ( messageId | messageTranslation )
+    ;
+
+
+/**
+ * A message block defines all the lines related to a single translatable message entry.
+ */
+messageBlock:
+    ( translatorComment | extractedComment | occurenceComment | flagComment | prevEntryComment )*
+    ( messageId | messageIdPlural | messageContext )+ messageTranslation ( messageTranslationPlural )* {
+        #messageBlock = #( [MESSAGE, "message-block"], #messageBlock );
+    }
+    ;
+
+translatorComment:
+    TRANSLATOR_COMMENT^ SPACE (~NEWLINE)* NEWLINE!
+    ;
+
+extractedComment:
+    EXTRACTED_COMMENT^ SPACE (~NEWLINE)* NEWLINE!
+    ;
+
+occurenceComment:
+    REFERENCE_COMMENT^ SPACE (~NEWLINE)* NEWLINE!
+    ;
+
+flagComment:
+    FLAG_COMMENT^ SPACE (~NEWLINE)* NEWLINE!
+    ;
+
+prevEntryComment:
+    PREV_ENTRY_COMMENT^ ( messageId | messageIdPlural | messageContext | messageTranslation | messageTranslationPlural )
+    ;
+
+messageId:
+    MSGID^ quotedText
+    ;
+
+messageIdPlural:
+    MSGID_PLURAL^ quotedText
+    ;
+
+messageContext:
+    MSGCTXT^ quotedText
+    ;
+
+messageTranslation:
+    MSGSTR^ ( quotedText )?
+    ;
+
+messageTranslationPlural:
+    MSGSTR_PLURAL^ OPEN_BRACKET! INTEGER CLOSE_BRACKET! ( quotedText )?
+    ;
+
+/**
+ * Yikes!!!! ;)
+ */
+quotedText: ( DOUBLE_QUOTE! (ESC|~DOUBLE_QUOTE)* (DOUBLE_QUOTE! (SPACE)*! NEWLINE! (SPACE)*!) )+
+    ;
+
+// **** LEXER ******************************************************************
+
+class GetTextLexer extends Lexer;
+
+options {
+    k=2;
+    exportVocab=GetText;
+    charVocabulary='\u0000'..'\uFFFE'; // Allow any char but \uFFFF (16 bit -1)
+    caseSensitive = true;
+}
+
+SPACE: ( ' ' | '\t' )+;
+
+NEWLINE: (
+        '\r' '\n' { newline(); }
+        | '\r' { newline(); }
+        | '\n' { newline(); }
+    )
+    ;
+HASH: '#';
+
+EOF: '\uFFFF';
+
+INTEGER: ( '0'..'9' )+;
+

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Comment.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Comment.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Comment.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import antlr.CommonAST;
+import antlr.collections.AST;
+
+/**
+ * Comment implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Comment extends CommonAST {
+	public String getCommentText() {
+		StringBuffer buffer = new StringBuffer();
+		AST n = getFirstChild();
+		boolean prependSpace = false;
+		while ( n != null ) {
+			if ( prependSpace ) {
+				buffer.append( ' ' );
+			}
+			buffer.append( n.getText() );
+			n = n.getFirstChild();
+			prependSpace = true;
+		}
+		return buffer.toString();
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/ExtendedGetTextParser.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/ExtendedGetTextParser.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/ExtendedGetTextParser.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+
+import antlr.TokenStream;
+
+/**
+ * ExtendedGetTextParser implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ExtendedGetTextParser extends GetTextParser {
+	public ExtendedGetTextParser(File file) throws FileNotFoundException {
+		this( new GetTextLexer(  new FileReader( file ) ) );
+	}
+
+	public ExtendedGetTextParser(TokenStream lexer) {
+		super( lexer );
+		setASTFactory( new GetTextNodeFactory() );
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/GetTextNodeFactory.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/GetTextNodeFactory.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/GetTextNodeFactory.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import antlr.ASTFactory;
+
+/**
+ * GetTextNodeFactory implementation
+ *
+ * @author Steve Ebersole
+ */
+public class GetTextNodeFactory extends ASTFactory {
+	public Class getASTNodeType(int i) {
+		switch ( i ) {
+			case GetTextTokenTypes.PORTABLE_OBJECT:
+				return PortableObject.class;
+			case GetTextTokenTypes.MESSAGE:
+				return Message.class;
+			case GetTextTokenTypes.EXTRACTED_COMMENT:
+			case GetTextTokenTypes.FLAG_COMMENT:
+			case GetTextTokenTypes.KDESDK_COMMENT:
+			case GetTextTokenTypes.PREV_ENTRY_COMMENT:
+			case GetTextTokenTypes.REFERENCE_COMMENT:
+			case GetTextTokenTypes.TRANSLATOR_COMMENT:
+				return Comment.class;
+			default:
+				return super.getASTNodeType( i );
+		}
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Message.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Message.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/Message.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import antlr.CommonAST;
+import antlr.collections.AST;
+
+/**
+ * Message implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Message  extends CommonAST {
+	public String getMessageContext() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGCTXT );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageId() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGID );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageIdPlural() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGID_PLURAL );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageTranslation() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGSTR );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+//		public List<String> getMessageTranslationPlurals() {
+//			List<String> translations = new ArrayList<String>();
+//			AST child = getFirstChild();
+//			while ( child != null ) {
+//				list.add( child );
+//				child = child.getNextSibling();
+//			}
+//		}
+
+
+	public static AST findTypeInChildren(AST parent, int type) {
+		AST n = parent.getFirstChild();
+		while ( n != null && n.getType() != type ) {
+			n = n.getNextSibling();
+		}
+		return n;
+	}
+
+	public List<Comment> getComments() {
+		List<Comment> list = new ArrayList<Comment>();
+		AST n = getFirstChild();
+		while ( n != null ) {
+			if ( isComment( n ) ) {
+				list.add( ( Comment ) n );
+			}
+			n = n.getNextSibling();
+		}
+		return list;
+	}
+
+	private boolean isComment(AST node) {
+		switch ( node.getType() ) {
+			case GetTextTokenTypes.EXTRACTED_COMMENT:
+			case GetTextTokenTypes.FLAG_COMMENT:
+			case GetTextTokenTypes.KDESDK_COMMENT:
+			case GetTextTokenTypes.PREV_ENTRY_COMMENT:
+			case GetTextTokenTypes.REFERENCE_COMMENT:
+			case GetTextTokenTypes.TRANSLATOR_COMMENT:
+				return true;
+			default:
+				return false;
+		}
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/PortableObject.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/PortableObject.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse/PortableObject.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import antlr.CommonAST;
+
+/**
+ * PortableObject implementation
+ *
+ * @author Steve Ebersole
+ */
+public class PortableObject extends CommonAST {
+	private List<Message> messages;
+
+	public List<Message> getMessageList() {
+		if ( messages == null ) {
+			messages = new ArrayList<Message>();
+			Message child = ( Message ) getFirstChild();
+			while ( child != null ) {
+				messages.add( child );
+				child = ( Message ) child.getNextSibling();
+			}
+		}
+		return messages;
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Comment.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Comment.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Comment.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import antlr.CommonAST;
+import antlr.collections.AST;
+
+/**
+ * Comment implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Comment extends CommonAST {
+	public String getCommentText() {
+		StringBuffer buffer = new StringBuffer();
+		AST n = getFirstChild();
+		boolean prependSpace = false;
+		while ( n != null ) {
+			if ( prependSpace ) {
+				buffer.append( ' ' );
+			}
+			buffer.append( n.getText() );
+			n = n.getFirstChild();
+			prependSpace = true;
+		}
+		return buffer.toString();
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/ExtendedGetTextParser.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/ExtendedGetTextParser.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/ExtendedGetTextParser.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+
+import antlr.TokenStream;
+
+/**
+ * ExtendedGetTextParser implementation
+ *
+ * @author Steve Ebersole
+ */
+public class ExtendedGetTextParser extends GetTextParser {
+	public ExtendedGetTextParser(File file) throws FileNotFoundException {
+		this( new GetTextLexer(  new FileReader( file ) ) );
+	}
+
+	public ExtendedGetTextParser(TokenStream lexer) {
+		super( lexer );
+		setASTFactory( new GetTextNodeFactory() );
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/GetTextNodeFactory.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/GetTextNodeFactory.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/GetTextNodeFactory.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import antlr.ASTFactory;
+
+/**
+ * GetTextNodeFactory implementation
+ *
+ * @author Steve Ebersole
+ */
+public class GetTextNodeFactory extends ASTFactory {
+	public Class getASTNodeType(int i) {
+		switch ( i ) {
+			case GetTextTokenTypes.PORTABLE_OBJECT:
+				return PortableObject.class;
+			case GetTextTokenTypes.MESSAGE:
+				return Message.class;
+			case GetTextTokenTypes.EXTRACTED_COMMENT:
+			case GetTextTokenTypes.FLAG_COMMENT:
+			case GetTextTokenTypes.KDESDK_COMMENT:
+			case GetTextTokenTypes.PREV_ENTRY_COMMENT:
+			case GetTextTokenTypes.REFERENCE_COMMENT:
+			case GetTextTokenTypes.TRANSLATOR_COMMENT:
+				return Comment.class;
+			default:
+				return super.getASTNodeType( i );
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Message.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Message.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/Message.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import antlr.CommonAST;
+import antlr.collections.AST;
+
+/**
+ * Message implementation
+ *
+ * @author Steve Ebersole
+ */
+public class Message extends CommonAST {
+	public String getMessageContext() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGCTXT );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageId() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGID );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageIdPlural() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGID_PLURAL );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+	public String getMessageTranslation() {
+		AST node = findTypeInChildren( this, GetTextTokenTypes.MSGSTR );
+		return ( node == null || node.getFirstChild() == null ) ? "" : node.getFirstChild().getText();
+	}
+
+//		public List<String> getMessageTranslationPlurals() {
+//			List<String> translations = new ArrayList<String>();
+//			AST child = getFirstChild();
+//			while ( child != null ) {
+//				list.add( child );
+//				child = child.getNextSibling();
+//			}
+//		}
+
+
+	public static AST findTypeInChildren(AST parent, int type) {
+		AST n = parent.getFirstChild();
+		while ( n != null && n.getType() != type ) {
+			n = n.getNextSibling();
+		}
+		return n;
+	}
+
+	public List<Comment> getComments() {
+		List<Comment> list = new ArrayList<Comment>();
+		AST n = getFirstChild();
+		while ( n != null ) {
+			if ( isComment( n ) ) {
+				list.add( ( Comment ) n );
+			}
+			n = n.getNextSibling();
+		}
+		return list;
+	}
+
+	private boolean isComment(AST node) {
+		switch ( node.getType() ) {
+			case GetTextTokenTypes.EXTRACTED_COMMENT:
+			case GetTextTokenTypes.FLAG_COMMENT:
+			case GetTextTokenTypes.KDESDK_COMMENT:
+			case GetTextTokenTypes.PREV_ENTRY_COMMENT:
+			case GetTextTokenTypes.REFERENCE_COMMENT:
+			case GetTextTokenTypes.TRANSLATOR_COMMENT:
+				return true;
+			default:
+				return false;
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/PortableObject.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/PortableObject.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/main/java/org/jboss/jdocbook/i18n/gettext/po/parse2/PortableObject.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import antlr.CommonAST;
+
+/**
+ * PortableObject implementation
+ *
+ * @author Steve Ebersole
+ */
+public class PortableObject extends CommonAST {
+	private List<Message> messages;
+
+	public List<Message> getMessageList() {
+		if ( messages == null ) {
+			messages = new ArrayList<Message>();
+			Message child = ( Message ) getFirstChild();
+			while ( child != null ) {
+				messages.add( child );
+				child = ( Message ) child.getNextSibling();
+			}
+		}
+		return messages;
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/i18n.apt
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/i18n.apt	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/apt/i18n.apt	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,40 @@
+ ------
+ Internationalization
+ ------
+ Steve Ebersole
+ ------
+ 30 October 2007
+ ------
+
+~~ Copyright © 2007  Red Hat Middleware, LLC. All rights reserved.
+~~
+~~ This copyrighted material is made available to anyone wishing to use, modify,
+~~ copy, or redistribute it subject to the terms and conditions of the GNU
+~~ Lesser General Public License, v. 2.1. This program is distributed in the
+~~ hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+~~ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+~~ Lesser General Public License for more details. You should have received a
+~~ copy of the GNU Lesser General Public License, v.2.1 along with this
+~~ distribution; if not, write to the Free Software Foundation, Inc.,
+~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~
+~~ Red Hat Author(s): Steve Ebersole
+
+Internationalization
+
+    In support of internationalization (i18n) and locationization (l10n) efforts, the <jDocBook Plugin> allows you
+    to develop and manage language-specific versions of your documentation.  This support comes mainly in two flavors.
+
+* GNU gettext support
+
+    The GNU {{{http://www.gnu.org/software/gettext/}gettext}} package aims to help developers and translators by
+    providing a series of tools to make localizing content easier.  The <jDocBook Plugin> supports an approach to
+    DocBook content development that includes makig use of <gettext>.  Currently the <jDocBook Plugin> relies on
+    the host system having the following executables available on their system/path and makes use of system
+    RuntimeEnvironment calls to execute them:
+
+        [[1]] msginit and msgmerge - these come from the <gettext> package itself (see link above)
+
+        [[2]] xml2pot and po2xml - which come from the KDE poxml package (
+
+        []
\ No newline at end of file

Modified: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml	2007-11-02 05:27:23 UTC (rev 16274)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/site/site.xml	2007-11-02 06:52:06 UTC (rev 16275)
@@ -28,6 +28,7 @@
             <item name="Goals" href="plugin-info.html"/>
             <item name="Usage" href="usage.html"/>
             <item name="Style" href="style.html"/>
+            <item name="Internationalization" href="i18n.html"/>
         </menu>
 
         <menu name="Examples">

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse/TestGetTextParser.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse/TestGetTextParser.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse/TestGetTextParser.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse;
+
+import java.io.File;
+import junit.framework.TestCase;
+
+/**
+ * TestGetTextParser implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TestGetTextParser extends TestCase {
+	private File poFile;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		poFile = new File( getClass().getResource( "/sample.po" ).getFile() );
+	}
+
+	public void testIt() throws Throwable {
+		ExtendedGetTextParser parser = new ExtendedGetTextParser( poFile );
+		parser.portableObject();
+		PortableObject portableObject = ( PortableObject ) parser.getAST();
+		for ( Message message : portableObject.getMessageList() ) {
+			System.out.println( "-------------------------------------------------------------------------------" );
+			System.out.println( "MESSAGE-CTXT : " + message.getMessageContext() );
+			System.out.println( "MESSAGE-ID   : " + message.getMessageId() );
+			System.out.println( "MESSAGE-STR  : " + message.getMessageTranslation() );
+			System.out.println( "COMMENTS:----------------------------------------------------------------------" );
+			for ( Comment comment : message.getComments() ) {
+				System.out.println( "**** (" + comment.getText() + ") : " + comment.getCommentText() );
+			}
+			System.out.println( "    ---------------------------------------------------------------------------" );
+			System.out.println( "-------------------------------------------------------------------------------" );
+		}
+	}
+}

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse2/TestGetTextParser.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse2/TestGetTextParser.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/java/org/jboss/jdocbook/i18n/gettext/po/parse2/TestGetTextParser.java	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details. You should have received a
+ * copy of the GNU Lesser General Public License, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.jdocbook.i18n.gettext.po.parse2;
+
+import java.io.File;
+import junit.framework.TestCase;
+
+/**
+ * TestGetTextParser implementation
+ *
+ * @author Steve Ebersole
+ */
+public class TestGetTextParser extends TestCase {
+	private File poFile;
+
+	protected void setUp() throws Exception {
+		super.setUp();
+		poFile = new File( getClass().getResource( "/sample.po" ).getFile() );
+	}
+
+	public void testIt() throws Throwable {
+		ExtendedGetTextParser parser = new ExtendedGetTextParser( poFile );
+		parser.portableObject();
+		PortableObject portableObject = ( PortableObject ) parser.getAST();
+		for ( Message message : portableObject.getMessageList() ) {
+			System.out.println( "-------------------------------------------------------------------------------" );
+			System.out.println( "MESSAGE-CTXT : " + message.getMessageContext() );
+			System.out.println( "MESSAGE-ID   : " + message.getMessageId() );
+			System.out.println( "MESSAGE-STR  : " + message.getMessageTranslation() );
+			System.out.println( "COMMENTS:----------------------------------------------------------------------" );
+			for ( Comment comment : message.getComments() ) {
+				System.out.println( "**** (" + comment.getText() + ") : " + comment.getCommentText() );
+			}
+			System.out.println( "    ---------------------------------------------------------------------------" );
+			System.out.println( "-------------------------------------------------------------------------------" );
+		}
+	}
+}
\ No newline at end of file

Added: labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/resources/sample.po
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/resources/sample.po	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jdocbook-plugin/src/test/resources/sample.po	2007-11-02 06:52:06 UTC (rev 16275)
@@ -0,0 +1,357 @@
+#, fuzzy
+msgid ""
+msgstr ""
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2007-10-27 04:27+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+
+#. Tag: title
+#: Hibernate_Reference.xml:25
+#, no-c-format
+msgid "HIBERNATE - Relational Persistence for Idiomatic Java"
+msgstr "HIBERNATE - Relational Persistence for Idiomatic Java"
+
+#. Tag: subtitle
+#: Hibernate_Reference.xml:26
+#, no-c-format
+msgid "Hibernate Reference Documentation"
+msgstr "Documentação da Referência do Hibernate"
+
+#. Tag: ulink
+#: Hibernate_Reference.xml:40
+#, no-c-format
+msgid "Red Hat Middleware, LLC."
+msgstr ""
+
+#~ msgid "&copyrightHolder;"
+#~ msgstr "&copyrightHolder;"
+
+#~ msgid "ROLES_OF_TRANSLATORS"
+#~ msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
+
+#~ msgid "CREDIT_FOR_TRANSLATORS"
+#~ msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
+
+## SOME DESCRIPTIVE TITLE.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2007-10-26 22:09+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <kde-i18n-doc at kde.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: application/x-xml2pot; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Tag: title
+#: architecture.xml:21
+#, no-c-format
+msgid "Architecture"
+msgstr ""
+
+#. Tag: title
+#: architecture.xml:24
+#, no-c-format
+msgid "Overview"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:26
+#, no-c-format
+msgid "A (very) high-level view of the Hibernate architecture:"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:39
+#, no-c-format
+msgid "This diagram shows Hibernate using the database and configuration data to provide persistence services (and persistent objects) to the application."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:44
+#, no-c-format
+msgid "We would like to show a more detailed view of the runtime architecture. Unfortunately, Hibernate is flexible and supports several approaches. We will show the two extremes. The \"lite\" architecture has the application provide its own JDBC connections and manage its own transactions. This approach uses a minimal subset of Hibernate's APIs:"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:61
+#, no-c-format
+msgid "The \"full cream\" architecture abstracts the application away from the underlying JDBC/JTA APIs and lets Hibernate take care of the details."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:75
+#, no-c-format
+msgid "Heres some definitions of the objects in the diagrams:"
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:80
+#, no-c-format
+msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:82
+#, no-c-format
+msgid "A threadsafe (immutable) cache of compiled mappings for a single database. A factory for <literal>Session</literal> and a client of <literal>ConnectionProvider</literal>. Might hold an optional (second-level) cache of data that is reusable between transactions, at a process- or cluster-level."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:92
+#, no-c-format
+msgid "Session (<literal>org.hibernate.Session</literal>)"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:94
+#, no-c-format
+msgid "A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps a JDBC connection. Factory for <literal>Transaction</literal>. Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:104
+#, no-c-format
+msgid "Persistent objects and collections"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:106
+#, no-c-format
+msgid "Short-lived, single threaded objects containing persistent state and business function. These might be ordinary JavaBeans/POJOs, the only special thing about them is that they are currently associated with (exactly one) <literal>Session</literal>. As soon as the <literal>Session</literal> is closed, they will be detached and free to use in any application layer (e.g. directly as data transfer objects to and from presentation)."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:117
+#, no-c-format
+msgid "Transient and detached objects and collections"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:119
+#, no-c-format
+msgid "Instances of persistent classes that are not currently associated with a <literal>Session</literal>. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed <literal>Session</literal>."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:128
+#, no-c-format
+msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:130
+#, no-c-format
+msgid "(Optional) A single-threaded, short-lived object used by the application to specify atomic units of work. Abstracts application from underlying JDBC, JTA or CORBA transaction. A <literal>Session</literal> might span several <literal>Transaction</literal>s in some cases. However, transaction demarcation, either using the underlying API or <literal>Transaction</literal>, is never optional!"
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:141
+#, no-c-format
+msgid "ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:143
+#, no-c-format
+msgid "(Optional) A factory for (and pool of) JDBC connections. Abstracts application from underlying <literal>Datasource</literal> or <literal>DriverManager</literal>. Not exposed to application, but can be extended/implemented by the developer."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:151
+#, no-c-format
+msgid "TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:153
+#, no-c-format
+msgid "(Optional) A factory for <literal>Transaction</literal> instances. Not exposed to the application, but can be extended/implemented by the developer."
+msgstr ""
+
+#. Tag: emphasis
+#: architecture.xml:160
+#, no-c-format
+msgid "Extension Interfaces"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:162
+#, no-c-format
+msgid "Hibernate offers many optional extension interfaces you can implement to customize the behavior of your persistence layer. See the API documentation for details."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:171
+#, no-c-format
+msgid "Given a \"lite\" architecture, the application bypasses the <literal>Transaction</literal>/<literal>TransactionFactory</literal> and/or <literal>ConnectionProvider</literal> APIs to talk to JTA or JDBC directly."
+msgstr ""
+
+#. Tag: title
+#: architecture.xml:179
+#, no-c-format
+msgid "Instance states"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:180
+#, no-c-format
+msgid "An instance of a persistent classes may be in one of three different states, which are defined with respect to a <emphasis>persistence context</emphasis>. The Hibernate <literal>Session</literal> object is the persistence context:"
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:188
+#, no-c-format
+msgid "transient"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:190
+#, no-c-format
+msgid "The instance is not, and has never been associated with any persistence context. It has no persistent identity (primary key value)."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:198
+#, no-c-format
+msgid "persistent"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:200
+#, no-c-format
+msgid "The instance is currently associated with a persistence context. It has a persistent identity (primary key value) and, perhaps, a corresponding row in the database. For a particular persistence context, Hibernate <emphasis>guarantees</emphasis> that persistent identity is equivalent to Java identity (in-memory location of the object)."
+msgstr ""
+
+#. Tag: term
+#: architecture.xml:212
+#, no-c-format
+msgid "detached"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:214
+#, no-c-format
+msgid "The instance was once associated with a persistence context, but that context was closed, or the instance was serialized to another process. It has a persistent identity and, perhaps, a corrsponding row in the database. For detached instances, Hibernate makes no guarantees about the relationship between persistent identity and Java identity."
+msgstr ""
+
+#. Tag: title
+#: architecture.xml:229
+#, no-c-format
+msgid "JMX Integration"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:231
+#, no-c-format
+msgid "JMX is the J2EE standard for management of Java components. Hibernate may be managed via a JMX standard service. We provide an MBean implementation in the distribution, <literal>org.hibernate.jmx.HibernateService</literal>."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:237
+#, no-c-format
+msgid "For an example how to deploy Hibernate as a JMX service on the JBoss Application Server, please see the JBoss User Guide. On JBoss AS, you also get these benefits if you deploy using JMX:"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:245
+#, no-c-format
+msgid "<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</literal>'s life cycle can be automatically bound to the scope of a JTA transaction. This means you no longer have to manually open and close the <literal>Session</literal>, this becomes the job of a JBoss EJB interceptor. You also don't have to worry about transaction demarcation in your code anymore (unless you'd like to write a portable persistence layer of course, use the optional Hibernate <literal>Transaction</literal> API for this). You call the <literal>HibernateContext</literal> to access a <literal>Session</literal>."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:257
+#, no-c-format
+msgid "<emphasis>HAR deployment:</emphasis> Usually you deploy the Hibernate JMX service using a JBoss service deployment descriptor (in an EAR and/or SAR file), it supports all the usual configuration options of a Hibernate <literal>SessionFactory</literal>. However, you still have to name all your mapping files in the deployment descriptor. If you decide to use the optional HAR deployment, JBoss will automatically detect all mapping files in your HAR file."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:268
+#, no-c-format
+msgid "Consult the JBoss AS user guide for more information about these options."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:272
+#, no-c-format
+msgid "Another feature available as a JMX service are runtime Hibernate statistics. See <xref linkend=\"configuration-optional-statistics\"/>."
+msgstr ""
+
+#. Tag: title
+#: architecture.xml:279
+#, no-c-format
+msgid "JCA Support"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:280
+#, no-c-format
+msgid "Hibernate may also be configured as a JCA connector. Please see the website for more details. Please note that Hibernate JCA support is still considered experimental."
+msgstr ""
+
+#. Tag: title
+#: architecture.xml:287
+#, no-c-format
+msgid "Contextual Sessions"
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:288
+#, no-c-format
+msgid "Most applications using Hibernate need some form of \"contextual\" sessions, where a given session is in effect throughout the scope of a given context. However, across applications the definition of what constitutes a context is typically different; and different contexts define different scopes to the notion of current. Applications using Hibernate prior to version 3.0 tended to utilize either home-grown <literal>ThreadLocal</literal>-based contextual sessions, helper classes such as <literal>HibernateUtil</literal>, or utilized third-party frameworks (such as Spring or Pico) which provided proxy/interception-based contextual sessions."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:297
+#, no-c-format
+msgid "Starting with version 3.0.1, Hibernate added the <literal>SessionFactory.getCurrentSession()</literal> method. Initially, this assumed usage of <literal>JTA</literal> transactions, where the <literal>JTA</literal> transaction defined both the scope and context of a current session. The Hibernate team maintains that, given the maturity of the numerous stand-alone <literal>JTA TransactionManager</literal> implementations out there, most (if not all) applications should be using <literal>JTA</literal> transaction management whether or not they are deployed into a <literal>J2EE</literal> container. Based on that, the <literal>JTA</literal>-based contextual sessions is all you should ever need to use."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:307
+#, no-c-format
+msgid "However, as of version 3.1, the processing behind <literal>SessionFactory.getCurrentSession()</literal> is now pluggable. To that end, a new extension interface (<literal>org.hibernate.context.CurrentSessionContext</literal>) and a new configuration parameter (<literal>hibernate.current_session_context_class</literal>) have been added to allow pluggability of the scope and context of defining current sessions."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:314
+#, no-c-format
+msgid "See the Javadocs for the <literal>org.hibernate.context.CurrentSessionContext</literal> interface for a detailed discussion of its contract. It defines a single method, <literal>currentSession()</literal>, by which the implementation is responsible for tracking the current contextual session. Out-of-the-box, Hibernate comes with three implementations of this interface."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:324
+#, no-c-format
+msgid "<literal>org.hibernate.context.JTASessionContext</literal> - current sessions are tracked and scoped by a <literal>JTA</literal> transaction. The processing here is exactly the same as in the older JTA-only approach. See the Javadocs for details."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:332
+#, no-c-format
+msgid "<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current sessions are tracked by thread of execution. Again, see the Javadocs for details."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:338
+#, no-c-format
+msgid "<literal>org.hibernate.context.ManagedSessionContext</literal> - current sessions are tracked by thread of execution. However, you are responsible to bind and unbind a <literal>Session</literal> instance with static methods on this class, it does never open, flush, or close a <literal>Session</literal>."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:347
+#, no-c-format
+msgid "The first two implementations provide a \"one session - one database transaction\" programming model, also known and used as <emphasis>session-per-request</emphasis>. The beginning and end of a Hibernate session is defined by the duration of a database transaction. If you use programatic transaction demarcation in plain JSE without JTA, you are adviced to use the Hibernate <literal>Transaction</literal> API to hide the underlying transaction system from your code. If you use JTA, use the JTA interfaces to demarcate transactions. If you execute in an EJB container that supports CMT, transaction boundaries are defined declaratively and you don't need any transaction or session demarcation operations in your code. Refer to <xref linkend=\"transactions\"/> for more information and code examples."
+msgstr ""
+
+#. Tag: para
+#: architecture.xml:359
+#, no-c-format
+msgid "The <literal>hibernate.current_session_context_class</literal> configuration parameter defines which <literal>org.hibernate.context.CurrentSessionContext</literal> implementation should be used. Note that for backwards compatibility, if this config param is not set but a <literal>org.hibernate.transaction.TransactionManagerLookup</literal> is configured, Hibernate will use the <literal>org.hibernate.context.JTASessionContext</literal>. Typically, the value of this parameter would just name the implementation class to use; for the three out-of-the-box implementations, however, there are three corresponding short names, \"jta\", \"thread\", and \"managed\"."
+msgstr ""




More information about the jboss-svn-commits mailing list