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

@@ -10,6 +10,22 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
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
2013-03-31 22:01 UTC+0200 Viktor Szakats (harbour syenar.net)
* .gitignore
* better rules to exclude lib subdir

View File

@@ -1403,6 +1403,7 @@ DYNAMIC __i18n_hashTable
DYNAMIC __i18n_potArrayJoin
DYNAMIC __i18n_potArrayLoad
DYNAMIC __i18n_potArraySave
DYNAMIC __i18n_potArraySort
DYNAMIC __i18n_potArrayToHash
DYNAMIC __i18n_potArrayTrans
DYNAMIC __Input

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

View File

@@ -31,10 +31,14 @@ PROCEDURE Main( cLogin )
FClose( hb_FTempCreateEx( @cTemp, , , ".pot" ) )
FClose( hb_FTempCreateEx( @cTemp2 ) )
? "generating pot"
? "generating .pot"
hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 %1$s -j%2$s -s", cMain, cTemp ) )
? "sorting .pot"
POT_Sort( cTemp )
? "saving locally"
cContent := hb_StrFormat( ;
@@ -78,3 +82,17 @@ STATIC FUNCTION GetJSON( cString )
cString := Left( cString, RAt( "}", cString ) )
RETURN cString
STATIC FUNCTION POT_Sort( cFileName )
LOCAL aTrans
LOCAL cErrorMsg
IF ( aTrans := __i18n_potArrayLoad( cFileName, @cErrorMsg ) ) != NIL .AND. ;
__i18n_potArraySave( cFileName, __i18n_potArraySort( aTrans ), @cErrorMsg )
RETURN .T.
ENDIF
? cErrorMsg
RETURN .F.

View File

@@ -15896,21 +15896,19 @@ STATIC PROCEDURE ShowHelp( hbmk, lMore, lLong )
{ "-longhelp" , I_( "long help" ) }, ;
{ "-longhelpmd" , I_( "long help in Markdown format" ) } }
/* Internal option descriptions intentionally not marked as translatable */
LOCAL aHdr_Opt_Internal := { ;
"", ;
"Options below are internal/developer ones (compatibility not guaranteed):" }
I_( "Options below are internal/developer ones (compatibility not guaranteed):" ) }
/* Internal option descriptions intentionally not marked as translatable */
LOCAL aLst_Opt_Internal := { ;
NIL, ;
{ "-debugtime" , "measure time spent on the build" }, ;
{ "-debuginc" , "display internals of incremental build" }, ;
{ "-debugstub" , "display content of all internally generated source files" }, ;
{ "-debugi18n" , "display internals on translation file generation" }, ;
{ "-debugdepd" , "display internals of dependency detection" }, ;
{ "-debugpars" , "display all input parameters in processing order" }, ;
{ "-debugrte" , "generate a run-time error" } }
{ "-debugtime" , I_( "measure time spent on the build" ) }, ;
{ "-debuginc" , I_( "display internals of incremental build" ) }, ;
{ "-debugstub" , I_( "display content of all internally generated source files" ) }, ;
{ "-debugi18n" , I_( "display internals on translation file generation" ) }, ;
{ "-debugdepd" , I_( "display internals of dependency detection" ) }, ;
{ "-debugpars" , I_( "display all input parameters in processing order" ) }, ;
{ "-debugrte" , I_( "generate a run-time error" ) } }
LOCAL aHdr_Opt_Self := { ;
NIL, ;