diff --git a/ChangeLog.txt b/ChangeLog.txt index 7b91de6ba2..1118b84798 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,20 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-04-03 01:48 UTC+0200 Viktor Szakats (harbour syenar.net) + * tests/lang2po.hb -> config/lang2po.hb + * tests/po2lang.hb -> config/po2lang.hb + * moved to their final location + + * config/lang.hb + + implemented automatic processed for core lang modules + (component name 'core-lang'). The script will automatically + convert to/from .c language modules and .po files for + Transifex. + + * src/lang/l_hu.c + + updated using above script + 2013-04-03 00:19 UTC+0200 Viktor Szakats (harbour syenar.net) * include/hblang.hbx * src/lang/Makefile diff --git a/config/lang.hb b/config/lang.hb index 994f839183..859f4c09a0 100644 --- a/config/lang.hb +++ b/config/lang.hb @@ -114,31 +114,41 @@ STATIC PROCEDURE src_push( cMain ) ? hPar[ "name" ], "generating translation source" - hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 %1$s -j%2$s -s", hPar[ "entry" ], cTempContent ) ) + IF Empty( hPar[ "po" ] ) + cContent := LangToPO( LangToCoreLang( hPar[ "baselang" ] ) ) + ELSE + hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 %1$s -j%2$s -s", hPar[ "entry" ], cTempContent ) ) - POT_Sort( cTempContent ) + POT_Sort( cTempContent ) - ? hPar[ "name" ], "saving locally" + cContent := hb_MemoRead( cTempContent ) + ENDIF - cContent := hb_StrFormat( ; - '#, c-format' + hb_eol() + ; - 'msgid ""' + hb_eol() + ; - 'msgstr ""' + hb_eol() + ; - '"Project-Id-Version: %1$s\n"' + hb_eol() + ; - '"Language: %2$s\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_FNameName( hPar[ "entry" ] ), hPar[ "baselang" ] ) + hb_eol() + ; - hb_eol() + ; - hb_MemoRead( cTempContent ) - - hb_MemoWrit( hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + hPar[ "baselang" ] + ".po", cContent ) + IF Empty( hPar[ "po" ] ) + #ifdef DEBUG + hb_MemoWrit( hPar[ "baselang" ] + ".po", cContent ) + #endif + ELSE + cContent := hb_StrFormat( ; + '#, c-format' + hb_eol() + ; + 'msgid ""' + hb_eol() + ; + 'msgstr ""' + hb_eol() + ; + '"Project-Id-Version: %1$s\n"' + hb_eol() + ; + '"Language: %2$s\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_FNameName( hPar[ "entry" ] ), hPar[ "baselang" ] ) + hb_eol() + ; + hb_eol() + ; + cContent + ? hPar[ "name" ], "saving locally" + hb_MemoWrit( hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + hPar[ "baselang" ] + ".po", cContent ) + ENDIF ? hPar[ "name" ], "uploading", "size", hb_ntos( Len( cContent ) ) hb_MemoWrit( cTempContent, hb_jsonEncode( { "content" => StrTran( cContent, hb_eol(), e"\n" ) } ) ) - hb_run( hb_StrFormat( 'curl -s -i -L --user %1$s -X ' + ; + hb_run( hb_StrFormat( 'curl -v -s -i -L --user %1$s -X ' + ; 'PUT -d @%2$s -H "Content-Type: application/json" ' + ; 'https://www.transifex.com/api/2/project/%3$s/resource/%4$s/content/' + ; ' -o %5$s', ; @@ -196,14 +206,24 @@ STATIC PROCEDURE trs_pull( cMain ) IF hb_jsonDecode( GetJSON( hb_MemoRead( cTempResult ) ), @json ) > 0 hb_MemoWrit( cTempResult, json[ "content" ] ) - POT_Sort( cTempResult ) - /* should only do this if the translation is primarily done - on Transifex website. This encouraged and probably the case - in practice. Delete source information, delete empty - translations and apply some automatic transformation for - common translation mistakes. */ - PO_Clean( cTempResult, hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + cLang + ".po", ; - .F., .F., @DoctorTranslation() ) + IF ! Empty( hPar[ "po" ] ) + POT_Sort( cTempResult ) + /* should only do this if the translation is primarily done + on Transifex website. This encouraged and probably the case + in practice. Delete source information, delete empty + translations and apply some automatic transformation for + common translation mistakes. */ + PO_Clean( cTempResult, hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + cLang + ".po", ; + .F., .F., @DoctorTranslation() ) + ELSE + POToLang( ; + cTempResult, ; + hb_DirBase() + hb_DirSepToOS( "../src/lang/" ) + "l_" + LangToCoreLang( cLang ) + ".c", ; + LangToCoreLang( cLang ) ) + #ifdef DEBUG + hb_MemoWrit( cLang + ".po", json[ "content" ] ) + #endif + ENDIF ELSE ? "API error" ENDIF @@ -301,11 +321,22 @@ STATIC PROCEDURE trs_push( cMain ) FClose( hb_FTempCreateEx( @cTempContent ) ) FClose( hb_FTempCreateEx( @cTempResult ) ) + ? hPar[ "name" ], "uploading translation:" + FOR EACH cLang IN hPar[ "langs" ] - cContent := hb_MemoRead( hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + cLang + ".po" ) + ?? "", cLang - ? hPar[ "name" ], "uploading translation", "size", Len( cContent ) + IF Empty( hPar[ "po" ] ) + cContent := LangToPO( LangToCoreLang( cLang ) ) + #ifdef DEBUG + hb_MemoWrit( cLang + ".po", cContent ) + #endif + ELSE + cContent := hb_MemoRead( hPar[ "po" ] + hb_FNameName( hPar[ "entry" ] ) + "." + cLang + ".po" ) + ENDIF + + ?? "", hb_ntos( Len( cContent ) ) hb_MemoWrit( cTempContent, hb_jsonEncode( { "content" => StrTran( cContent, hb_eol(), e"\n" ) } ) ) @@ -369,6 +400,16 @@ STATIC FUNCTION _HAGetDef( xContainer, xDefault, ... ) RETURN xDefault +STATIC FUNCTION LangToCoreLang( cLang ) + RETURN hb_HGetDef( { ; + "zh_CN" => "zh_tra", ; + "zh_CN.GB2312" => "zh_sim", ; + "sr" => "sr_cyr", ; + "sr@latin" => "sr_lat", ; + "fr_FR" => "fr", ; + "es_ES" => "es", ; + "pt_BR" => "pt" }, cLang, cLang ) + STATIC FUNCTION LoadPar( cMain ) LOCAL hPar := { => } @@ -376,31 +417,44 @@ STATIC FUNCTION LoadPar( cMain ) LOCAL cConfig LOCAL item - hPar[ "entry" ] := cMain - - cConfig := hb_MemoRead( hb_FNameExtSet( hPar[ "entry" ], ".hbp" ) ) - hPar[ "project" ] := "harbour" + hPar[ "entry" ] := cMain hPar[ "login" ] := GetEnv( "HB_TRANSIFEX_LOGIN" ) /* Format: username:password */ hPar[ "name" ] := hb_FNameName( hPar[ "entry" ] ) - hPar[ "doc" ] := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( "doc/" ) - hPar[ "docext" ] := _HAGetDef( hb_regexAll( "-3rd=_hblang_docext=([\S]*)", cConfig,,,,, .T. ), ".txt", 1, 2 ) - hPar[ "docoption" ] := {} - FOR EACH item IN hb_regexAll( "-3rd=_hblang_docoption=([\S]*)", cConfig,,,,, .T. ) - AAdd( hPar[ "docoption" ], item[ 2 ] ) - NEXT - item := _HAGetDef( hb_regexAll( "-3rd=_hblang_entry=([\S]*)", cConfig,,,,, .T. ), NIL, 1, 2 ) - IF item != NIL - item := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( item ) - hPar[ "entry" ] := iif( Empty( hb_FNameName( item ) ), item + hb_FNameName( hb_DirSepDel( item ) ) + ".prg", item ) + IF hPar[ "entry" ] == "core-lang" +// hPar[ "langs" ] := { "hu", "el", "fr_FR", "it", "es_ES", "es_419", "pt_BR", "de" } +// hPar[ "langs" ] := { "zh_CN", "zh_CN.GB2312" } // CoreLangList() + hPar[ "langs" ] := { "hu" } + hPar[ "baselang" ] := "en" + hPar[ "po" ] := NIL + ELSE + cConfig := hb_MemoRead( hb_FNameExtSet( hPar[ "entry" ], ".hbp" ) ) + + hPar[ "doc" ] := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( "doc/" ) + hPar[ "docext" ] := _HAGetDef( hb_regexAll( "-3rd=_hblang_docext=([\S]*)", cConfig,,,,, .T. ), ".txt", 1, 2 ) + hPar[ "docoption" ] := {} + FOR EACH item IN hb_regexAll( "-3rd=_hblang_docoption=([\S]*)", cConfig,,,,, .T. ) + AAdd( hPar[ "docoption" ], item[ 2 ] ) + NEXT + + item := _HAGetDef( hb_regexAll( "-3rd=_hblang_entry=([\S]*)", cConfig,,,,, .T. ), NIL, 1, 2 ) + IF item != NIL + item := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( item ) + hPar[ "entry" ] := iif( Empty( hb_FNameName( item ) ), item + hb_FNameName( hb_DirSepDel( item ) ) + ".prg", item ) + ENDIF + + cConfig := hb_MemoRead( hb_FNameExtSet( hPar[ "entry" ], ".hbp" ) ) + + hPar[ "langs" ] := hb_ATokens( _HAGetDef( hb_regexAll( "-lng=([\w,]*)", cConfig,,,,, .T. ), "", 1, 2 ), "," ) + hPar[ "baselang" ] := _HAGetDef( hb_regexAll( "-3rd=_hblang_base=([\w]*)", cConfig,,,,, .T. ), "en", 1, 2 ) + + hPar[ "po" ] := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( "po/" ) ENDIF - cConfig := hb_MemoRead( hb_FNameExtSet( hPar[ "entry" ], ".hbp" ) ) - - hPar[ "langs" ] := hb_ATokens( _HAGetDef( hb_regexAll( "-lng=([\w,]*)", cConfig,,,,, .T. ), "", 1, 2 ), "," ) - hPar[ "baselang" ] := _HAGetDef( hb_regexAll( "-3rd=_hblang_base=([\w]*)", cConfig,,,,, .T. ), "en", 1, 2 ) - - hPar[ "po" ] := hb_FNameDir( hPar[ "entry" ] ) + hb_DirSepToOS( "po/" ) - RETURN hPar + +/* --------------------------------------------- */ + +#include "lang2po.hb" +#include "po2lang.hb" diff --git a/tests/lang2po.hb b/config/lang2po.hb similarity index 98% rename from tests/lang2po.hb rename to config/lang2po.hb index a0e06bdb4a..a7c9fd6a22 100644 --- a/tests/lang2po.hb +++ b/config/lang2po.hb @@ -1,5 +1,5 @@ /* - * Converts lang modules to standard .po files + * Converts core lang modules to standard .po files * * Copyright 2013 Viktor Szakats (harbour syenar.net) * www - http://harbour-project.org diff --git a/tests/po2lang.hb b/config/po2lang.hb similarity index 98% rename from tests/po2lang.hb rename to config/po2lang.hb index 06f02c409c..99512b9a50 100644 --- a/tests/po2lang.hb +++ b/config/po2lang.hb @@ -1,5 +1,5 @@ /* - * Converts .po files to lang modules + * Converts .po files to core lang modules * * Copyright 2013 Viktor Szakats (harbour syenar.net) * www - http://harbour-project.org diff --git a/src/lang/l_hu.c b/src/lang/l_hu.c index 475b138c13..2943a6e6bc 100644 --- a/src/lang/l_hu.c +++ b/src/lang/l_hu.c @@ -1,50 +1,4 @@ -/* - * Harbour Project source code: - * Language Support Module (hu) - * - * Copyright 2012 Viktor Szakats (harbour syenar.net) - * 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: hbtest */ #include "hbapilng.h" @@ -53,12 +7,12 @@ static HB_LANG s_lang = { /* Identification */ - "hu", /* ISO ID (2 chars) */ - "Hungarian", /* Name (in English) */ - "Magyar", /* Name (in native language) */ - "HU", /* RFC ID */ - "UTF8", /* Codepage */ - "", /* Version */ + "hu", + "Hungarian", + "Magyar", + "", + "UTF8", + "", /* Month names */ @@ -169,7 +123,7 @@ static HB_LANG s_lang = "hb_xrealloc nem tud memóriát újrafoglalni", "hb_xfree hibás mutatóval került meghívásra", "hb_xfree NULL mutatóval került meghívásra", - "Nem sikerült megtalálni a kezdő procedúrát: \'%s\'", + "Nem sikerült megtalálni a kezdő procedúrát: '%s'", "Nem található kezdő procedúra", "Ismeretlen VM opkód", "%s hívásnak szimbólum adatra van szüksége",