2010-08-27 00:40 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* src/rtl/hbi18n2.prg
    + __I18N_POTARRAYSAVE(): new lUTF8BOM parameter.

  * utils/hbmk2/hbmk2.prg
    + Retain UTF8 BOM in .po files.
This commit is contained in:
Viktor Szakats
2010-08-26 22:41:55 +00:00
parent ee5450a5fb
commit 79abf55913
3 changed files with 36 additions and 5 deletions

View File

@@ -16,6 +16,13 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-08-27 00:40 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/hbi18n2.prg
+ __I18N_POTARRAYSAVE(): new lUTF8BOM parameter.
* utils/hbmk2/hbmk2.prg
+ Retain UTF8 BOM in .po files.
2010-08-27 00:01 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/contrib/sddodbc/tests/test2.prg
! reverted accidentally changed file in last commit

View File

@@ -98,6 +98,7 @@ STATIC FUNCTION __I18N_strDecode( cLine, cValue, lCont )
RETURN lRet
#define _UTF8_BOM e"\xEF\xBB\xBF"
FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
LOCAL cLine, cValue
@@ -121,8 +122,8 @@ FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
RETURN NIL
ENDIF
/* Strip UTF-8 BOM */
IF Left( cValue, 3 ) == e"\xEF\xBB\xBF"
cValue := SubStr( cValue, 4 )
IF Left( cValue, Len( _UTF8_BOM ) ) == _UTF8_BOM
cValue := SubStr( cValue, Len( _UTF8_BOM ) + 1 )
ENDIF
IF !hb_eol() == _I18N_EOL
cValue := strtran( cValue, hb_eol(), _I18N_EOL )
@@ -298,7 +299,7 @@ FUNCTION __I18N_POTARRAYLOAD( cFile, cErrorMsg )
RETURN aTrans
FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef )
FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef, lUTF8BOM )
LOCAL aItem
LOCAL hFile
LOCAL lRet, lPlural
@@ -311,11 +312,15 @@ FUNCTION __I18N_POTARRAYSAVE( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef )
IF ! ISLOGICAL( lSourceRef )
lSourceRef := .T.
ENDIF
IF ! ISLOGICAL( lUTF8BOM )
lUTF8BOM := .T.
ENDIF
lRet := .F.
cEol := hb_eol()
cFlg := "#, c-format" + cEol
cPOT := "#" + cEol + ;
cPOT := iif( lUTF8BOM, _UTF8_BOM + cEol, "" ) + ; /* Put it in separate line to less confuse non-BOM aware parsers */
"#" + cEol + ;
"# This file is generated by " + iif( lVersionNo, hb_version(), "Harbour" ) + cEol + ;
"#" + cEol
FOR EACH aItem IN aTrans

View File

@@ -10164,9 +10164,11 @@ STATIC PROCEDURE POTMerge( hbmk, aFiles, cFileBase, cFileOut )
STATIC PROCEDURE AutoTrans( hbmk, cFileIn, aFiles, cFileOut )
LOCAL cErrorMsg
LOCAL lUTF8BOM := IsBOM_UTF8( cFileOut )
IF ! __i18n_potArraySave( cFileOut, ;
__i18n_potArrayTrans( LoadPOTFiles( hbmk, {}, cFileIn, .F. ), ;
LoadPOTFilesAsHash( hbmk, aFiles ) ), @cErrorMsg, ! hbmk[ _HBMK_lMINIPO ], ! hbmk[ _HBMK_lMINIPO ] )
LoadPOTFilesAsHash( hbmk, aFiles ) ), @cErrorMsg, ! hbmk[ _HBMK_lMINIPO ], ! hbmk[ _HBMK_lMINIPO ], lUTF8BOM )
hbmk_OutErr( hbmk, hb_StrFormat( I_( "Error: %1$s" ), cErrorMsg ) )
ENDIF
@@ -10190,6 +10192,23 @@ STATIC FUNCTION GenHBL( hbmk, aFiles, cFileOut, lEmpty )
RETURN lRetVal
#define _UTF8_BOM e"\xEF\xBB\xBF"
STATIC FUNCTION IsBOM_UTF8( cFileName )
LOCAL fhnd := FOpen( cFileName, FO_READ )
LOCAL cBuffer
IF fhnd != F_ERROR
cBuffer := Space( Len( _UTF8_BOM ) )
FRead( fhnd, @cBuffer, Len( cBuffer ) )
FClose( fhnd )
IF cBuffer == _UTF8_BOM
RETURN .T.
ENDIF
ENDIF
RETURN .F.
STATIC FUNCTION win_implib_command( hbmk, cCommand, cSourceDLL, cTargetLib, cFlags )
IF ! hb_FileExists( cSourceDLL )