From e80dff8be7ffd0abbc217c2057064d02536f1a56 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 12 Nov 2012 14:03:47 +0000 Subject: [PATCH] 2012-11-12 15:02 UTC+0100 Viktor Szakats (harbour syenar.net) * utils/hbi18n/hbi18n.prg + converted UI strings to translatable ones % use core functions instead of FileExt() --- harbour/ChangeLog | 5 +++++ harbour/utils/hbi18n/hbi18n.prg | 39 +++++++++++++-------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 76eab9044c..15189b9e4f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-12 15:02 UTC+0100 Viktor Szakats (harbour syenar.net) + * utils/hbi18n/hbi18n.prg + + converted UI strings to translatable ones + % use core functions instead of FileExt() + 2012-11-12 14:08 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/include/hbexpra.c + added compile time error for GETs with complex macros diff --git a/harbour/utils/hbi18n/hbi18n.prg b/harbour/utils/hbi18n/hbi18n.prg index 609b30bd71..b44c3daee8 100644 --- a/harbour/utils/hbi18n/hbi18n.prg +++ b/harbour/utils/hbi18n/hbi18n.prg @@ -59,6 +59,8 @@ #define LEFTEQUAL( l, r ) ( Left( l, Len( r ) ) == r ) +#define I_( x ) hb_UTF8ToStr( hb_i18n_gettext( x ) ) + ANNOUNCE HB_GTSYS REQUEST HB_GT_CGI_DEFAULT @@ -171,7 +173,7 @@ STATIC PROCEDURE Logo() STATIC PROCEDURE Syntax() Logo() - OutStd( ; + OutStd( I_( ; "Syntax: hbi18n -m | -g | -a [-o] [-e] [-q] " + hb_eol() + ; hb_eol() + ; " -m merge given .pot files" + hb_eol() + ; @@ -182,11 +184,11 @@ STATIC PROCEDURE Syntax() " default is first .pot file name with" + hb_eol() + ; " .po (merge) or .hbl extension" + hb_eol() + ; " -e do not strip empty translation rules from .hbl files" + hb_eol() + ; - " -q quiet mode" + hb_eol() + ; + " -q quiet mode" + hb_eol() ) + ; hb_eol() ) IF hb_gtInfo( HB_GTI_ISGRAPHIC ) - OutStd( "Press any key to continue..." ) + OutStd( I_( "Press any key to continue..." ) ) Inkey( 0 ) ENDIF ErrorLevel( 1 ) @@ -194,26 +196,15 @@ STATIC PROCEDURE Syntax() STATIC PROCEDURE ErrorMsg( cErrorMsg ) - OutStd( "error: " + StrTran( cErrorMsg, ";", hb_eol() ) + hb_eol() ) + OutStd( hb_StrFormat( I_( "error: %1$s" ), StrTran( cErrorMsg, ";", hb_eol() ) ) + hb_eol() ) IF hb_gtInfo( HB_GTI_ISGRAPHIC ) - OutStd( "Press any key to continue..." ) + OutStd( I_( "Press any key to continue..." ) ) Inkey( 0 ) ENDIF ErrorLevel( 1 ) QUIT -STATIC FUNCTION FileExt( cFile, cDefExt, lForce ) - - LOCAL cPath, cName, cExt - - hb_FNameSplit( cFile, @cPath, @cName, @cExt ) - IF lForce .OR. Empty( cExt ) - cFile := hb_FNameMerge( cPath, cName, cDefExt ) - ENDIF - - RETURN cFile - STATIC FUNCTION ExpandWildCards( aFiles ) /* do not expand wild cards in environments where SHELL already does it. @@ -283,7 +274,7 @@ STATIC FUNCTION LoadFilesAsHash( aFiles ) IF Lower( cExt ) == ".hbl" cTrans := hb_MemoRead( aFiles[ n ] ) IF ! hb_i18n_Check( cTrans ) - ErrorMsg( "Wrong file format: " + aFiles[ n ] ) + ErrorMsg( hb_StrFormat( I_( "Wrong file format: %1$s" ), aFiles[ n ] ) ) ENDIF IF hTrans == NIL hTrans := __i18n_hashTable( hb_i18n_RestoreTable( cTrans ) ) @@ -306,9 +297,9 @@ STATIC PROCEDURE Merge( aFiles, cFileOut ) LOCAL cErrorMsg IF Empty( cFileOut ) - cFileOut := FileExt( aFiles[ 1 ], ".po", .T. ) + cFileOut := hb_FNameExtSet( aFiles[ 1 ], ".po" ) ELSE - cFileOut := FileExt( cFileOut, ".po", .F. ) + cFileOut := hb_FNameExtSetDef( cFileOut, ".po" ) ENDIF IF ! __i18n_potArraySave( cFileOut, LoadFiles( aFiles ), @cErrorMsg ) @@ -323,16 +314,16 @@ STATIC PROCEDURE GenHBL( aFiles, cFileOut, lEmpty ) LOCAL pI18N IF Empty( cFileOut ) - cFileOut := FileExt( aFiles[ 1 ], ".hbl", .T. ) + cFileOut := hb_FNameExtSet( aFiles[ 1 ], ".hbl" ) ELSE - cFileOut := FileExt( cFileOut, ".hbl", .F. ) + cFileOut := hb_FNameExtSetDef( cFileOut, ".hbl" ) ENDIF pI18N := __i18n_hashTable( __i18n_potArrayToHash( LoadFiles( aFiles ), ; lEmpty ) ) cHBLBody := hb_i18n_SaveTable( pI18N ) IF ! hb_MemoWrit( cFileOut, cHBLBody ) - ErrorMsg( "cannot create file: " + cFileOut ) + ErrorMsg( hb_StrFormat( I_( "cannot create file: %1$s" ), cFileOut ) ) ENDIF RETURN @@ -342,9 +333,9 @@ STATIC PROCEDURE AutoTrans( cFileIn, aFiles, cFileOut ) LOCAL cErrorMsg IF Empty( cFileOut ) - cFileOut := FileExt( cFileIn, ".po", .T. ) + cFileOut := hb_FNameExtSet( cFileIn, ".po" ) ELSE - cFileOut := FileExt( cFileOut, ".po", .F. ) + cFileOut := hb_FNameExtSetDef( cFileOut, ".po" ) ENDIF IF ! __i18n_potArraySave( cFileOut, ;