Skip to content

Commit

Permalink
Updated for XliffManager 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Dec 28, 2024
1 parent 6e60142 commit e801224
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Where:
-catalog: (optional) XML catalog to use for processing
-unapproved: (optional) accept translations from unapproved segments
-export: (optional) generate TMX file from approved segments
-getTarget: (optional) display a potential target file name and exit
```

## XLIFF Validation
Expand Down
Binary file modified lib/openxliff.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions src/com/maxprograms/converters/ApproveAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import javax.xml.parsers.ParserConfigurationException;

Expand Down Expand Up @@ -49,6 +50,9 @@ public static void main(String[] args) {
help();
return;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
if (arg.equals("-xliff") && (i + 1) < arguments.length) {
xliff = arguments[i + 1];
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/maxprograms/converters/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ private Constants() {

public static final String TOOLID = "OpenXLIFF";
public static final String TOOLNAME = "OpenXLIFF Filters";
public static final String VERSION = "4.0.0";
public static final String BUILD = "20241225_0934";
public static final String VERSION = "4.1.0";
public static final String BUILD = "20241228_0951";

public static final String SUCCESS = "0";
public static final String ERROR = "1";
Expand Down
4 changes: 4 additions & 0 deletions src/com/maxprograms/converters/Convert.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
Expand Down Expand Up @@ -114,6 +115,9 @@ public static void main(String[] args) {
listCharsets();
return;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
if (arg.equals("-json") && (i + 1) < arguments.length) {
jsonFile = arguments[i + 1];
try {
Expand Down
4 changes: 4 additions & 0 deletions src/com/maxprograms/converters/CopySources.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -52,6 +53,9 @@ public static void main(String[] args) {
help();
return;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
if (arg.equals("-xliff") && (i + 1) < arguments.length) {
xliff = arguments[i + 1];
}
Expand Down
18 changes: 18 additions & 0 deletions src/com/maxprograms/converters/Merge.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeSet;

Expand Down Expand Up @@ -79,6 +80,7 @@ public static void main(String[] args) {
String catalog = "";
boolean unapproved = false;
boolean exportTMX = false;
boolean getTarget = false;

String[] arguments = Utils.fixPath(args);
for (int i = 0; i < arguments.length; i++) {
Expand Down Expand Up @@ -107,6 +109,12 @@ public static void main(String[] args) {
if (arg.equals("-export")) {
exportTMX = true;
}
if (arg.equals("-getTarget")) {
getTarget = true;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
}
if (arguments.length < 2) {
help();
Expand All @@ -120,6 +128,16 @@ public static void main(String[] args) {
if (!xliffFile.isAbsolute()) {
xliff = xliffFile.getAbsoluteFile().getAbsolutePath();
}
if (getTarget) {
try {
target = getTargetFile(xliff);
System.out.println(target);
return;
} catch (IOException | SAXException | ParserConfigurationException e) {
logger.log(Level.ERROR, Messages.getString("Merge.03"), e);
return;
}
}
if (target.isEmpty()) {
try {
target = getTargetFile(xliff);
Expand Down
4 changes: 4 additions & 0 deletions src/com/maxprograms/converters/PseudoTranslation.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;
Expand Down Expand Up @@ -52,6 +53,9 @@ public static void main(String[] args) {
help();
return;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
if (arg.equals("-xliff") && (i + 1) < arguments.length) {
xliff = arguments[i + 1];
}
Expand Down
4 changes: 4 additions & 0 deletions src/com/maxprograms/converters/RemoveTargets.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import javax.xml.parsers.ParserConfigurationException;

Expand Down Expand Up @@ -47,6 +48,9 @@ public static void main(String[] args) {
help();
return;
}
if (arg.equals("-lang") && (i + 1) < arguments.length) {
Locale.setDefault(Locale.forLanguageTag(arguments[i + 1]));
}
if (arg.equals("-xliff") && (i + 1) < arguments.length) {
xliff = arguments[i + 1];
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxprograms/converters/converters.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Join.3=XLIFF files with different source language
Join.4=XLIFF files with different target language
Join.5=Missing -target parameter
Join.6=Missing -files parameter
Merge.help=\n\nUsage:\n\n{0} [-help] [-version] -xliff xliffFile -target targetFile [-catalog catalogFile] [-unapproved] [-export]\n\nWhere:\n\n -help: (optional) display this help information and exit\n -version: (optional) display version & build information and exit\n -xliff: XLIFF file to merge\n -target: (optional) translated file or folder where to store translated files\n -catalog: (optional) XML catalog to use for processing\n -unapproved: (optional) accept translations from unapproved segments\n -export: (optional) generate TMX file from approved segments\n\n
Merge.help=\n\nUsage:\n\n{0} [-help] [-version] -xliff xliffFile -target targetFile [-catalog catalogFile] [-unapproved] [-export]\n\nWhere:\n\n -help: (optional) display this help information and exit\n -version: (optional) display version & build information and exit\n -xliff: XLIFF file to merge\n -target: (optional) translated file or folder where to store translated files\n -catalog: (optional) XML catalog to use for processing\n -unapproved: (optional) accept translations from unapproved segments\n -export: (optional) generate TMX file from approved segments\n -getTarget: (optional) display a potential target file name and exit\n\n
Merge.01=Version: {0} Build: {1}
Merge.02=Missing '-xliff' parameter
Merge.03=Error getting target file
Expand Down
2 changes: 1 addition & 1 deletion src/com/maxprograms/converters/converters_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Join.3=Archivos XLIFF con diferente idioma de origen
Join.4=Archivos XLIFF con diferente idioma de destino
Join.5=Falta el parámetro -target
Join.6=Falta el parámetro -files
Merge.help=\n\nUso:\n\n{0} [-help] [-version] -xliff archivoXliff -target traducción [-catalog catalogoXml] [-unapproved] [-export]\n\nDónde:\n\n -help: (opcional) mostrar esta información de ayuda y salir\n -versión: (opcional) mostrar información de versión y salir\n -xliff: archivo XLIFF para combinar\n -target: (opcional) archivo traducido o carpeta donde almacenar los archivos traducidos\n -catalog: (opcional) Catálogo XML para el procesamiento\n -unapproved: (opcional) aceptar traducciones de segmentos no aprobados\n -export: (opcional) generar archivo TMX a partir de segmentos aprobados\n\n
Merge.help=\n\nUso:\n\n{0} [-help] [-version] -xliff archivoXliff -target traducción [-catalog catalogoXml] [-unapproved] [-export]\n\nDónde:\n\n -help: (opcional) mostrar esta información de ayuda y salir\n -versión: (opcional) mostrar información de versión y salir\n -xliff: archivo XLIFF para combinar\n -target: (opcional) archivo traducido o carpeta donde almacenar los archivos traducidos\n -catalog: (opcional) Catálogo XML para el procesamiento\n -unapproved: (opcional) aceptar traducciones de segmentos no aprobados\n -export: (opcional) generar archivo TMX a partir de segmentos aprobados\n -getTarget: (opcional) mostrar un posible nombre de archivo traducido y salir\n\n
Merge.01=Versión: {0} Compilación: {1}
Merge.02=Falta el parámetro '-xliff'
Merge.03=Error al obtener el archivo de destino
Expand Down
25 changes: 25 additions & 0 deletions src/com/maxprograms/converters/sdlppx/Sdlppx2Xliff.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
Expand Down Expand Up @@ -60,6 +61,30 @@ private Sdlppx2Xliff() {
// use run method instead
}

public static void main(String[] args) {
String[] params = Utils.fixPath(args);
String file = "";
for (int i = 0; i < params.length; i++) {
if ("-lang".equals(params[i]) && i + 1 < params.length) {
Locale.setDefault(Locale.forLanguageTag(params[i + 1]));
}
if ("-file".equals(params[i]) && i + 1 < params.length) {
file = params[i + 1];
}
}
if (file.isEmpty()) {
System.out.println(Messages.getString("Sdlppx2Xliff.5"));
return;
}
try {
JSONObject json = getPackageLanguages(file);
System.out.println(json.toString(2));
} catch (IOException | SAXException | ParserConfigurationException e) {
Logger logger = System.getLogger(Sdlppx2Xliff.class.getName());
logger.log(Level.ERROR, e);
}
}

public static List<String> run(Map<String, String> params) {
List<String> result = new ArrayList<>();

Expand Down
1 change: 1 addition & 0 deletions src/com/maxprograms/converters/sdlppx/sdlppx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Sdlppx2Xliff.1=Incorrect source language. Valid options:
Sdlppx2Xliff.2=Error converting SDL package
Sdlppx2Xliff.3=Project file not found in package
Sdlppx2Xliff.4=Selected file is a return package
Sdlppx2Xliff.5=Missing -file parameter
Xliff2Sdlrpx.0=Missing <header>
Xliff2Sdlrpx.1=Missing <prop-group>
Xliff2Sdlrpx.2=Missing sdlxliff file name
Expand Down
1 change: 1 addition & 0 deletions src/com/maxprograms/converters/sdlppx/sdlppx_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Sdlppx2Xliff.1=Idioma de origen incorrecto. Opciones válidas:
Sdlppx2Xliff.2=Error al convertir el paquete de SDL
Sdlppx2Xliff.3=Archivo de proyecto no encontrado en el paquete
Sdlppx2Xliff.4=El archivo seleccionado es un paquete de devolución
Sdlppx2Xliff.5=Falta el parámetro -file
Xliff2Sdlrpx.0=Falta <header>
Xliff2Sdlrpx.1=Falta <prop-group>
Xliff2Sdlrpx.2=Falta el nombre de archivo sdlxliff
Expand Down
28 changes: 28 additions & 0 deletions src/com/maxprograms/converters/xliff/XliffUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@

import java.io.File;
import java.io.IOException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import javax.xml.parsers.ParserConfigurationException;

import org.json.JSONException;
import org.json.JSONObject;
import org.xml.sax.SAXException;

import com.maxprograms.converters.Utils;
import com.maxprograms.xml.Attribute;
import com.maxprograms.xml.Document;
import com.maxprograms.xml.Element;
Expand All @@ -34,6 +38,30 @@ private XliffUtils() {
// do not instantiate this class
}

public static void main(String[] args) {
String[] params = Utils.fixPath(args);
String file = "";
for (int i = 0; i < params.length; i++) {
if ("-lang".equals(params[i]) && i + 1 < params.length) {
Locale.setDefault(Locale.forLanguageTag(params[i + 1]));
}
if ("-file".equals(params[i]) && i + 1 < params.length) {
file = params[i + 1];
}
}
if (file.isEmpty()) {
System.out.println(Messages.getString("XliffUtils.3"));
return;
}
try {
JSONObject json = getXliffLanguages(new File(file));
System.out.println(json.toString(2));
} catch (IOException | SAXException | ParserConfigurationException e) {
Logger logger = System.getLogger(XliffUtils.class.getName());
logger.log(Level.ERROR, e);
}
}

public static String getHead(Element e) {
StringBuilder builder = new StringBuilder();
builder.append('<');
Expand Down
1 change: 1 addition & 0 deletions src/com/maxprograms/converters/xliff/xliff.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ FromOpenXliff.1=Error merging XLIFF file
FromOpenXliff.2=Wrong XLIFF version
XliffUtils.1=Selected file is not an XLIFF document
XliffUtils.2=Unsupported version of XLIFF
XliffUtils.3=Missing -file parameter
1 change: 1 addition & 0 deletions src/com/maxprograms/converters/xliff/xliff_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ FromOpenXliff.1=Error al combinar el archivo XLIFF
FromOpenXliff.2=Versión de XLIFF incorrecta
XliffUtils.1=El archivo seleccionado no es un documento XLIFF
XliffUtils.2=Versión no compatible de XLIFF
XliffUtils.3=Falta el parámetro -file
4 changes: 4 additions & 0 deletions src/com/maxprograms/stats/RepetitionAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

Expand Down Expand Up @@ -70,6 +71,9 @@ public static void main(String[] args) {
if (arg.equals("-catalog") && (i + 1) < fixedArgs.length) {
catalog = fixedArgs[i + 1];
}
if (arg.equals("-lang") && (i + 1) < fixedArgs.length) {
Locale.setDefault(Locale.forLanguageTag(fixedArgs[i + 1]));
}
}
if (fixedArgs.length < 2) {
help();
Expand Down
4 changes: 4 additions & 0 deletions src/com/maxprograms/validation/XliffChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -80,6 +81,9 @@ public static void main(String[] args) {
help();
return;
}
if (arg.equals("-lang") && (i + 1) < fixedArgs.length) {
Locale.setDefault(Locale.forLanguageTag(fixedArgs[i + 1]));
}
if (arg.equals("-xliff") && (i + 1) < fixedArgs.length) {
xliff = fixedArgs[i + 1];
}
Expand Down

0 comments on commit e801224

Please sign in to comment.