2013-04-02 22:09 UTC+0200 Viktor Szakats (harbour syenar.net)

* bin/check.hb
    + added file fixup feature (not yet activated)
    + refined detection of some problems

  * src/lang/l_de.c
  * src/lang/l_hu.c
  * src/lang/l_nl.c
  * src/lang/l_pl.c
    ! manual whitepsace/punctuation corrections

  * src/lang/l_el.c
    + manually applied translation from Transifex by Pete_wg
    * some manual whitepsace/punctuation corrections

  * src/rtl/langapi.c
    - deleted reference of unused and not needed RFC ID in language modules
    ; TODO: delete it from the language module string list

  * src/rtl/tgetlist.prg
    + handle the translation error where _GET_INSERT_OFF and _GET_INSERT_ON
      length doesn't match. Draw spaces instead of _GET_INSERT_OFF in that case

  * tests/lang2po.hb
  * tests/po2lang.hb
    + finalized two way .po <-> l_*.c file conversion
      (copyrights and RFC ID will be lost)
This commit is contained in:
Viktor Szakats
2013-04-02 22:14:28 +02:00
parent 4d4fceb53f
commit c0d88c42dc
11 changed files with 253 additions and 169 deletions

View File

@@ -10,6 +10,34 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2013-04-02 22:09 UTC+0200 Viktor Szakats (harbour syenar.net)
* bin/check.hb
+ added file fixup feature (not yet activated)
+ refined detection of some problems
* src/lang/l_de.c
* src/lang/l_hu.c
* src/lang/l_nl.c
* src/lang/l_pl.c
! manual whitepsace/punctuation corrections
* src/lang/l_el.c
+ manually applied translation from Transifex by Pete_wg
* some manual whitepsace/punctuation corrections
* src/rtl/langapi.c
- deleted reference of unused and not needed RFC ID in language modules
; TODO: delete it from the language module string list
* src/rtl/tgetlist.prg
+ handle the translation error where _GET_INSERT_OFF and _GET_INSERT_ON
length doesn't match. Draw spaces instead of _GET_INSERT_OFF in that case
* tests/lang2po.hb
* tests/po2lang.hb
+ finalized two way .po <-> l_*.c file conversion
(copyrights and RFC ID will be lost)
2013-04-02 17:49 UTC+0200 Viktor Szakats (harbour syenar.net)
+ bin/check.hb
+ new source verifier. Able to all documented (and more)

View File

@@ -24,6 +24,9 @@
*
*/
/* TODO: Apply transformations:
Uncrustify, hbformat, optipng, jpgclean, css/html/xml format, etc */
#pragma -w3
#pragma -km+
#pragma -ko+
@@ -60,12 +63,15 @@ FUNCTION CheckFileList( xName )
RETURN lPassed
STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
STATIC FUNCTION CheckFile( cName, /* @ */ aErr, lApplyFixes )
LOCAL cFile
LOCAL tmp
LOCAL cEOL
LOCAL lReBuild
LOCAL lRemoveEndingWhitespace
LOCAL aCanBeUpper := { ;
"Makefile", ;
"README.md", ;
@@ -116,6 +122,8 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
LOCAL aForcedLF := { ;
"*.sh" }
hb_default( @lApplyFixes, .F. )
cName := hb_DirSepToOS( cName )
cFile := hb_MemoRead( cName )
@@ -123,7 +131,7 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
/* filename checks */
IF ! FNameExc( cName, LoadGitIgnore() )
IF ! FNameExc( cName, LoadGitignore() )
IF ( Len( hb_FNameName( cName ) ) > 8 .OR. Len( hb_FNameExt( cName ) ) > 4 ) .AND. ! FNameExc( cName, aCanBeLong )
AAdd( aErr, "filename: non-8.3" )
@@ -142,7 +150,7 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
ENDIF
IF IsBinary( cFile )
IF .F.
IF lApplyFixes
IF hb_FNameExt( cFile ) == ".png"
OutStd( cFile + ": " + "content: optimizing" + hb_eol() )
hb_run( "optipng " + cFile )
@@ -150,10 +158,12 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
ENDIF
ELSE
IF hb_FileMatch( cName, "ChangeLog.txt" ) .AND. Len( cFile ) > 32768
IF hb_FileMatch( cName, "ChangeLog.txt" ) .AND. Len( cFile ) > 32768 .AND. ! lApplyFixes
cFile := Left( cFile, 16384 ) + Right( cFile, 16384 )
ENDIF
lReBuild := .F.
/* text content checks */
IF ! FNameExc( cName, aCanHaveTab ) .AND. e"\t" $ cFile
@@ -162,37 +172,68 @@ STATIC FUNCTION CheckFile( cName, /* @ */ aErr )
IF hb_BLeft( cFile, Len( UTF8_BOM() ) ) == UTF8_BOM()
AAdd( aErr, "content: has BOM" )
ENDIF
IF ! FNameExc( cName, aCanHaveSpaceAtEol ) .AND. EndingWhitespace( cFile )
AAdd( aErr, "content: has ending whitespace" )
IF lApplyFixes
cFile := hb_BSubStr( cFile, Len( UTF8_BOM() ) + 1 )
ENDIF
ENDIF
IF Right( cFile, 1 ) == Chr( 26 )
AAdd( aErr, "content: has legacy EOF char" )
IF lApplyFixes
cFile := hb_StrShrink( cFile, 1 )
ENDIF
ENDIF
cEOL := EOLDetect( cFile )
IF Len( cEOL ) == 0
AAdd( aErr, "content: has mixed EOL types" )
IF lApplyFixes
lReBuild := .T.
ENDIF
ENDIF
IF FNameExc( cName, aForcedCRLF ) .AND. !( cEOL == Chr( 13 ) + Chr( 10 ) )
AAdd( aErr, "content: must use CRLF EOL for file type" )
IF lApplyFixes
cFile := StrTran( StrTran( cFile, Chr( 13 ) ), Chr( 10 ), cEOL := Chr( 13 ) + Chr( 10 ) )
ENDIF
ENDIF
IF FNameExc( cName, aForcedLF ) .AND. !( cEOL == Chr( 10 ) )
AAdd( aErr, "content: must use LF EOL for file type" )
IF lApplyFixes
cFile := StrTran( cFile, Chr( 13 ) )
cEOL := Chr( 10 )
ENDIF
ENDIF
IF !( Right( cFile, Len( hb_eol() ) ) == hb_eol() ) .AND. ;
!( Right( cFile, Len( e"\n" ) ) == e"\n" )
IF ! FNameExc( cName, aCanHaveSpaceAtEol ) .AND. EndingWhitespace( cFile )
AAdd( aErr, "content: has ending whitespace" )
IF lApplyFixes
lRemoveEndingWhitespace := .T.
lReBuild := .T.
ENDIF
ENDIF
IF lReBuild
cFile := RemoveEndingWhitespace( cFile, cEOL, lRemoveEndingWhitespace )
ENDIF
IF !( Right( cFile, Len( cEOL ) ) == cEOL )
AAdd( aErr, "content: has no EOL at EOF" )
IF lApplyFixes
cFile += cEOL
ENDIF
ENDIF
IF Right( cFile, 2 * Len( hb_eol() ) ) == Replicate( hb_eol(), 2 )
IF Right( cFile, Len( cEOL ) * 2 ) == Replicate( cEOL, 2 )
AAdd( aErr, "content: has multiple EOL at EOF" )
IF lApplyFixes
DO WHILE Right( cFile, Len( cEOL ) * 2 ) == Replicate( cEOL, 2 )
cFile := hb_StrShrink( cFile, Len( cEOL ) )
ENDDO
ENDIF
ENDIF
IF ! FNameExc( cName, aCanHaveAnyEncoding )
@@ -312,6 +353,8 @@ STATIC FUNCTION EOLDetect( cFile )
RETURN Chr( 13 )
ELSEIF nCR == 0 .AND. nLF > 0
RETURN Chr( 10 )
ELSEIF nCR == 0 .AND. nLF == 0
RETURN "binary"
ELSEIF nCR == nLF
RETURN Chr( 13 ) + Chr( 10 )
ENDIF
@@ -330,6 +373,20 @@ STATIC FUNCTION EndingWhitespace( cFile )
RETURN .F.
STATIC FUNCTION RemoveEndingWhitespace( cFile, cEOL, lRTrim )
LOCAL cResult := ""
LOCAL cLine
FOR EACH cLine IN hb_ATokens( StrTran( cFile, Chr( 13 ) ), Chr( 10 ) )
cResult += iif( lRTrim, RTrim( cLine ), cLine )
IF ! cLine:__enumIsLast()
cResult += cEOL
ENDIF
NEXT
RETURN cResult
STATIC FUNCTION FNameExc( cName, aList )
LOCAL tmp, tmp1
@@ -353,7 +410,7 @@ STATIC FUNCTION UTF8_BOM()
hb_BChar( 0xBB ) + ;
hb_BChar( 0xBF )
STATIC FUNCTION LoadGitIgnore()
STATIC FUNCTION LoadGitignore()
THREAD STATIC s_aIgnore := NIL

View File

@@ -94,7 +94,7 @@ static HB_LANG s_lang =
"* Teilsumme *",
"*** Summe ***",
"Einfg.",
" ",
" ",
"Ungültiges Datum",
"Bereich: ",
" - ",

View File

@@ -1,50 +1,4 @@
/*
* Harbour Project source code:
* Language Support Module (el)
*
* Copyright 2004 Pete Dionisopoulos <pete_westg@yahoo.gr>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING.txt. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/* Last Translator: Pete_wg <pete_westg@yahoo.gr> */
#include "hbapilng.h"
@@ -66,7 +20,7 @@ static HB_LANG s_lang =
"Φεβρουάριος",
"Μάρτιος",
"Απρίλιος",
"Μάϊος",
"Μάιος",
"Ιούνιος",
"Ιούλιος",
"Αύγουστος",
@@ -87,102 +41,102 @@ static HB_LANG s_lang =
/* CA-Cl*pper compatible natmsg items */
"Αρχεία δεδομένων # Εγγραφές Τελ.Ενημέρωση Μεγ.",
"Θέλετε άλλα παραδείγματα?",
"Αρ.Σελιδ",
"** Υποσύνολο**",
"* Μερ.Σύνολο *",
"Βάση δεδομένων # Εγγραφών Τελευταία ενημ. Μέγεθος",
"Θέλετε περισσότερα παραδείγματα?",
"Αρ. Σελίδας",
"** Μερικό σύνολο **",
"* Υποσύνολο *",
"*** Σύνολο ***",
"Εισ",
" ",
"Ακυρη Ημερ. ",
"Ακυρη ημερ/νία",
"Εύρος: ",
" - ",
"Ν/Ο",
"ΑΚΥΡΗ ΕΚΦΡΑΣΗ ",
"ΑΚΥΡΗ ΕΚΦΡΑΣΗ",
/* Error description names */
"Αγνωστο σφάλμα",
"Argument error",
"Bound error",
"String overflow",
"Αγνωστο λάθος",
"Λάθος όρισμα",
"Λάθος όρια",
"Υπερχείλιση συμβολοσειράς",
"Αριθμητική υπερχείλιση",
"Διαίρεση με μηδέν",
"Numeric error",
"Μηδενικός διαιρέτης",
"Αριθμητικό λάθος",
"Συντακτικό λάθος",
"Operation too complex",
"Λειτουργία πολύ μπερδεμένη",
"",
"",
"Έλλειψη Μνήμης",
"Undefined function",
"No exported method",
"Variable does not exist",
"Alias does not exist",
"No exported variable",
"Illegal characters in alias",
"Alias already in use",
"Χαμηλή μνήμη",
"Απροσδιόριστη συνάρτηση /Undefined/",
"Μη εξαγώγιμη μέθοδος",
"Ανύπαρκτη μεταβλητή",
"Το ψευδώνυμο /alias/ δεν υπάρχει",
"Μη εξαγώγιμη μεταβλητή",
"Ακυροι χαρακτήρες στο ψευδώνυμο /alias/",
"Tο ψευδώνυμο /alias/ χρησιμοποιείται ήδη",
"",
"Create error",
"Open error",
"Close error",
"Σφάλμα ανάγνωσης",
"Σφάλμα εγγραφής",
"Σφάλμα εκτύπωσης",
"Λάθος δημιουργίας",
"Λάθος ανοίγματος",
"Λάθος κλεισίματος",
"Λάθος ανάγνωσης",
"Λάθος εγγραφής",
"Λάθος εκτύπωσης",
"",
"",
"",
"",
"Μη υποστηριζόμενη λειτουργία",
"Υπέρβαση Ορίων",
"Διαπιστώθηκε φθορά ",
"Η λειτουργία δεν υποστηρίζεται",
"Ξεπεράστηκε το όριο",
"Ανιχνεύτηκε φθορά αρχείων",
"Λανθασμένος τύπος δεδομένων",
"Λανθασμένο πλάτος δεδομένων",
"Workarea not in use",
"Workarea not indexed",
"Exclusive required",
"Lock required",
"Δεν επιτρέπετε εγγραφή",
"Append lock failed",
"Lock Failure",
"Η περιοχή-εργασίας δεν είναι σε χρήση",
"Η περιοχή-εργασίας δεν είναι ταξινομημένη",
"Απαιτείται αποκλειστική χρήση /Exclusive/",
"Απαιτείται κλείδωμα",
"Δεν επιτρέπεται η εγγραφή",
"Αποτυχία κλειδώματος νέας εγγραφής /Append/",
"Αποτυχία κλειδώματος",
"",
"",
"",
"",
"array access",
"array assign",
"array dimension",
"not an array",
"conditional",
"Αποτυχία καταστροφής αντικειμένου",
"πρόσβαση πίνακα",
"καταχώριση σε πίνακα",
"διασταση πίνακα",
"δεν είναι πίνακας",
"στη σύγκριση",
/* Internal error names */
"Ανεπανόρθωτο σφάλμα %d: ",
"Αποτυχία διόρθωσης σφάλματος",
"No ERRORBLOCK() for error",
"Too many recursive error handler calls",
"RDD invalid or failed to load",
"Invalid method type from %s",
"hb_xgrab can't allocate memory",
"hb_xrealloc called with a NULL pointer",
"hb_xrealloc called with an invalid pointer",
"hb_xrealloc can't reallocate memory",
"hb_xfree called with an invalid pointer",
"hb_xfree called with a NULL pointer",
"Can\'t locate the starting procedure: \'%s\'",
"No starting procedure",
"Unsupported VM opcode",
"Symbol item expected from %s",
"Invalid symbol type for self from %s",
"Codeblock expected from %s",
"Incorrect item type on the stack trying to pop from %s",
"Υπερχείλιση στοίβας (Stack underflow)",
"An item was going to be copied to itself from %s",
"Invalid symbol item passed as memvar %s",
"Υπερχείλιση ενδιάμεσης μνήμη (Memory buffer overflow)",
"hb_xgrab requested to allocate zero bytes",
"hb_xrealloc requested to resize to zero bytes",
"hb_xalloc requested to allocate zero bytes",
"Μη αναστρέψιμο λάθος %d: ",
"Αποτυχία επανόρθωσης λάθους",
"Δεν υπάρχει ERRORBLOCK() για το λάθος",
"Πάρα πολλές επαναλαμβανόμενες κλήσεις χειρισμού σφαλμάτων",
"Ακυρη RDD ή αποτυχία φόρτωσης",
"Ακυρος τύπος μεθόδου από %s",
"Η συνάρτηση hb_xgrab δεν μπορεί να εκχωρήσει μνήμη",
"Η συνάρτηση hb_xrealloc κλήθηκε με ένα δείκτη NULL",
"Η συνάρτηση hb_xrealloc κλήθηκε με ένα άκυρο δείκτη",
"Η συνάρτηση hb_xrealloc δεν μπορεί να εκχωρήσει μνήμη",
"Η συνάρτηση hb_xfree κλήθηκε με ένα άκυρο δείκτη",
"Η συνάρτηση hb_xfree κλήθηκε με ένα δείκτη NULL",
"Αδυναμία εντοπισμού της εναρκτήριας διαδικασίας: '%s'",
"Δεν υπάρχει εναρκτήρια διαδικασία",
"Μη υσποστηριζόμενος VM opcode",
"Συμβολοστοιχείο αναμενόταν από %s",
"Ακυρος τύπος συμβόλου για self απο %s",
"Αναμενόταν μπλοκ-κώδικα απο %s",
"Ακυρος τύπος στοιχείου στοίβας επιχειρεί pop από %s",
"Ελειπής ροή στοίβας /stack underflow/",
"Ενα στοιχείο επιχειρούσε να αντιγραφεί στον εαυτό του από %s",
"Ακυρο συμβολικό στοιχείο περάστηκε ως μεταβλητή μνήμης %s",
"Υπερχείλιση buffer Μνήμης",
"Η συνάρτηση hb_xgrab αιτήθηκε να διαθέσει μηδέν χαρακτήρες",
"Η συνάρτηση hb_xrealloc αιτήθηκε να αλλάξει μέγεθος σε μηδέν χαρακτήρες",
"Η συνάρτηση hb_xalloc αιτήθηκε να διαθέσει μηδέν χαρακτήρες",
/* Texts */

View File

@@ -96,7 +96,7 @@ static HB_LANG s_lang =
"Ins",
" ",
"Rossz dátum",
" Határok ",
"Határok: ",
" - ",
"I/N",
"HIBÁS KIFEJEZÉS",

View File

@@ -94,7 +94,7 @@ static HB_LANG s_lang =
"* Subsubtotaal *",
"*** Totaal ***",
"Ins",
" ",
" ",
"Ongeldige datum",
"Bereik: ",
" - ",

View File

@@ -96,7 +96,7 @@ static HB_LANG s_lang =
"Wst", /* wstaw */
"Zas", /* zastap */
"Nieprawidłowa data",
"Zakres:",
"Zakres: ",
" - ",
"T/N",
"Błędne wyrażenie",

View File

@@ -207,7 +207,6 @@ HB_LANG_ANNOUNCE( EN )
#define HB_LANG_ITEM_ID_ID 0
#define HB_LANG_ITEM_ID_NAME 1
#define HB_LANG_ITEM_ID_NAMENAT 2
#define HB_LANG_ITEM_ID_RFCID 3
#define HB_LANG_ITEM_ID_CODEPAGE 4
typedef struct

View File

@@ -804,7 +804,11 @@ METHOD ShowScoreboard() CLASS HBGetList
IF Set( _SET_SCOREBOARD )
hb_DispOutAt( SCORE_ROW, SCORE_COL, iif( Set( _SET_INSERT ), __natMsg( _GET_INSERT_ON ), __natMsg( _GET_INSERT_OFF ) ) )
hb_DispOutAt( SCORE_ROW, SCORE_COL, iif( Set( _SET_INSERT ), ;
__natMsg( _GET_INSERT_ON ), ;
iif( Len( __natMsg( _GET_INSERT_OFF ) ) == Len( __natMsg( _GET_INSERT_ON ) ), ;
__natMsg( _GET_INSERT_ON ), ;
Space( Len( __natMsg( _GET_INSERT_ON ) ) ) ) ) )
ENDIF

View File

@@ -12,7 +12,7 @@
#include "hblang.ch"
PROCEDURE Main()
PROCEDURE Main_lang2po()
LOCAL cLang
@@ -25,18 +25,38 @@ PROCEDURE Main()
STATIC FUNCTION LangToPO( cLang )
LOCAL nPos := 0
LOCAL cPO := Item( "", Meta( cLang ), nPos++ )
LOCAL cPO := Item( "", Meta(), nPos++ )
LOCAL tmp
cPO += Item( "English (in English)", hb_langMessage( 1, cLang ), nPos++ )
cPO += Item( "English", hb_langMessage( 2, cLang ), nPos++ )
FOR tmp := HB_LANG_ITEM_BASE_MONTH TO HB_LANG_ITEM_MAX_ - 1
cPO += Item( ;
hb_langMessage( tmp, "en" ), ;
iif( hb_langMessage( tmp, "en" ) == hb_langMessage( tmp, cLang ), "", hb_langMessage( tmp, cLang ) ), ;
nPos++ )
IF Len( hb_langMessage( tmp, "en" ) ) > 0
cPO += Item( ;
hb_langMessage( tmp, "en" ), ;
iif( hb_langMessage( tmp, "en" ) == hb_langMessage( tmp, cLang ) .AND. ;
! NonTranslatable( hb_langMessage( tmp, "en" ) ) .AND. ;
nPos != 28, "", hb_langMessage( tmp, cLang ) ), ;
nPos++ )
ENDIF
NEXT
RETURN hb_StrShrink( cPO, Len( hb_eol() ) )
STATIC FUNCTION NonTranslatable( cString )
LOCAL tmp
FOR tmp := 1 TO Len( cString )
IF IsAlpha( SubStr( cString, tmp, 1 ) ) .OR. ;
IsDigit( SubStr( cString, tmp, 1 ) )
RETURN .F.
ENDIF
NEXT
RETURN .T.
#define LEFTEQUAL( l, r ) ( Left( l, Len( r ) ) == r )
STATIC FUNCTION CoreLangList()
@@ -60,7 +80,7 @@ STATIC FUNCTION CoreLangList()
RETURN aList
STATIC FUNCTION Meta( cName )
STATIC FUNCTION Meta()
LOCAL cISO_TimeStamp := ISO_TimeStamp()
@@ -68,7 +88,6 @@ STATIC FUNCTION Meta( cName )
LOCAL cMeta
LOCAL meta
LOCAL tmp
/* NOTE: workaround for Harbour not retaining definition order of hash literals */
hMeta := { => }
@@ -77,16 +96,12 @@ STATIC FUNCTION Meta( cName )
hMeta[ "Report-Msgid-Bugs-To:" ] := "https://groups.google.com/group/harbour-devel/"
hMeta[ "POT-Creation-Date:" ] := cISO_TimeStamp
hMeta[ "PO-Revision-Date:" ] := cISO_TimeStamp
hMeta[ "Last-Translator:" ] := "a b <a.b@c.d>"
hMeta[ "Last-Translator:" ] := "foo bar <foo.bar@foobaz>"
hMeta[ "Language-Team:" ] := "https://www.transifex.com/projects/p/harbour/"
hMeta[ "MIME-Version:" ] := "1.0"
hMeta[ "Content-Type:" ] := "text/plain; charset=UTF-8"
hMeta[ "Content-Transfer-Encoding:" ] := "8bit"
FOR tmp := 0 TO 5
hMeta[ hb_StrFormat( "Harbour-Lang-Meta-%1$d:", tmp ) ] := hb_langMessage( tmp, cName )
NEXT
cMeta := '"' + hb_eol()
FOR EACH meta IN hMeta
cMeta += ;
@@ -111,8 +126,22 @@ STATIC FUNCTION ISO_TimeStamp()
Int( ( ( nOffset / 3600 ) - Int( nOffset / 3600 ) ) * 60 ) )
STATIC FUNCTION Item( cOri, cTrs, nPos )
LOCAL cComment := Comment( nPos )
RETURN hb_StrFormat( ;
iif( Empty( cComment ), "", "# " + cComment + hb_eol() ) + ;
"#, c-format" + hb_eol() + ;
'msgid "%1$s"' + hb_eol() + ;
'msgstr "%2$s"' + hb_eol() + ;
hb_eol(), iif( Empty( cOri ) .AND. nPos != 0, "{" + StrZero( nPos, 3, 0 ) + "}", cOri ), cTrs )
hb_eol(), iif( Len( cOri ) == 0 .AND. nPos != 0, "{" + StrZero( nPos, 3, 0 ) + "}", cOri ), cTrs )
STATIC FUNCTION Comment( nPos )
SWITCH nPos
CASE 22 ; RETURN "Colums must be aligned to positions: 1, 19, 32, 48"
CASE 29 ; RETURN "Abbrev of 'Overwrite' using same length as 'Ins', can be spaces only (fill with 3 spaces if in doubt)"
CASE 102 ; RETURN "Local date format, where YYYY=year, MM=month, DD=day"
ENDSWITCH
RETURN ""

View File

@@ -1,3 +1,10 @@
/*
* Converts .po files to lang modules
*
* Copyright 2013 Viktor Szakats (harbour syenar.net)
* www - http://harbour-project.org
*
*/
#pragma -w3
#pragma -km+
@@ -5,23 +12,20 @@
#include "hblang.ch"
PROCEDURE Main()
PROCEDURE Main_po2lang()
LOCAL cFileIn := "hu.po"
LOCAL cFileOut := "l_hu.c"
PO_2_C( cFileIn, cFileOut )
PO_2_C( "hu.po", "l_hu.c", "hu" )
PO_2_C( "el.po", "l_el.c", "el" )
RETURN
STATIC FUNCTION PO_2_C( cFileIn, cFileOut, ... )
STATIC FUNCTION PO_2_C( cFileIn, cFileOut, cLang )
LOCAL aTrans
LOCAL cErrorMsg
LOCAL cContent
LOCAL cTranslator
LOCAL cID
LOCAL nPos
IF ( aTrans := __i18n_potArrayLoad( cFileIn, @cErrorMsg ) ) != NIL
@@ -29,11 +33,11 @@ STATIC FUNCTION PO_2_C( cFileIn, cFileOut, ... )
cContent := StrTran( _begin(), e"\n", hb_eol() )
nPos := 0
__i18n_potArrayClean( aTrans,,, {| cTrs, cOri | ProcessTrs( @cContent, cTrs, cOri, @cTranslator, @cID, @nPos ) } )
__i18n_potArrayClean( aTrans,,, {| cTrs, cOri | ProcessTrs( @cContent, cTrs, cOri, @cTranslator, @nPos, cLang ) } )
cContent := "/* Last Translator: " + cTranslator + " */" + hb_eol() + ;
Left( cContent, Len( cContent ) - Len( "," ) - Len( hb_eol() ) ) + hb_eol() + ;
StrTran( StrTran( _end(), e"\n", hb_eol() ), "{LNG}", Upper( cID ) )
StrTran( StrTran( _end(), e"\n", hb_eol() ), "{LNG}", Upper( cLang ) )
hb_MemoWrit( cFileOut, cContent )
@@ -44,9 +48,16 @@ STATIC FUNCTION PO_2_C( cFileIn, cFileOut, ... )
RETURN .F.
STATIC FUNCTION ProcessTrs( /* @ */ cContent, cTrs, cOri, /* @ */ cTranslator, /* @ */ cID, /* @ */ nPos )
STATIC FUNCTION ProcessTrs( /* @ */ cContent, cTrs, cOri, /* @ */ cTranslator, /* @ */ nPos, cLang )
LOCAL tmp, tmp1
STATIC sc_hEmpty := { ;
3 => { "", "UTF8", "" }, ;
47 => { "", "" }, ;
57 => { "" }, ;
64 => { "", "", "", "" }, ;
80 => { "", "", "" } }
LOCAL tmp
SWITCH nPos
CASE HB_LANG_ITEM_BASE_ID ; tmp := "/* Identification */" ; EXIT
@@ -65,22 +76,24 @@ STATIC FUNCTION ProcessTrs( /* @ */ cContent, cTrs, cOri, /* @ */ cTranslator, /
IF nPos == 0
cTranslator := hb_regexAll( "Last-Translator: ([^\n]*)", cTrs,,,,, .T. )[ 1 ][ 2 ]
IF cTranslator == "a b <a.b@c.d>"
IF cTranslator == "foo bar <foo.bar@foobaz>"
cTranslator := ""
ENDIF
FOR tmp := 0 TO 5
cContent += Space( 6 ) + ConvToC( tmp1 := hb_regexAll( hb_StrFormat( "Harbour-Lang-Meta-%1$d: ([\S]*)", tmp ), cTrs,,,,, .T. )[ 1 ][ 2 ] ) + "," + hb_eol()
++nPos
IF tmp == 0
cID := tmp1
ENDIF
NEXT
cContent += Space( 6 ) + ConvToC( cLang ) + "," + hb_eol()
++nPos
ELSE
IF Len( cTrs ) == 0
cTrs := cOri
ENDIF
cContent += Space( 6 ) + ConvToC( cTrs ) + "," + hb_eol()
++nPos
IF nPos $ sc_hEmpty
FOR tmp := 1 TO Len( sc_hEmpty[ nPos ] )
cContent += Space( 6 ) + ConvToC( sc_hEmpty[ nPos ][ tmp ] ) + "," + hb_eol()
NEXT
nPos += Len( sc_hEmpty[ nPos ] )
ENDIF
ENDIF
RETURN NIL