diff options
author | Andras Timar <atimar@suse.com> | 2011-11-08 18:50:58 +0100 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2011-11-08 22:37:13 +0100 |
commit | 182913a18c01b945e27246a6ace4e5104bccd9c0 (patch) | |
tree | ec83ea57aa376f7a07860de04ff8d18471c02aae /l10ntools | |
parent | 00b2e13d2c7378577e77e1a1107601651735486e (diff) |
code cleanup of localize tool
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/inc/srciter.hxx | 3 | ||||
-rw-r--r-- | l10ntools/source/localize.cxx | 139 | ||||
-rw-r--r-- | l10ntools/source/srciter.cxx | 10 |
3 files changed, 24 insertions, 128 deletions
diff --git a/l10ntools/inc/srciter.hxx b/l10ntools/inc/srciter.hxx index c859d2356c1a..5a1db39739bc 100644 --- a/l10ntools/inc/srciter.hxx +++ b/l10ntools/inc/srciter.hxx @@ -43,11 +43,10 @@ private: void ExecuteDirectory( transex::Directory& pDirectory ); protected: - bool bLocal; bool bSkipLinks; public: - SourceTreeIterator( const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in = false); + SourceTreeIterator( const ByteString &rRootDirectory, const ByteString &rVersion ); virtual ~SourceTreeIterator(); sal_Bool StartExecute(); diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 8e0a370eaa53..609e344a9ade 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -172,7 +172,6 @@ const char DLIST_NAME[] = "d.lst"; #define LOCALIZE_NONE 0x0000 #define LOCALIZE_EXTRACT 0x0001 -#define LOCALIZE_MERGE 0x0002 class SourceTreeLocalizer : public SourceTreeIterator { @@ -208,11 +207,9 @@ private: ); void WorkOnDirectory( const ByteString &rDirectory ); public: - SourceTreeLocalizer( const ByteString &rRoot, const ByteString &rVersion , bool bLocal , bool skip_links ); + SourceTreeLocalizer( const ByteString &rRoot, const ByteString &rVersion , bool skip_links ); ~SourceTreeLocalizer(); - ByteString getSourceLanguages( ByteString sLanguageRestriction , ByteString sCommand ); - void SetLanguageRestriction( const ByteString& rRestrictions ) { sLanguageRestriction = rRestrictions; } int getFileCnt(); @@ -223,9 +220,9 @@ public: /*****************************************************************************/ SourceTreeLocalizer::SourceTreeLocalizer( - const ByteString &rRoot, const ByteString &rVersion, bool bLocal_in , bool skip_links ) + const ByteString &rRoot, const ByteString &rVersion, bool skip_links ) /*****************************************************************************/ - : SourceTreeIterator( rRoot, rVersion , bLocal_in ), + : SourceTreeIterator( rRoot, rVersion ), nMode( LOCALIZE_NONE ), nFileCnt( 0 ) { @@ -368,7 +365,7 @@ void SourceTreeLocalizer::WorkOnFile( sCommand += sTempFile; if ( sLanguageRestriction.Len()) { sCommand += " -l "; - sCommand += getSourceLanguages( sLanguageRestriction , sCommand ); + sCommand += sLanguageRestriction; } //printf("DBG: %s\n",sCommand.GetBuffer()); @@ -393,18 +390,6 @@ void SourceTreeLocalizer::WorkOnFile( aOldCWD.SetCWD(); } -ByteString SourceTreeLocalizer::getSourceLanguages( ByteString sLanguageRestriction_inout , ByteString sCommand ) -{ - // Source languages in helpcontent2 and macromigration en-US only! - if( sCommand.Search("helpex") != STRING_NOTFOUND ) { - sLanguageRestriction_inout.Assign( ByteString("en-US") ); - } - else if( sCommand.Search("xmlex") != STRING_NOTFOUND ){ - sLanguageRestriction_inout.Assign( ByteString("en-US") ); - } - return sLanguageRestriction_inout; -} - /*****************************************************************************/ sal_Bool SourceTreeLocalizer::CheckNegativeList( const ByteString &rFileName ) /*****************************************************************************/ @@ -559,14 +544,6 @@ sal_Bool SourceTreeLocalizer::Extract( const ByteString &rDestinationFile ) } using namespace transex3; -#define STATE_NONE 0x0000 -#define STATE_EXPORT 0x0001 -#define STATE_MERGE 0x0002 -#define STATE_ISOCODE 0x0003 -#define STATE_LANGUAGES 0x0004 -#define STATE_FILENAME 0x0005 -#define STATE_OUTPUT 0x0006 - /*****************************************************************************/ void Help() /*****************************************************************************/ @@ -575,23 +552,12 @@ void Help() "localize (c)2001 by Sun Microsystems\n" "====================================\n" ); fprintf( stdout, - "As part of the L10N framework, localize extracts and merges translations\n" - "out of and into the toplevel modules defined in ModuleList array in\n" + "As part of the L10N framework, localize extracts en-US strings for\n" + "translation out of the toplevel modules defined in ModuleList array in\n" "l10ntools/source/localize.cxx.\n\n" - "Syntax: localize -e -l en-US -f FileName \n" + "Syntax: localize -f FileName \n" "Parameter:\n" - "\t-e: Extract mode\n" - "\tFileName: Output file when extract mode, input file when merge mode\n" - "\tl1...ln: supported languages (\"all\" for all languages).\n" - ); - - fprintf( stdout, - "Valid language codes for l1...ln and f1...fn are:\n" ); - fprintf( stdout, - "\nExample 1:\n" - "==========\n" - "localize -e -l en-US -f MyFile\n\n" - "All strings will be extracted for language en-US.\n" + "\tFileName: Output file\n" ); } @@ -604,14 +570,6 @@ int Error() } /*****************************************************************************/ -sal_Bool CheckLanguages( ByteString &rLanguages ) -/*****************************************************************************/ -{ - ByteString sTmp( rLanguages ); - return true; -} - -/*****************************************************************************/ #if defined(UNX) int main( int argc, char *argv[] ) #else @@ -621,101 +579,42 @@ int _cdecl main( int argc, char *argv[] ) { String sTempBase( String::CreateFromAscii( "loc" )); DirEntry::SetTempNameBase( sTempBase ); - sal_uInt16 nState = STATE_NONE; - sal_Bool bExport = sal_False; - sal_Bool bMerge = sal_False; bool bSkipLinks = false; ByteString sLanguages; ByteString sFileName; - ByteString sOutput; - bExport = sal_True; + sLanguages = ByteString( "en-US" ); - for( int i = 1; i < argc; i++ ) { - ByteString sSwitch( argv[ i ] ); - sSwitch.ToUpperAscii(); + ByteString sSwitch( argv[ 1 ] ); + sSwitch.ToUpperAscii(); - if ( sSwitch.Equals( "-E" )) { - nState = STATE_EXPORT; - if ( bMerge ) - return Error(); - bExport = sal_True; - } - else if ( sSwitch.Equals( "-I" ) ) - nState = STATE_ISOCODE; - else if ( sSwitch.Equals( "-L" ) ) - nState = STATE_LANGUAGES; - else if ( sSwitch.Equals( "-F" ) ) - nState = STATE_FILENAME; - else if ( ByteString( argv[ i ]).ToUpperAscii().Equals( "-O" ) ) - nState = STATE_OUTPUT; - else { - switch ( nState ) { - case STATE_NONE: - return Error(); - case STATE_OUTPUT: - if ( sOutput.Len()) - return Error(); - sOutput = ByteString( argv[ i ] ); - nState = STATE_NONE; - break; - case STATE_LANGUAGES: - if ( sLanguages.Len()) - return Error(); - sLanguages = ByteString( argv[ i ] ); - nState = STATE_NONE; - break; - case STATE_FILENAME: - if ( sFileName.Len()) - return Error(); - sFileName = ByteString( argv[ i ] ); - nState = STATE_NONE; - break; - default: - return Error(); - } - } - } - if ( !bMerge && !bExport ) { - Help(); - return 1; - } + if ( ( argc == 3 ) && sSwitch.Equals( "-F" ) ) + sFileName = ByteString( argv[ 2 ] ); + else + return Error(); - ByteString sSolarVer( Export::GetEnv( "WORK_STAMP" )); ByteString sVersion( Export::GetEnv( "WORK_STAMP" )); - if ( !sSolarVer.Len() || !sVersion.Len()) { + if ( !sVersion.Len() ) { fprintf( stderr, "ERROR: No environment set!\n" ); return 1; } - if ( !CheckLanguages( sLanguages )) - return 2; - - if ( !sFileName.Len()) { - fprintf( stderr, "ERROR: No filename given\n" ); - return 3; - } - DirEntry aEntry( String( sFileName , RTL_TEXTENCODING_ASCII_US )); aEntry.ToAbs(); String sFullEntry = aEntry.GetFull(); ByteString sFileABS(aEntry.GetFull(), osl_getThreadTextEncoding()); - //printf("B %s\nA %s\n",rDestinationFile.GetBuffer(), sFile.GetBuffer()); sFileName = sFileABS; string pwd; Export::getCurrentDir( pwd ); cout << "Localizing directory " << pwd << "\n"; - SourceTreeLocalizer aIter( ByteString( pwd.c_str() ) , sVersion , (sOutput.Len() > 0) , bSkipLinks ); + SourceTreeLocalizer aIter( ByteString( pwd.c_str() ) , sVersion , bSkipLinks ); aIter.SetLanguageRestriction( sLanguages ); - if ( bExport ){ - fflush( stdout ); - aIter.Extract( sFileName ); - printf("\n%d files found!\n",aIter.GetFileCnt()); - } + aIter.Extract( sFileName ); + printf("\n%d files found!\n",aIter.GetFileCnt()); return 0; } diff --git a/l10ntools/source/srciter.cxx b/l10ntools/source/srciter.cxx index 6a16d92d0227..dfd27f458de8 100644 --- a/l10ntools/source/srciter.cxx +++ b/l10ntools/source/srciter.cxx @@ -39,16 +39,14 @@ /*****************************************************************************/ SourceTreeIterator::SourceTreeIterator( - const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in ) + const ByteString &rRootDirectory, const ByteString &rVersion ) /*****************************************************************************/ - : bInExecute( sal_False ) , bLocal( bLocal_in ) + : bInExecute( sal_False ) { (void) rVersion ; - if(!bLocal){ - rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 ); - aRootDirectory = transex::Directory( sRootDirectory ); - } + rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 ); + aRootDirectory = transex::Directory( sRootDirectory ); } /*****************************************************************************/ |