xref: /aoo41x/main/l10ntools/layout/tralay.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp>
29*cdf0e10cSrcweir #include <l10ntools/vosapp.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <osl/file.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "export.hxx"
34*cdf0e10cSrcweir #include "layoutparse.hxx"
35*cdf0e10cSrcweir #include "helpmerge.hxx"
36*cdf0e10cSrcweir #include "xmlparse.hxx"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir // Convert a rtl::OUString to a byte string.
39*cdf0e10cSrcweir #define OUSTRING_CSTR( str ) \
40*cdf0e10cSrcweir     rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr()
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #define STRING( str ) String( str, RTL_TEXTENCODING_UTF8 )
43*cdf0e10cSrcweir #define BSTRING( str ) ByteString( str, RTL_TEXTENCODING_UTF8 )
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using ::rtl::OUString;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir using namespace ::osl;
48*cdf0e10cSrcweir using namespace ::com::sun::star;
49*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir class TranslateLayout : public Application
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir     ByteString mGid1;
55*cdf0e10cSrcweir     ByteString mLanguage;
56*cdf0e10cSrcweir     ByteString mLocalize;
57*cdf0e10cSrcweir     ByteString mOutput;
58*cdf0e10cSrcweir     ByteString mProject;
59*cdf0e10cSrcweir     ByteString mRoot;
60*cdf0e10cSrcweir     bool mMergeMode;
61*cdf0e10cSrcweir     std::vector< ByteString > mLanguages;
62*cdf0e10cSrcweir     std::list< ByteString > mFiles;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir     TranslateLayout();
66*cdf0e10cSrcweir     virtual ~TranslateLayout();
67*cdf0e10cSrcweir     ByteString GetCommandLineParam( int i );
68*cdf0e10cSrcweir     ByteString GetOptionArgument( int const i );
69*cdf0e10cSrcweir     void ExceptionalMain();
70*cdf0e10cSrcweir     void Main();
71*cdf0e10cSrcweir     void Merge();
72*cdf0e10cSrcweir     void MergeLanguage( ByteString const& language );
73*cdf0e10cSrcweir     void ParseCommandLine();
74*cdf0e10cSrcweir     void CreateSDF();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir     using Application::GetCommandLineParam;
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir static void usage()
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     fprintf( stderr, "Usage: tralay [OPTION]... XML-FILE\n" );
82*cdf0e10cSrcweir     fprintf( stderr, "\nOptions:\n" );
83*cdf0e10cSrcweir     fprintf( stderr, "  -h,--help                  show this help\n" );
84*cdf0e10cSrcweir     fprintf( stderr, "  -l,--language=LANG         process this language\n" );
85*cdf0e10cSrcweir     fprintf( stderr, "  -m,--merge=DATABASE.SDF    translation database\n" );
86*cdf0e10cSrcweir     fprintf( stderr, "\nExamples:\n" );
87*cdf0e10cSrcweir     fprintf( stderr, "  tralay -l en-US -o localize.sdf zoom.xml   # Extract\n" );
88*cdf0e10cSrcweir     fprintf( stderr, "  tralay -m localize.sdf -l de -l nl -o out zoom.xml  # Merge/translate\n" );
89*cdf0e10cSrcweir     exit( 2 );
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir static ByteString ConvertSystemPath( const ByteString& rPath )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     if( rPath.CompareTo( ".", 1 ) == 0 )
95*cdf0e10cSrcweir     {
96*cdf0e10cSrcweir         OUString sPath( rPath.GetBuffer(), rPath.Len(), RTL_TEXTENCODING_UTF8 );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         ::rtl::OUString curDirPth, sURL;
99*cdf0e10cSrcweir         osl_getProcessWorkingDir( &curDirPth.pData );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         ::osl::FileBase::getAbsoluteFileURL( curDirPth, sPath, sURL );
102*cdf0e10cSrcweir         ::osl::FileBase::getSystemPathFromFileURL( sURL, sPath );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir         return ByteString( rtl::OUStringToOString( sPath, RTL_TEXTENCODING_UTF8 ) );
105*cdf0e10cSrcweir     }
106*cdf0e10cSrcweir     else
107*cdf0e10cSrcweir     {
108*cdf0e10cSrcweir         return rPath;
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir ByteString TranslateLayout::GetCommandLineParam( int i )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     return ByteString( OUSTRING_CSTR( Application::GetCommandLineParam( sal::static_int_cast< sal_uInt16 >( i ) ) ) );
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir ByteString TranslateLayout::GetOptionArgument( int const i )
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir     if ( i >= GetCommandLineParamCount() )
120*cdf0e10cSrcweir         usage();
121*cdf0e10cSrcweir     ByteString arg = GetCommandLineParam( i );
122*cdf0e10cSrcweir     if ( !arg.CompareTo( "-", 1 ) )
123*cdf0e10cSrcweir     {
124*cdf0e10cSrcweir         fprintf( stderr, "Option needs an argument: %s, found: %s\n",
125*cdf0e10cSrcweir                  GetCommandLineParam( i - 1 ).GetBuffer(),
126*cdf0e10cSrcweir                  arg.GetBuffer() );
127*cdf0e10cSrcweir         usage();
128*cdf0e10cSrcweir     }
129*cdf0e10cSrcweir     return arg;
130*cdf0e10cSrcweir  }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir void TranslateLayout::ParseCommandLine()
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir     for ( int i = 0; i < GetCommandLineParamCount(); i++ )
135*cdf0e10cSrcweir     {
136*cdf0e10cSrcweir         ByteString aParam = GetCommandLineParam( i );
137*cdf0e10cSrcweir         if ( aParam.Equals( "-h" ) || aParam.Equals( "--help" ) )
138*cdf0e10cSrcweir             usage();
139*cdf0e10cSrcweir         else if ( aParam.Equals( "-l" ) || aParam.Equals( "--language" ) )
140*cdf0e10cSrcweir             mLanguages.push_back ( GetOptionArgument( ++i ) );
141*cdf0e10cSrcweir         else if ( aParam.Equals( "-m" ) || aParam.Equals( "--merge" ) )
142*cdf0e10cSrcweir         {
143*cdf0e10cSrcweir             mMergeMode = true;
144*cdf0e10cSrcweir             mLocalize = GetOptionArgument( ++i );
145*cdf0e10cSrcweir         }
146*cdf0e10cSrcweir         else if ( aParam.Equals( "-o" ) || aParam.Equals( "--output" ) )
147*cdf0e10cSrcweir             mOutput = ConvertSystemPath( GetOptionArgument( ++i ) );
148*cdf0e10cSrcweir         else if ( !aParam.CompareTo( "-", 1 ) )
149*cdf0e10cSrcweir         {
150*cdf0e10cSrcweir             fprintf( stderr, "error: No such option: %s\n", aParam.GetBuffer() );
151*cdf0e10cSrcweir             usage();
152*cdf0e10cSrcweir         }
153*cdf0e10cSrcweir         else
154*cdf0e10cSrcweir             mFiles.push_back( ConvertSystemPath( aParam ) );
155*cdf0e10cSrcweir     }
156*cdf0e10cSrcweir     if ( !mFiles.size() )
157*cdf0e10cSrcweir     {
158*cdf0e10cSrcweir         fprintf( stderr, "error: No XML-FILE found\n" );
159*cdf0e10cSrcweir         usage();
160*cdf0e10cSrcweir     }
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir static XMLAttribute*
164*cdf0e10cSrcweir findAttribute( XMLAttributeList* lst, String const& name )
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     for ( sal_uLong i = 0; i < lst->Count(); i++ )
167*cdf0e10cSrcweir         if ( lst->GetObject( i )->Equals( name ) )
168*cdf0e10cSrcweir             return lst->GetObject( i );
169*cdf0e10cSrcweir     return 0;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir static XMLAttribute*
173*cdf0e10cSrcweir translateAttribute( XMLAttributeList* lst,
174*cdf0e10cSrcweir                     String const& name, String const& translation )
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir     if ( XMLAttribute* a = findAttribute( lst, name ) )
177*cdf0e10cSrcweir         return lst->Replace ( new XMLAttribute( name.Copy( 1 ), translation ), a );
178*cdf0e10cSrcweir     return 0;
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir static void
182*cdf0e10cSrcweir translateElement( XMLElement* element, ByteString const& lang,
183*cdf0e10cSrcweir                   ResData* resData, MergeDataFile& mergeData )
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     XMLAttributeList* attributes = element->GetAttributeList();
186*cdf0e10cSrcweir     std::vector<XMLAttribute*> interesting( interestingAttributes( attributes ) );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir     if( !interesting.empty() )
190*cdf0e10cSrcweir     {
191*cdf0e10cSrcweir         std::vector<XMLAttribute*>::iterator i( interesting.begin() );
192*cdf0e10cSrcweir         ByteString id = BSTRING( (*i++)->GetValue() );
193*cdf0e10cSrcweir         for ( ; i != interesting.end(); ++i )
194*cdf0e10cSrcweir         {
195*cdf0e10cSrcweir             ByteString attributeId = id;
196*cdf0e10cSrcweir             attributeId += BSTRING ( **i );
197*cdf0e10cSrcweir             resData->sGId = attributeId;
198*cdf0e10cSrcweir             resData->sId = element->GetOldref();
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir             if ( PFormEntrys* entry = mergeData.GetPFormEntrys( resData ) )
201*cdf0e10cSrcweir             {
202*cdf0e10cSrcweir                 ByteString translation;
203*cdf0e10cSrcweir                 entry->GetText( translation, STRING_TYP_TEXT, lang, true );
204*cdf0e10cSrcweir     //            ByteString original = removeContent( element );
205*cdf0e10cSrcweir                 if ( !translation.Len() )
206*cdf0e10cSrcweir #if 0
207*cdf0e10cSrcweir                     translation = original;
208*cdf0e10cSrcweir #else
209*cdf0e10cSrcweir                     translation = BSTRING( ( *i )->GetValue() );
210*cdf0e10cSrcweir #endif
211*cdf0e10cSrcweir                 delete translateAttribute( attributes, **i , STRING( translation ) );
212*cdf0e10cSrcweir             }
213*cdf0e10cSrcweir         }
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir }
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir static bool is_dir( ByteString const& name )
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     DirectoryItem aItem;
220*cdf0e10cSrcweir     OUString sFileURL( name.GetBuffer(), name.Len(), RTL_TEXTENCODING_UTF8 );
221*cdf0e10cSrcweir     FileBase::getFileURLFromSystemPath( sFileURL, sFileURL );
222*cdf0e10cSrcweir     if( DirectoryItem::get( sFileURL, aItem ) == FileBase::E_None )
223*cdf0e10cSrcweir     {
224*cdf0e10cSrcweir         FileStatus aStatus(FileStatusMask_Type);
225*cdf0e10cSrcweir         if( aItem.getFileStatus( aStatus ) == FileBase::E_None )
226*cdf0e10cSrcweir         {
227*cdf0e10cSrcweir             if( aStatus.getFileType() == FileStatus::Directory )
228*cdf0e10cSrcweir                 return true;
229*cdf0e10cSrcweir         }
230*cdf0e10cSrcweir     }
231*cdf0e10cSrcweir     return false;
232*cdf0e10cSrcweir }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir static void make_directory( ByteString const& name )
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir     OUString sFileURL( name.GetBuffer(), name.Len(), RTL_TEXTENCODING_UTF8 );
237*cdf0e10cSrcweir     FileBase::getFileURLFromSystemPath( sFileURL, sFileURL );
238*cdf0e10cSrcweir     Directory::create( sFileURL );
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir static void insertMarker( XMLParentNode *p, ByteString const& file )
242*cdf0e10cSrcweir {
243*cdf0e10cSrcweir     if ( XMLChildNodeList* lst = p->GetChildList() )
244*cdf0e10cSrcweir         if ( lst->Count() )
245*cdf0e10cSrcweir         {
246*cdf0e10cSrcweir             sal_uLong i = 1;
247*cdf0e10cSrcweir             // Skip newline, if possible.
248*cdf0e10cSrcweir             if ( lst->Count() > 1
249*cdf0e10cSrcweir                  && lst->GetObject( 2 )->GetNodeType() == XML_NODE_TYPE_DEFAULT )
250*cdf0e10cSrcweir                 i++;
251*cdf0e10cSrcweir             OUString marker = OUString::createFromAscii( "\n    NOTE: This file has been generated automagically by transex3/layout/tralay,\n          from source template: " )
252*cdf0e10cSrcweir                 + STRING( file )
253*cdf0e10cSrcweir                 + OUString::createFromAscii( ".\n          Do not edit, changes will be lost.\n" );
254*cdf0e10cSrcweir             lst->Insert( new XMLComment( marker, 0 ), i );
255*cdf0e10cSrcweir         }
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir void TranslateLayout::MergeLanguage( ByteString const& language )
259*cdf0e10cSrcweir {
260*cdf0e10cSrcweir     ByteString xmlFile = mFiles.front();
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir     MergeDataFile mergeData( mLocalize, xmlFile,
263*cdf0e10cSrcweir                              sal_False, RTL_TEXTENCODING_MS_1252 );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir     DirEntry aFile( xmlFile );
266*cdf0e10cSrcweir     SimpleXMLParser aParser;
267*cdf0e10cSrcweir     LayoutXMLFile* layoutXml = new LayoutXMLFile( mMergeMode );
268*cdf0e10cSrcweir     if ( !aParser.Execute( aFile.GetFull() , STRING( xmlFile ), layoutXml ) )
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir         fprintf(stderr, "error: parsing: %s\n", xmlFile.GetBuffer() );
271*cdf0e10cSrcweir         return;
272*cdf0e10cSrcweir     }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     layoutXml->Extract();
275*cdf0e10cSrcweir     insertMarker( layoutXml, xmlFile );
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir     ResData resData( "", "", "" );
278*cdf0e10cSrcweir     resData.sResTyp = mProject; /* mGid1 ?? */
279*cdf0e10cSrcweir     resData.sFilename = xmlFile;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     XMLHashMap* xmlStrings = layoutXml->GetStrings();
282*cdf0e10cSrcweir     for ( XMLHashMap::iterator i = xmlStrings->begin(); i != xmlStrings->end();
283*cdf0e10cSrcweir           ++i )
284*cdf0e10cSrcweir     {
285*cdf0e10cSrcweir         if ( LangHashMap* languageMap = i->second )
286*cdf0e10cSrcweir             if ( XMLElement* element = ( *languageMap )[ "en-US" ] )
287*cdf0e10cSrcweir                 translateElement( element, language, &resData, mergeData );
288*cdf0e10cSrcweir     }
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir #ifndef WNT
291*cdf0e10cSrcweir     ByteString outFile = "/dev/stdout";
292*cdf0e10cSrcweir #else
293*cdf0e10cSrcweir     ByteString outFile = "\\\\.\\CON";
294*cdf0e10cSrcweir #endif
295*cdf0e10cSrcweir     if ( mOutput.Len() )
296*cdf0e10cSrcweir     {
297*cdf0e10cSrcweir         outFile = mOutput;
298*cdf0e10cSrcweir         if ( is_dir( outFile ) )
299*cdf0e10cSrcweir         {
300*cdf0e10cSrcweir             ByteString outDir = mOutput;
301*cdf0e10cSrcweir             outDir.Append( "/" ).Append( language );
302*cdf0e10cSrcweir             if ( !is_dir( outDir ) )
303*cdf0e10cSrcweir                 make_directory( outDir );
304*cdf0e10cSrcweir             outFile = outDir;
305*cdf0e10cSrcweir             outFile.Append( "/" ).Append( xmlFile );
306*cdf0e10cSrcweir         }
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir     layoutXml->Write( outFile );
309*cdf0e10cSrcweir     delete layoutXml;
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir void TranslateLayout::Merge()
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     if ( mLanguages.size() )
315*cdf0e10cSrcweir         for ( std::vector<ByteString>::iterator i = mLanguages.begin();
316*cdf0e10cSrcweir               i != mLanguages.end(); ++i)
317*cdf0e10cSrcweir             MergeLanguage( *i );
318*cdf0e10cSrcweir     else
319*cdf0e10cSrcweir         MergeLanguage( mLanguage );
320*cdf0e10cSrcweir }
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir void TranslateLayout::CreateSDF()
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir     ByteString xmlFile = mFiles.front();
325*cdf0e10cSrcweir #ifndef WNT
326*cdf0e10cSrcweir     ByteString sdf = "/dev/stdout";
327*cdf0e10cSrcweir #else
328*cdf0e10cSrcweir     ByteString sdf = "\\\\.\\CON";
329*cdf0e10cSrcweir #endif
330*cdf0e10cSrcweir     if ( mOutput.Len() )
331*cdf0e10cSrcweir         sdf = mOutput;
332*cdf0e10cSrcweir     Export::SetLanguages( mLanguages );
333*cdf0e10cSrcweir     HelpParser::CreateSDF( sdf, mProject, mRoot, xmlFile,
334*cdf0e10cSrcweir                            new LayoutXMLFile( mMergeMode ), mGid1 );
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir void TranslateLayout::ExceptionalMain()
338*cdf0e10cSrcweir {
339*cdf0e10cSrcweir     ParseCommandLine();
340*cdf0e10cSrcweir     if ( mLanguages.size() )
341*cdf0e10cSrcweir         mLanguage = mLanguages.front();
342*cdf0e10cSrcweir     if ( mMergeMode )
343*cdf0e10cSrcweir         Merge();
344*cdf0e10cSrcweir     else
345*cdf0e10cSrcweir         CreateSDF();
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir void TranslateLayout::Main()
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     try
351*cdf0e10cSrcweir     {
352*cdf0e10cSrcweir         ExceptionalMain();
353*cdf0e10cSrcweir     }
354*cdf0e10cSrcweir     catch ( xml::sax::SAXException& rExc )
355*cdf0e10cSrcweir     {
356*cdf0e10cSrcweir         OString aStr( OUStringToOString( rExc.Message,
357*cdf0e10cSrcweir                                          RTL_TEXTENCODING_ASCII_US ) );
358*cdf0e10cSrcweir         uno::Exception exc;
359*cdf0e10cSrcweir         if (rExc.WrappedException >>= exc)
360*cdf0e10cSrcweir         {
361*cdf0e10cSrcweir             aStr += OString( " >>> " );
362*cdf0e10cSrcweir             aStr += OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US );
363*cdf0e10cSrcweir         }
364*cdf0e10cSrcweir         fprintf( stderr, "error: parsing: '%s'\n", aStr.getStr() );
365*cdf0e10cSrcweir         OSL_ENSURE( 0, aStr.getStr() );
366*cdf0e10cSrcweir     }
367*cdf0e10cSrcweir     catch ( uno::Exception& rExc )
368*cdf0e10cSrcweir     {
369*cdf0e10cSrcweir         OString aStr( OUStringToOString( rExc.Message,
370*cdf0e10cSrcweir                                          RTL_TEXTENCODING_ASCII_US ) );
371*cdf0e10cSrcweir         fprintf( stderr, "error: UNO: '%s'\n", aStr.getStr() );
372*cdf0e10cSrcweir         OSL_ENSURE( 0, aStr.getStr() );
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir TranslateLayout::TranslateLayout()
377*cdf0e10cSrcweir     : Application()
378*cdf0e10cSrcweir     , mGid1( "layout" )
379*cdf0e10cSrcweir     , mLanguage( "en-US" )
380*cdf0e10cSrcweir     , mLocalize( "localize.sdf" )
381*cdf0e10cSrcweir     , mOutput()
382*cdf0e10cSrcweir     , mProject( "layout" )
383*cdf0e10cSrcweir     , mRoot()
384*cdf0e10cSrcweir     , mMergeMode( false )
385*cdf0e10cSrcweir     , mLanguages()
386*cdf0e10cSrcweir     , mFiles()
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir TranslateLayout::~TranslateLayout()
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
395*cdf0e10cSrcweir {
396*cdf0e10cSrcweir     TranslateLayout t;
397*cdf0e10cSrcweir     t.Main();
398*cdf0e10cSrcweir     return 0;
399*cdf0e10cSrcweir }
400