2013-03-31 15:15 UTC+0200 Viktor Szakats (harbour syenar.net)
* utils/hbmk2/_md_make.hb
* utils/hbmk2/_po_pull.hb
* utils/hbmk2/_po_push.hb
+ internals almost fully generalized
+ convert Transifex newline symbol to real newline
* utils/hbmk2/hbmk2.prg
+ AllTrim() some translated text to avoid bad Markdown result
when translated text contains left/right padding.
TODO: double spaces in translated text and extend above
to all strings, and move the whole post-processing/fixing
to the po pull stage. Would be nice to have a core i18n
function to be able to apply transformations via codeblock
to translated text.
This commit is contained in:
committed by
Viktor Szakats
parent
626b68ad19
commit
ab064dee76
@@ -10,6 +10,22 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2013-03-31 15:15 UTC+0200 Viktor Szakats (harbour syenar.net)
|
||||
* utils/hbmk2/_md_make.hb
|
||||
* utils/hbmk2/_po_pull.hb
|
||||
* utils/hbmk2/_po_push.hb
|
||||
+ internals almost fully generalized
|
||||
+ convert Transifex newline symbol to real newline
|
||||
|
||||
* utils/hbmk2/hbmk2.prg
|
||||
+ AllTrim() some translated text to avoid bad Markdown result
|
||||
when translated text contains left/right padding.
|
||||
TODO: double spaces in translated text and extend above
|
||||
to all strings, and move the whole post-processing/fixing
|
||||
to the po pull stage. Would be nice to have a core i18n
|
||||
function to be able to apply transformations via codeblock
|
||||
to translated text.
|
||||
|
||||
2013-03-31 04:46 UTC+0200 Viktor Szakats (harbour syenar.net)
|
||||
* utils/hbmk2/_md_make.hb
|
||||
* utils/hbmk2/_po_pull.hb
|
||||
|
||||
@@ -20,6 +20,8 @@ PROCEDURE Main()
|
||||
LOCAL cLang
|
||||
LOCAL cTemp
|
||||
|
||||
LOCAL cMain := cBase + "hbmk2.prg"
|
||||
|
||||
? "preparing"
|
||||
|
||||
FOR EACH file IN Directory( cBase + hb_DirSepToOS( "po/*.po" ) )
|
||||
@@ -28,21 +30,21 @@ PROCEDURE Main()
|
||||
cBase + hb_DirSepToOS( "po/" + file[ F_NAME ] ) ) )
|
||||
NEXT
|
||||
|
||||
cTemp := cBase + "hbmk2.hrb"
|
||||
cTemp := hb_FNameExtSet( cMain, ".hrb" )
|
||||
|
||||
hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 -gh %1$s -o%2$s", cBase + "hbmk2.prg", cTemp ) )
|
||||
hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 -gh %1$s -o%2$s", cMain, cTemp ) )
|
||||
|
||||
? "generating .md help:"
|
||||
|
||||
FOR EACH cLang IN hb_ATokens( "en," + hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( cBase + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," )
|
||||
FOR EACH cLang IN hb_ATokens( "en," + hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( hb_FNameExtSet( cMain, ".hbp" ) ),,,,, .T. )[ 1 ][ 2 ], "," )
|
||||
|
||||
?? "", cLang
|
||||
|
||||
file := cBase + hb_DirSepToOS( "doc/hbmk2." + cLang + ".md" )
|
||||
file := cBase + hb_DirSepToOS( "doc/" + hb_FNameName( cMain ) + "." + cLang + ".md" )
|
||||
hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmd > %3$s", cTemp, cLang, file ) )
|
||||
FToNativeEOL( file )
|
||||
|
||||
file := cBase + hb_DirSepToOS( "../../contrib/hbrun/doc/hbrun." + cLang + ".md" )
|
||||
file := cBase + hb_DirSepToOS( "../../contrib/hbrun/doc/" + "hbrun" + "." + cLang + ".md" )
|
||||
hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmdsh > %3$s", cTemp, cLang, file ) )
|
||||
FToNativeEOL( file )
|
||||
NEXT
|
||||
|
||||
@@ -19,6 +19,8 @@ PROCEDURE Main( cLogin )
|
||||
LOCAL cLang
|
||||
LOCAL cTemp
|
||||
|
||||
LOCAL cMain := cBase + "hbmk2.prg"
|
||||
|
||||
IF Empty( cLogin )
|
||||
cLogin := GetEnv( "HB_TRANSIFEX_LOGIN" ) /* Format: username:password */
|
||||
ENDIF
|
||||
@@ -27,17 +29,17 @@ PROCEDURE Main( cLogin )
|
||||
|
||||
? "pulling .po files:"
|
||||
|
||||
FOR EACH cLang IN hb_ATokens( hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( cBase + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," )
|
||||
FOR EACH cLang IN hb_ATokens( hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( hb_FNameExtSet( cMain, ".hbp" ) ),,,,, .T. )[ 1 ][ 2 ], "," )
|
||||
|
||||
?? "", cLang
|
||||
|
||||
hb_run( hb_StrFormat( "curl -s -i -L --user %1$s -X " + ;
|
||||
"GET https://www.transifex.com/api/2/project/harbour/resource/hbmk2/translation/%2$s/ " + ;
|
||||
"-o %3$s", ;
|
||||
cLogin, cLang, cTemp ) )
|
||||
"GET https://www.transifex.com/api/2/project/harbour/resource/%2$s/translation/%3$s/ " + ;
|
||||
"-o %4$s", ;
|
||||
cLogin, hb_FNameName( cMain ), cLang, cTemp ) )
|
||||
|
||||
IF hb_jsonDecode( GetJSON( hb_MemoRead( cTemp ) ), @json ) > 0
|
||||
hb_MemoWrit( hb_DirSepToOS( cBase + "po/hbmk2." + cLang + ".po" ), StrTran( json[ "content" ], e"\n", hb_eol() ) )
|
||||
hb_MemoWrit( hb_DirSepToOS( cBase + "po/" + hb_FNameName( cMain ) + "." + cLang + ".po" ), DoctorContent( json[ "content" ] ) )
|
||||
ELSE
|
||||
? "API error"
|
||||
ENDIF
|
||||
@@ -47,6 +49,13 @@ PROCEDURE Main( cLogin )
|
||||
|
||||
RETURN
|
||||
|
||||
STATIC FUNCTION DoctorContent( cString )
|
||||
|
||||
cString := StrTran( cString, hb_UChar( 9166 ), "\n" ) /* convert RETURN SYMBOL used by Transifex for NEWLINE */
|
||||
cString := StrTran( cString, e"\n", hb_eol() )
|
||||
|
||||
RETURN cString
|
||||
|
||||
STATIC FUNCTION GetJSON( cString )
|
||||
|
||||
cString := SubStr( cString, At( "{", cString ) )
|
||||
|
||||
@@ -19,6 +19,8 @@ PROCEDURE Main( cLogin )
|
||||
LOCAL cTemp, cTemp2
|
||||
LOCAL cContent
|
||||
|
||||
LOCAL cMain := cBase + "hbmk2.prg"
|
||||
|
||||
IF Empty( cLogin )
|
||||
cLogin := GetEnv( "HB_TRANSIFEX_LOGIN" ) /* Format: username:password */
|
||||
ENDIF
|
||||
@@ -28,22 +30,23 @@ PROCEDURE Main( cLogin )
|
||||
|
||||
? "generating pot"
|
||||
|
||||
hb_run( hb_StrFormat( "harbour -q0 %1$s -j%2$s -i%3$s -s", cBase + "hbmk2.prg", cTemp, hb_DirSepToOS( cBase + "../../include" )) )
|
||||
hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 %1$s -j%2$s -s", cMain, cTemp ) )
|
||||
|
||||
? "saving locally"
|
||||
|
||||
cContent := ;
|
||||
cContent := hb_StrFormat( ;
|
||||
'#, c-format' + hb_eol() + ;
|
||||
'msgid ""' + hb_eol() + ;
|
||||
'msgstr ""' + hb_eol() + ;
|
||||
'"Project-Id-Version: hbmk2\n"' + hb_eol() + ;
|
||||
'"Project-Id-Version: %1$s\n"' + hb_eol() + ;
|
||||
'"Language: en\n"' + hb_eol() + ;
|
||||
'"MIME-Version: 1.0\n"' + hb_eol() + ;
|
||||
'"Content-Type: text/plain; charset=UTF-8\n"' + hb_eol() + ;
|
||||
'"Content-Transfer-Encoding: 8bit\n"' + hb_eol() + hb_eol() + ;
|
||||
'"Content-Transfer-Encoding: 8bit\n"', hb_FNameName( cMain ) ) + hb_eol() + ;
|
||||
hb_eol() + ;
|
||||
hb_MemoRead( cTemp )
|
||||
|
||||
hb_MemoWrit( hb_DirSepToOS( cBase + "po/hbmk2.en.po" ), cContent )
|
||||
hb_MemoWrit( hb_DirSepToOS( cBase + "po/" + hb_FNameName( cMain ) + ".en.po" ), cContent )
|
||||
|
||||
? "uploading", "size", Len( cContent )
|
||||
?
|
||||
@@ -52,9 +55,9 @@ PROCEDURE Main( cLogin )
|
||||
|
||||
hb_run( hb_StrFormat( 'curl -s -i -L --user %1$s -X ' + ;
|
||||
'PUT -d @%2$s -H "Content-Type: application/json" ' + ;
|
||||
'https://www.transifex.com/api/2/project/harbour/resource/hbmk2/content/' + ;
|
||||
' -o %3$s', ;
|
||||
cLogin, cTemp, cTemp2 ) )
|
||||
'https://www.transifex.com/api/2/project/harbour/resource/%3$s/content/' + ;
|
||||
' -o %4$s', ;
|
||||
cLogin, cTemp, hb_FNameName( cMain ), cTemp2 ) )
|
||||
|
||||
IF hb_jsonDecode( GetJSON( hb_MemoRead( cTemp2 ) ), @json ) > 0
|
||||
? hb_ValToExp( json )
|
||||
|
||||
@@ -15582,10 +15582,10 @@ STATIC FUNCTION ToMarkdown( cText, cStyle )
|
||||
IF HB_ISSTRING( cStyle )
|
||||
SWITCH cStyle
|
||||
CASE "strong"
|
||||
cText := "**" + cText + "**"
|
||||
cText := "**" + AllTrim( cText ) + "**"
|
||||
EXIT
|
||||
CASE "url"
|
||||
cText := "<" + cText + ">"
|
||||
cText := "<" + AllTrim( cText ) + ">"
|
||||
EXIT
|
||||
ENDSWITCH
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user