1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: lngex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_transex3.hxx"
36 #include "lngmerge.hxx"
38 // defines to parse command line
39 #define STATE_NON 0x0001
40 #define STATE_INPUT 0x0002
41 #define STATE_OUTPUT 0x0003
42 #define STATE_PRJ 0x0004
43 #define STATE_ROOT 0x0005
44 #define STATE_MERGESRC 0x0006
45 #define STATE_ERRORLOG 0x0007
46 #define STATE_BREAKHELP 0x0008
47 #define STATE_UNMERGE 0x0009
48 #define STATE_UTF8 0x000A
49 #define STATE_ULF 0x000B
50 #define STATE_LANGUAGES 0x000C
52 // set of global variables
53 ByteString sInputFile
;
58 BOOL bULF
; // ULF = Unicode Language File
62 ByteString sOutputFile
;
65 /*****************************************************************************/
66 BOOL
ParseCommandLine( int argc
, char* argv
[])
67 /*****************************************************************************/
69 bEnableExport
= FALSE
;
77 Export::sLanguages
= "";
79 USHORT nState
= STATE_NON
;
83 for( int i
= 1; i
< argc
; i
++ ) {
84 ByteString
sSwitch( argv
[ i
] );
85 sSwitch
.ToUpperAscii();
86 if ( sSwitch
== "-I" ) {
87 nState
= STATE_INPUT
; // next tokens specifies source files
89 else if ( sSwitch
== "-O" ) {
90 nState
= STATE_OUTPUT
; // next token specifies the dest file
92 else if ( sSwitch
== "-P" ) {
93 nState
= STATE_PRJ
; // next token specifies the cur. project
95 else if ( sSwitch
== "-R" ) {
96 nState
= STATE_ROOT
; // next token specifies path to project root
98 else if ( sSwitch
== "-QQ" ) {
101 else if ( sSwitch
== "-M" ) {
102 nState
= STATE_MERGESRC
; // next token specifies the merge database
104 else if ( sSwitch
== "-E" ) {
105 nState
= STATE_ERRORLOG
;
108 else if ( sSwitch
== "-UTF8" ) {
112 /* else if ( sSwitch == "-NOUTF8" ) {
116 /* else if ( sSwitch == "-ULF" ) {
120 else if ( sSwitch
== "-L" ) {
121 nState
= STATE_LANGUAGES
;
126 return FALSE
; // no valid command line
130 sInputFile
= argv
[ i
];
131 bInput
= TRUE
; // source file found
135 sOutputFile
= argv
[ i
]; // the dest. file
140 // sPrj.ToLowerAscii(); // the project
144 sPrjRoot
= argv
[ i
]; // path to project root
147 case STATE_MERGESRC
: {
148 sMergeSrc
= argv
[ i
];
149 bMergeMode
= TRUE
; // activate merge mode, cause merge database found
152 case STATE_LANGUAGES
: {
153 Export::sLanguages
= argv
[ i
];
161 // command line is valid
163 bEnableExport
= TRUE
;
167 // command line is not valid
172 /*****************************************************************************/
174 /*****************************************************************************/
176 //fprintf( stdout, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-e][-b][-u][-NOUTF8][-ULF][-L l1,l2,...]\n" );
177 fprintf( stdout
, "Syntax:ULFEX[-p Prj][-r PrjRoot]-i FileIn -o FileOut[-m DataBase][-L l1,l2,...]\n" );
178 fprintf( stdout
, " Prj: Project\n" );
179 fprintf( stdout
, " PrjRoot: Path to project root (..\\.. etc.)\n" );
180 fprintf( stdout
, " FileIn: Source file (*.lng)\n" );
181 fprintf( stdout
, " FileOut: Destination file (*.*)\n" );
182 fprintf( stdout
, " DataBase: Mergedata (*.sdf)\n" );
183 fprintf( stdout
, " -QQ: quite output\n" );
184 //fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
185 //fprintf( stdout, " -ULF: enables Unicode Language File format, leads to UTF8 encoded version of lng files" );
186 fprintf( stdout
, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
187 fprintf( stdout
, " A fallback language can be defined like this: l1=f1.\n" );
188 fprintf( stdout
, " f1, f2,... are also elements of (de,en-US...)\n" );
189 fprintf( stdout
, " Example: -L de,es=en-US\n" );
190 fprintf( stdout
, " Restriction to de and es, en-US will be fallback for es\n" );
193 /*****************************************************************************/
194 #if defined(UNX) || defined(OS2)
195 int main( int argc
, char *argv
[] )
197 int _cdecl
main( int argc
, char *argv
[] )
199 /*****************************************************************************/
201 if ( !ParseCommandLine( argc
, argv
)) {
206 fprintf( stdout
, "\nUlfEx 1 Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.\n" );
207 fprintf( stdout
, "====================================================================\n" );
208 fprintf( stdout
, "\nProcessing File %s ...\n", sInputFile
.GetBuffer());
211 fprintf(stdout
, ".");
215 if ( sOutputFile
.Len()) {
216 LngParser
aParser( sInputFile
, bUTF8
, bULF
, bQuiet
);
218 aParser
.Merge( sMergeSrc
, sOutputFile
, sPrj
);
220 aParser
.CreateSDF( sOutputFile
, sPrj
, sPrjRoot
);
223 if( !bQuiet
) fprintf( stdout
, "\n=================================================\n\n" );