diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 02e00f78eb..a7a02fa7ee 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-22 15:17 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/hbi18n2.prg + % create index using hash array to speedup __I18N_POTARRAYJOIN() + operation + 2009-04-22 14:35 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg * Finished to .pot support (changed po to pot). diff --git a/harbour/source/rtl/hbi18n2.prg b/harbour/source/rtl/hbi18n2.prg index 56f8d5ec9d..4b93d7a423 100644 --- a/harbour/source/rtl/hbi18n2.prg +++ b/harbour/source/rtl/hbi18n2.prg @@ -63,6 +63,8 @@ #define _I18N_ITEM { "", {}, {}, .F., NIL } #define _I18N_EOL chr( 10 ) +#define _I18N_DELIM ( chr( 0 ) + chr( 3 ) + chr( 0 ) ) + STATIC FUNCTION __I18N_fileName( cFile ) LOCAL cExt @@ -75,6 +77,7 @@ STATIC FUNCTION __I18N_fileName( cFile ) ENDIF RETURN cFile + STATIC FUNCTION __I18N_strEncode( cStr ) RETURN substr( hb_strToExp( cStr, .T. ), 2 ) @@ -390,17 +393,22 @@ FUNCTION __I18N_POTARRAYTOHASH( aTrans, lEmpty, hI18N ) FUNCTION __I18N_POTARRAYJOIN( aTrans, aTrans2 ) LOCAL aItem, aDest, aSrc - LOCAL ctx, msg - LOCAL n + LOCAL hIndex + LOCAL ctx + + hIndex := { => } + FOR EACH aItem in aTrans + ctx := aItem[ _I18N_CONTEXT ] + _I18N_DELIM + aItem[ _I18N_MSGID, 1 ] + hIndex[ ctx ] := aItem:__enumIndex() + NEXT FOR EACH aItem in aTrans2 - ctx := aItem[ _I18N_CONTEXT ] - msg := aItem[ _I18N_MSGID, 1 ] - IF ( n := ASCAN( aTrans, { |x| x[ _I18N_CONTEXT ] == ctx .AND. ; - x[ _I18N_MSGID, 1 ] == msg } ) ) == 0 + ctx := aItem[ _I18N_CONTEXT ] + _I18N_DELIM + aItem[ _I18N_MSGID, 1 ] + IF ! ctx $ hIndex AAdd( aTrans, AClone( aItem ) ) + hIndex[ ctx ] := Len( aTrans ) ELSE - aDest := aTrans[ n ] + aDest := aTrans[ hIndex[ ctx ] ] IF aItem[ _I18N_PLURAL ] aDest[ _I18N_PLURAL ] := .T. ENDIF @@ -428,6 +436,7 @@ FUNCTION __I18N_POTARRAYJOIN( aTrans, aTrans2 ) RETURN aTrans + FUNCTION HB_I18N_LOADPOT( cFile, pI18N, cErrorMsg ) LOCAL aTrans LOCAL hI18N