2013-03-31 22:52 UTC+0200 Viktor Szakats (harbour syenar.net)

* include/harbour.hbx
  * src/rtl/hbi18n2.prg
    + added __i18n_potArraySort( aTrans ) -> aTrans
      to sort .pot files to a predictable order (of first
      occurrence in file). It helps reducing unnecessarily
      large and unusable diffs when updating .pots and their
      related .po files

  * utils/hbmk2/hbmk2.prg
    * marked some string previously (and intentionally) marked
      as non-translatable, as translatable. One exception less.

  * utils/hbmk2/_po_push.hb
    + sort .pot before saving and pushing to localization service
This commit is contained in:
Viktor Szakats
2013-03-31 22:55:32 +02:00
parent 0fe9afaf16
commit 4f1db3a0b0
5 changed files with 68 additions and 13 deletions

View File

@@ -292,7 +292,7 @@ FUNCTION __i18n_potArrayLoad( cFile, cErrorMsg )
RETURN aTrans
STATIC FUNCTION IsBOM_UTF8( cFileName )
STATIC FUNCTION __i18n_IsBOM_UTF8( cFileName )
LOCAL fhnd := FOpen( cFileName, FO_READ )
LOCAL cBuffer
@@ -310,6 +310,28 @@ STATIC FUNCTION IsBOM_UTF8( cFileName )
RETURN .F.
FUNCTION __i18n_potArraySort( aTrans )
ASort( aTrans,,, {| item1, item2 | __i18n_ItemToStr( item1 ) < __i18n_ItemToStr( item2 ) } )
RETURN aTrans
STATIC FUNCTION __i18n_ItemToStr( item )
LOCAL cSource := item[ _I18N_SOURCE ]
LOCAL tmp
/* first source occurrence */
IF ( tmp := At( " ", cSource ) ) > 0
cSource := Left( cSource, tmp - 1 )
ENDIF
IF ( tmp := RAt( ":", cSource ) ) > 0
cSource := Left( cSource, tmp - 1 ) + Str( Val( SubStr( cSource, tmp + 1 ) ), 10, 0 )
ENDIF
RETURN cSource + Left( item[ _I18N_MSGID, 1 ], 30 )
FUNCTION __i18n_potArraySave( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef )
LOCAL aItem
@@ -324,7 +346,7 @@ FUNCTION __i18n_potArraySave( cFile, aTrans, cErrorMsg, lVersionNo, lSourceRef )
lRet := .F.
cEol := hb_eol()
cFlg := "#, c-format" + cEol
cPOT := iif( hb_FileExists( cFile ) .AND. IsBOM_UTF8( cFile ), _UTF8_BOM + cEol, "" ) + ; /* Put it in separate line to less confuse non-BOM aware parsers */
cPOT := iif( hb_FileExists( cFile ) .AND. __i18n_IsBOM_UTF8( cFile ), _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