[MMTP-devel] SF.net SVN: mtp: [43] trunk
Status: Pre-Alpha
Brought to you by:
idominguez
|
From: <ido...@us...> - 2007-12-09 14:37:41
|
Revision: 43
http://mtp.svn.sourceforge.net/mtp/?rev=43&view=rev
Author: idominguez
Date: 2007-12-09 06:37:18 -0800 (Sun, 09 Dec 2007)
Log Message:
-----------
i18n support
Modified Paths:
--------------
trunk/build.xml
trunk/src/mtp/analysis/StaticAnalyser.java
trunk/src/mtp/analysis/SymTabBuilder.java
trunk/src/mtp/mtp.java
Added Paths:
-----------
trunk/bin/extract_strings
trunk/resources/
trunk/resources/MTP.po
trunk/resources/translations/
trunk/resources/translations/es_ES/
trunk/resources/translations/es_ES/MTP.po
trunk/src/mtp/i18n/
trunk/src/mtp/i18n/I18N.java
Added: trunk/bin/extract_strings
===================================================================
--- trunk/bin/extract_strings (rev 0)
+++ trunk/bin/extract_strings 2007-12-09 14:37:18 UTC (rev 43)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+find src/mtp -iname *.java | xargs xgettext --keyword=_ -L java -p resources/ -d MTP --from-code=utf-8
Property changes on: trunk/bin/extract_strings
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-12-09 13:44:58 UTC (rev 42)
+++ trunk/build.xml 2007-12-09 14:37:18 UTC (rev 43)
@@ -46,6 +46,8 @@
<target name="compile" description="compiles the source">
<ant antfile="${mtp}/build.xml" target="compile-jar" />
+ <ant antfile="./build.xml" target="translation" />
+ <ant antfile="${mtp}/build.xml" target="compile-jar" />
<mtpscript />
</target>
@@ -130,25 +132,56 @@
<target name="install" depends="compile,configure-install,install-vim">
- <antcall target="install-vim" />
- <mkdir dir="${installroot}/lib" />
- <copy todir="${installroot}" overwrite="true">
- <fileset dir=".">
- <include name="${lib}/JSAP-2.1.jar" />
- <include name="${lib}/mtp.jar" />
- </fileset>
- </copy>
- <symlink action="single"
- link="${installroot}/lib/jsap.jar"
- resource="${installroot}/lib/JSAP-2.1.jar"
- overwrite="true" />
- <mkdir dir="${installroot}/bin" />
- <copy tofile="${installroot}/bin/mtp" overwrite="true" file="bin/mtp.sh" />
- <replace file="${installroot}/bin/mtp" token="$DEV_ROOT" value="${installroot}" />
- <chmod file="${installroot}/bin/mtp" perm="ugo+rx" />
- <symlink action="single"
- link="${installbinroot}/mtp"
- resource="${installroot}/bin/mtp"
- overwrite="true" />
+ <antcall target="install-vim" />
+ <mkdir dir="${installroot}/lib" />
+ <copy todir="${installroot}" overwrite="true">
+ <fileset dir=".">
+ <include name="${lib}/JSAP-2.1.jar" />
+ <include name="${lib}/mtp.jar" />
+ </fileset>
+ </copy>
+ <symlink action="single"
+ link="${installroot}/lib/jsap.jar"
+ resource="${installroot}/lib/JSAP-2.1.jar"
+ overwrite="true" />
+ <mkdir dir="${installroot}/bin" />
+ <copy tofile="${installroot}/bin/mtp" overwrite="true" file="bin/mtp.sh" />
+ <replace file="${installroot}/bin/mtp" token="$DEV_ROOT" value="${installroot}" />
+ <chmod file="${installroot}/bin/mtp" perm="ugo+rx" />
+ <symlink action="single"
+ link="${installbinroot}/mtp"
+ resource="${installroot}/bin/mtp"
+ overwrite="true" />
</target>
+
+<target name="translation">
+ <mtp-translation-generate-classes language="es_ES" />
+</target>
+
+<macrodef name="mtp-translation-generate-classes">
+ <attribute name="language" />
+ <sequential>
+ <translation-generate-classes language="@{language}" base="MTP" destdir="obj" resource="mtp.i18n.MTP" />
+ </sequential>
+</macrodef>
+
+<macrodef name="translation-generate-classes">
+ <attribute name="language" />
+ <attribute name="base" />
+ <attribute name="destdir" />
+ <attribute name="resource" />
+ <sequential>
+ <exec executable="msgfmt">
+ <arg value="--java2" />
+ <arg value="-d" />
+ <arg value="@{destdir}" />
+ <arg value="-r" />
+ <arg value="@{resource}" />
+ <arg value="-l" />
+ <arg value="@{language}" />
+ <arg value="resources/translations/@{language}/@{base}.po" />
+ </exec>
+ </sequential>
+</macrodef>
+
</project>
Added: trunk/resources/MTP.po
===================================================================
--- trunk/resources/MTP.po (rev 0)
+++ trunk/resources/MTP.po 2007-12-09 14:37:18 UTC (rev 43)
@@ -0,0 +1,43 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-09-05 13:31+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL...@li...>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/mtp/synthesis/Output.java:69
+msgid "The directory "
+msgstr ""
+
+#: src/mtp/synthesis/Output.java:70
+msgid " couldn't be created"
+msgstr ""
+
+#: src/mtp/backends/basic/GrammarModuleBackEnd.java:46
+#: src/mtp/backends/basic/GrammarModuleBackEnd.java:71
+#: src/mtp/backends/basic/GrammarModuleBackEnd.java:74
+msgid "mtpfile"
+msgstr ""
+
+#: src/mtp/analysis/SymTabBuilder.java:781
+msgid "According to the module name "
+msgstr ""
+
+#: src/mtp/analysis/SymTabBuilder.java:782
+msgid ", the file should be named "
+msgstr ""
+
+#: src/mtp/analysis/StaticAnalyser.java:111
+msgid "Starting static analysis"
+msgstr ""
Added: trunk/resources/translations/es_ES/MTP.po
===================================================================
--- trunk/resources/translations/es_ES/MTP.po (rev 0)
+++ trunk/resources/translations/es_ES/MTP.po 2007-12-09 14:37:18 UTC (rev 43)
@@ -0,0 +1,37 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: MTP-0.3.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-09-05 13:31+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL...@li...>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/mtp/synthesis/Output.java:69
+msgid "The directory "
+msgstr "El directorio "
+
+#: src/mtp/synthesis/Output.java:70
+msgid " couldn't be created"
+msgstr " no se ha podido crear"
+
+#: src/mtp/analysis/SymTabBuilder.java:781
+msgid "According to the module name "
+msgstr "De acuerdo con el nombre del módulo "
+
+#: src/mtp/analysis/SymTabBuilder.java:782
+msgid ", the file should be named "
+msgstr ", el fichero debería llamarse "
+
+#: src/mtp/analysis/StaticAnalyser.java:111
+msgid "Starting static analysis"
+msgstr "Comenzando análisis estático"
Modified: trunk/src/mtp/analysis/StaticAnalyser.java
===================================================================
--- trunk/src/mtp/analysis/StaticAnalyser.java 2007-12-09 13:44:58 UTC (rev 42)
+++ trunk/src/mtp/analysis/StaticAnalyser.java 2007-12-09 14:37:18 UTC (rev 43)
@@ -33,6 +33,7 @@
import mtp.log.Msg;
import mtp.log.Priority;
import mtp.semantics.*;
+import static mtp.i18n.I18N._;
/**
* Checks some semantic properties of an MTP {@link
@@ -43,8 +44,8 @@
* @author Jaime Nuche
* @author Hector Fuertes
* @author Ivan Perez
- * @version $Revision: 1180 $
- */
+ * @version $Revision: 988 $
+ **/
public class StaticAnalyser {
/**
* To report error and debug messages (log messages in general).
@@ -78,7 +79,7 @@
/**
* Default constructor <b>not allowed</b>
- */
+ **/
private StaticAnalyser()
{
// Unused constructor
@@ -89,7 +90,7 @@
*
* @param log the log object
* @param filename the file name int log messages
- */
+ **/
public StaticAnalyser (Log log,
String filename)
{
@@ -103,11 +104,11 @@
* mtp.semantics.Environment} environment.
*
* @param grammarModule the grammar module to be analysed
- */
+ **/
public void analyse (GrammarModule grammarModule)
{
this.log.report(new Msg(Priority.DEBUG,
- "Starting static analysis"));
+ _("Starting static analysis")));
// Building temporal symbol tables
this.symTabBuilder = new SymTabBuilder(this.log,this.filename);
@@ -136,7 +137,7 @@
/**
* Checks if all the defined symbols are used.
- */
+ **/
private void allSymbolsUsed ()
{
this.log.report(new Msg(Priority.DEBUG,
@@ -158,7 +159,7 @@
* expressions} and builds a symbol table with
* {@link * mtp.semantics.SemRegExp semantic regular expressions}
* in the {@link env environment}
- */
+ **/
private void analyseRegularExpressions ()
{
this.log.report(new Msg(Priority.DEBUG,
@@ -184,7 +185,7 @@
*
* @param tsSymbol the terminal symbol name
* @param expanded the set of the expanded terminal symbols
- */
+ **/
private SemRegExp analyseTerminal (Symbol tsSymbol,
Set<Symbol> expanded)
{
@@ -209,7 +210,7 @@
*
* @param regExp the regular expression to be kinded
* @param expanded the set of terminal symbol used in the definition
- */
+ **/
private SemRegExp.Kind analyseRegExp (RegExp regExp,
Set<Symbol> expanded)
{
@@ -246,7 +247,7 @@
* @param complexRegExp the complex regular expression to be
* kinded
* @param expanded the set of terminal symbol used in the definition
- */
+ **/
private SemRegExp.Kind analyseComplexRegExp
(ComplexRegExp complexRegExp,
Set<Symbol> expanded)
@@ -281,7 +282,7 @@
* kinded
* @param expanded the set of terminal symbol names used in
* the definition.
- */
+ **/
private SemRegExp.Kind analyseRegExpUnit (RegExpUnit regExpUnit,
Set<Symbol> expanded)
{
@@ -350,7 +351,7 @@
* Analyses static properties of {@link mtp.ast.Production
* productions} and adds semantic information to the {@link env
* environment}.
- */
+ **/
private void analyseProductions ()
{
this.log.report(new Msg(Priority.DEBUG,
@@ -371,7 +372,7 @@
* and ads semantic information to the {@link env environment}.
*
* @param ntsSymbol the non terminal symbol to be analysed
- */
+ **/
private void analyseProduction (Symbol ntsSymbol)
{
this.log.report(new Msg(Priority.DEBUG,
@@ -396,7 +397,7 @@
*
* @param ntsSymbol the non terminal symbol to be analysed
* @param classification the RHS in the production definition for ntsName
- */
+ **/
private void analyseClassification (Symbol ntsSymbol,
Classification classification)
{
@@ -449,7 +450,7 @@
*
* @param ntsSymbol the non terminal symbol to be analysed
* @param structure the right hand side of the production
- */
+ **/
private void analyseStructure (Symbol ntsSymbol,
Structure structure)
{
@@ -486,7 +487,7 @@
}
} else if (semLabConsSeq[i].label != null) {
labels.add (semLabConsSeq[i].label);
- } // else (label == null -> non-informative construct)
+ } // else (label = null -> non-informative construct)
}
this.env.structures.put(ntsSymbol, semLabConsSeq);
@@ -519,7 +520,7 @@
* labelled construct}.
*
* @param labelledConstruct the labelled construct
- */
+ **/
private SemLabelledConstruct semanticLabelledConstruct
(LabelledConstruct labelledConstruct)
{
@@ -533,36 +534,16 @@
semLabelledConstruct.label);
}
else {
- String userLabel =
- labelledConstruct.identifierOpt[0].terminalNode.image;
-
- // The label "_" indicates that the user doesn't want to save
- // the symbol in the AST node
- if (userLabel.compareTo("_") == 0) {
- semLabelledConstruct.label = null;
- }
- else {
- semLabelledConstruct.label = userLabel;
- }
+ semLabelledConstruct.label =
+ labelledConstruct.identifierOpt[0].terminalNode.image;
}
}
- else {
- if (labelledConstruct.identifierOpt.length > 0 &&
- semLabelledConstruct.poly == SemLabelledConstruct.Poly.CTE) {
- reportConstantTermianlLabelError
- (semLabelledConstruct.firstIdentifier(),
- labelledConstruct.identifierOpt[0].terminalNode.image);
- }
- }
return semLabelledConstruct;
}
- /**
- * Returns a {@link SemLabelledConstruct semantic labelled
- * construct} from a given {@link mtp.ast.Construct construct}.
+ /*
*
- * @param construct the construct
*/
private SemLabelledConstruct semanticLabelledConstruct (Construct construct)
{
@@ -618,7 +599,7 @@
* @param construct the construct node
*
* @return the significative label in the given construct node
- */
+ **/
private String getConstantTerminalLabel (Construct construct)
{
String label = null;
@@ -663,7 +644,7 @@
* @param construct the construct node
*
* @return the significative type in the given construct node
- */
+ **/
private String baseType (Construct construct)
{
String result = null;
@@ -739,14 +720,14 @@
* @param construct the construct node
*
* @return the polymorphic type of the given construct node
- */
+ **/
private SemLabelledConstruct.Poly poly (Construct construct)
{
SemLabelledConstruct.Poly result;
SemLabelledConstruct.Poly externType;
if (construct instanceof SimpleConstruct) {
- if (this.baseType(construct) == null) {
+ if (baseType(construct) == null) {
result = SemLabelledConstruct.Poly.CTE;
}
else {
@@ -846,7 +827,7 @@
* that stores an instance of the class.
*
* @param className the class name
- */
+ **/
private static String classToAttribute (String className)
{
if (className == null) {
@@ -862,7 +843,7 @@
*
* @param construct the construct
* @return the first identifier in the given construct.
- */
+ **/
private static Identifier firstIdentifier (Construct construct)
{
if (construct instanceof SimpleConstruct) {
@@ -897,7 +878,7 @@
* @param symbol a symbol
*
* @return the symbol name string
- */
+ **/
public static String getSymbolString (Symbol symbol)
{
if (symbol == null) {
@@ -922,7 +903,7 @@
* @param string a string
*
* @return the string with the first char in capital letter
- */
+ **/
public static String firstCharToUpper (String string) {
if (string != null) {
String sub = string.substring(0, 1);
@@ -940,7 +921,7 @@
* @param string a string
*
* @return the string with the first char in small letter
- */
+ **/
public static String firstCharToLower (String string) {
if (string != null) {
String sub = string.substring (0, 1);
@@ -956,7 +937,7 @@
* Reports errors about undefined symbols names.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportUndefSymbolErr (Identifier id)
{
int line = id.terminalNode.beginLine;
@@ -970,7 +951,7 @@
* Reports errors about recursive terminal symbol use.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportCircularRegExpErr (Identifier id)
{
int line = id.terminalNode.beginLine;
@@ -988,7 +969,7 @@
* expressions.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportNonTerminalNotAllowedErr (Identifier id)
{
int line = id.terminalNode.beginLine;
@@ -1004,7 +985,7 @@
* Reports warnings about unused symbols names.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportUnusedSymbolWarn (Symbol symbol)
{
int line = symbol.symbolId.terminalNode.beginLine;
@@ -1019,7 +1000,7 @@
* productions.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportTerminalInClassificationErr (Identifier id)
{
int line = id.terminalNode.beginLine;
@@ -1037,7 +1018,7 @@
* production.
*
* @param id the identifier containing the symbol name
- */
+ **/
private void reportCircularClassificationErr (Identifier id)
{
int line = id.terminalNode.beginLine;
@@ -1052,7 +1033,7 @@
/**
* Reports errors about the semantic restriction in production RHS.
- */
+ **/
private void reportSemanticRestrictionErr (Identifier id,
String tyName1,
String tyName2)
@@ -1072,7 +1053,7 @@
/**
* Reports warning about unlabelled constructs automatically labelled
- */
+ **/
private void reportAutomaticLabelWarn (Identifier id,
String label)
{
@@ -1087,24 +1068,8 @@
}
/**
- * Reports error about constant terminal symbols labelled by the user
- */
- private void reportConstantTermianlLabelError (Identifier id,
- String label)
- {
- int line = id.terminalNode.beginLine;
- int column = id.terminalNode.beginColumn;
- String msg =
- "Constant lexeme terminal symbol (\""
- + label
- + "\") cannot be labelled.";
-
- log.report (new Msg(Priority.ERROR, msg, filename, line, column));
- }
-
- /**
* Reports errors about duplicated labels in right hand side.
- */
+ **/
private void reportDuplicatedLabelErr (Symbol symbol,
String label)
{
Modified: trunk/src/mtp/analysis/SymTabBuilder.java
===================================================================
--- trunk/src/mtp/analysis/SymTabBuilder.java 2007-12-09 13:44:58 UTC (rev 42)
+++ trunk/src/mtp/analysis/SymTabBuilder.java 2007-12-09 14:37:18 UTC (rev 43)
@@ -30,6 +30,7 @@
import mtp.ast.*;
import mtp.log.*;
+import static mtp.i18n.I18N._;
/**
* Builds several symbol tables by visiting a {@link
@@ -777,8 +778,8 @@
int line,
int column)
{
- String msg = "According to the module name " + moduleName +
- ", " + "the file should be named " + moduleName + ".mmtp";
+ String msg = _("According to the module name ") + moduleName +
+ ", " + _("the file should be named ") + moduleName + ".mmtp";
log.report(new Msg (Priority.WARN, msg,
this.filename, line, column));
Added: trunk/src/mtp/i18n/I18N.java
===================================================================
--- trunk/src/mtp/i18n/I18N.java (rev 0)
+++ trunk/src/mtp/i18n/I18N.java 2007-12-09 14:37:18 UTC (rev 43)
@@ -0,0 +1,40 @@
+package mtp.i18n;
+
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+public class I18N
+{
+ private static ResourceBundle catalog = get();
+
+ public static final String _(String s)
+ {
+ if (catalog == null)
+ {
+ return s;
+ }
+ else
+ {
+ try
+ {
+ return catalog.getString(s);
+ }
+ catch (MissingResourceException e)
+ {
+ return s;
+ }
+ }
+ }
+
+ private static ResourceBundle get ()
+ {
+ try
+ {
+ return ResourceBundle.getBundle("mtp.i18n.MTP");
+ }
+ catch (MissingResourceException e)
+ {
+ return null;
+ }
+ }
+}
Modified: trunk/src/mtp/mtp.java
===================================================================
--- trunk/src/mtp/mtp.java 2007-12-09 13:44:58 UTC (rev 42)
+++ trunk/src/mtp/mtp.java 2007-12-09 14:37:18 UTC (rev 43)
@@ -138,8 +138,8 @@
mng.execute(parseCmdLine(jsap, args)) ;
System.exit(0);
- } catch (BackEndException e) {
- System.exit(1);
+ //} catch (BackEndException e) {
+ // System.exit(1);
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(2);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|