diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index e565b851ea..2567ee97fa 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -10,6 +10,39 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-01-30 18:24 UTC+0100 Viktor Szakats (harbour syenar.net) + * doc/en/lang.txt + * include/hbapilng.h + * src/rtl/langapi.c + + HB_LANGNAME() Harbour API extended to accept optional + language ID. See docs. + + HB_LANGMESSAGE() Harbour API extended to accept 2nd parameter + as optional language ID. See docs. + + added new C level API to retrieve a language string from + any language module (not just selected one): + const char * hb_langGetItem( const char * pszID, int iIndex ); + + extended hb_langName() C level API to be able to retrieve + name of any language modules, not just selected one: + char * hb_langName( const char * pszID ); + [INCOMPATIBLE] + * hb_langDGetItem() C level API moved to 'compatibility' status + * uncrustified unattendedly + + * src/codepage/l_fr.c + ! fixed another typo which was result of local paste mistake + + * utils/hbmk2/hbmk2.hu_HU.po + * utils/hbmk2/hbmk2.prg + + extended the wording of -comp=/-plat= options, default behavior indicated + + * tests/langapi.prg + ! updated to RTE at the end and to use non-legacy language IDs + + * tests/langapi.prg + * contrib/hbnf/tests/datecnfg.prg + * utils/hbtest/hbtest.prg + * minor cleanup + 2013-01-30 15:31 UTC+0100 Viktor Szakats (harbour syenar.net) - src/codepage/l_ua.c + src/codepage/l_uk.c @@ -8822,7 +8855,7 @@ * contrib/hbnf/tests/woy.prg ! avoid using CTOD() (use date type and STOD() instead) + SET CENTURY ON where dates are displayed - + hb_langSelect( "EN" ) where output has language + + hb_langSelect( "en" ) where output has language dependent strings + TOFIX added where NF code is incompatible with CENTURY ON (and RTEs) + use LOCAL instead of MEMVAR diff --git a/harbour/contrib/hbnf/tests/datecnfg.prg b/harbour/contrib/hbnf/tests/datecnfg.prg index 47772cc7df..621f2620ff 100644 --- a/harbour/contrib/hbnf/tests/datecnfg.prg +++ b/harbour/contrib/hbnf/tests/datecnfg.prg @@ -54,7 +54,7 @@ PROCEDURE Main() SET DATE ANSI // User's normal date format SET CENTURY ON - hb_langSelect( "EN" ) + hb_langSelect( "en" ) aTemp := ft_DateCnfg() // Get/Set cFY_Start and nDOW_Start. #if 0 diff --git a/harbour/doc/en/lang.txt b/harbour/doc/en/lang.txt index c78d56a216..9ccba5a404 100644 --- a/harbour/doc/en/lang.txt +++ b/harbour/doc/en/lang.txt @@ -45,7 +45,7 @@ PROCEDURE Main() // English: Argument error ? "English:", hb_langErrMsg( EG_ARG ) - hb_langSelect( "ES" ) + hb_langSelect( "es" ) // Spanish: Error de argumento ? "Spanish:", hb_langErrMsg( EG_ARG ) RETURN @@ -75,9 +75,11 @@ $ONELINER$ Returns international strings messages and errors $SYNTAX$ - hb_langMessage( ) --> cMessage + hb_langMessage( [, ] ) --> cMessage $ARGUMENTS$ - is the message number to get. + is the message number to get. + is an optional language module ID. Uses the currently + selected language module, if not specified. $RETURNS$ hb_langMessage() return the text associated with the code . $DESCRIPTION$ @@ -92,9 +94,10 @@ PROCEDURE Main() // English: Monday ? "English:", hb_langMessage( HB_LANG_ITEM_BASE_DAY + 1 ) - hb_langSelect( "ES" ) + hb_langSelect( "es" ) // Spanish: Lunes ? "Spanish:", hb_langMessage( HB_LANG_ITEM_BASE_DAY + 1 ) + ? "English:", hb_langMessage( HB_LANG_ITEM_BASE_DAY + 1, "en" ) RETURN $STATUS$ R @@ -120,22 +123,27 @@ $SUBCATEGORY$ Language and Nation $ONELINER$ - Return the name of the current language module in use + Return the name of the language module $SYNTAX$ - hb_langName() --> cLangName + hb_langName( [] ) --> cLangName $ARGUMENTS$ - None. + is an optional language module ID. Uses the currently + selected language module, if not specified. $RETURNS$ - Name of the current language in use + Name of the language module $DESCRIPTION$ - This function return the current name of the language module in use. + This function return the name of the language module in use or + specified. $EXAMPLES$ REQUEST HB_LANG_PT REQUEST HB_LANG_RO REQUEST HB_LANG_ES + REQUEST HB_LANG_HU PROCEDURE Main() + ? hb_langName( "hu" ) + ? hb_langName( "" ) hb_langSelect( "pt" ) // Default language is now Portuguese - ? CDoW( Date() ) //Segunda-feira + ? CDoW( Date() ) // Segunda-feira ? "Current language is ", hb_langName() // Portuguese ? "Old language id selected is ", hb_langSelect() // PT hb_langSelect( "ro" ) // Default language is now Romanian @@ -171,9 +179,9 @@ $ONELINER$ Select a specific nation message module $SYNTAX$ - hb_langSelect( [ ][, ] ) --> cOldLang + hb_langSelect( [][, ] ) --> cOldLang $ARGUMENTS$ - The optional ID of the country language module. + The optional ID of the language module. Possible values for are below as defined in the Lang library, sorted by language. Optional codepage ID into which the language @@ -270,7 +278,7 @@ $SYNTAX$ hb_cdpSelect( [] ) --> cOldLang $ARGUMENTS$ - The optional ID of the country language module. + The optional ID of the language module. Possible values for are below as defined in the Codepage library, sorted by language. @@ -413,7 +421,7 @@ PROCEDURE Main() LOCAL cTxt := "A" + Chr( 142 ) + "BC" ? "German CP-850 text:", cTxt - ? "German Windows-1252 text:", hb_Translate( cTxt, "DE", "DEWIN" ) + ? "German Windows-1252 text:", hb_Translate( cTxt, "DE850", "DEWIN" ) RETURN $STATUS$ R diff --git a/harbour/include/hbapilng.h b/harbour/include/hbapilng.h index f7a07581b1..1bf2c7eadb 100644 --- a/harbour/include/hbapilng.h +++ b/harbour/include/hbapilng.h @@ -92,12 +92,13 @@ extern HB_EXPORT PHB_LANG hb_langFind ( const char * pszID ); extern HB_EXPORT PHB_LANG hb_langSelect ( PHB_LANG lang ); extern HB_EXPORT const char * hb_langSelectID ( const char * pszID ); -extern HB_EXPORT const char * hb_langDGetItem ( int iIndex ); +extern HB_EXPORT const char * hb_langGetItem ( const char * pszID, int iIndex ); extern HB_EXPORT const char * hb_langID ( void ); -extern HB_EXPORT char * hb_langName ( void ); +extern HB_EXPORT char * hb_langName ( const char * pszID ); -/* Compatibility interface */ +/* Compatibility interfaces */ +extern HB_EXPORT const char * hb_langDGetItem ( int iIndex ); extern HB_EXPORT const char * hb_langDGetErrorDesc ( int iIndex ); HB_EXTERN_END diff --git a/harbour/src/codepage/l_fr.c b/harbour/src/codepage/l_fr.c index 3fa8c4bfd7..80d5eea13f 100644 --- a/harbour/src/codepage/l_fr.c +++ b/harbour/src/codepage/l_fr.c @@ -4,5 +4,5 @@ /* Viktor Szakats (harbour syenar.net) */ -#define HB_CP_UPPER "A~Á~À~Â~ÃBC~ÇD~ÐE~É~È~Ê~ËFGHI~Í~Ì~Î~ÏJKLMN~ÑO~Ó~Ò~Ô~ÕPQRSTU~Ú~Ù~ÛV~WXY~Ý~Ÿ~ÜZÅÄ~ÆÖ~Ø~Œ" +#define HB_CP_UPPER "A~Á~À~Â~ÄBCDE~É~È~Ê~ËFGHI~Í~Ì~Î~ÏJKLMNO~Ó~Ò~Ô~ÖPQRSTU~Ú~Ù~Û~ÜVWXYZ" #define HB_CP_LOWER "a~á~à~â~äbcde~é~è~ê~ëfghi~í~ì~î~ïjklmno~ó~ò~ô~öpqrstu~ú~ù~û~üvwxyz" diff --git a/harbour/src/rtl/langapi.c b/harbour/src/rtl/langapi.c index c37dcf523a..d0c82e8242 100644 --- a/harbour/src/rtl/langapi.c +++ b/harbour/src/rtl/langapi.c @@ -265,8 +265,8 @@ static HB_BOOL hb_langTranslate( const char * szNewId, PHB_LANG lang, PHB_CODEPA { PHB_LANG_BASE pBase; HB_LANG_TRANS trans; - char * buffer, * ptr; - HB_SIZE nSize = 0; + char * buffer, * ptr; + HB_SIZE nSize = 0; int i; if( ! szNewId || *szNewId == 0 || ! lang || ! cdpIn || ! cdpOut || cdpIn == cdpOut ) @@ -298,7 +298,7 @@ static HB_BOOL hb_langTranslate( const char * szNewId, PHB_LANG lang, PHB_CODEPA nSize += sizeof( HB_LANG_TRANS ); buffer = ( char * ) hb_xgrab( nSize ); - ptr = buffer + sizeof( trans ); + ptr = buffer + sizeof( trans ); for( i = 0; i < HB_LANG_ITEM_MAX_; ++i ) { if( trans.pItemList[ i ] != NULL ) @@ -317,7 +317,7 @@ static HB_BOOL hb_langTranslate( const char * szNewId, PHB_LANG lang, PHB_CODEPA pBase = hb_langFindBase( szNewId ); if( pBase && pBase->lang == NULL ) { - pBase->lang = ( PHB_LANG ) buffer; + pBase->lang = ( PHB_LANG ) buffer; pBase->buffer = ( void * ) buffer; return HB_TRUE; } @@ -381,7 +381,7 @@ PHB_LANG hb_langSelect( PHB_LANG lang ) const char * hb_langSelectID( const char * pszID ) { const char * pszIDOld = hb_langID(); - PHB_LANG lang; + PHB_LANG lang; HB_TRACE( HB_TR_DEBUG, ( "hb_langSelectID(%s)", pszID ) ); @@ -394,6 +394,57 @@ const char * hb_langSelectID( const char * pszID ) return pszIDOld; } +const char * hb_langGetItem( const char * pszID, int iIndex ) +{ + PHB_LANG lang; + + HB_TRACE( HB_TR_DEBUG, ( "hb_langGetItem(%s,%i)", pszID, iIndex ) ); + + lang = pszID ? hb_langFind( pszID ) : hb_vmLang(); + if( lang && iIndex >= 0 && iIndex < HB_LANG_ITEM_MAX_ ) + return lang->pItemList[ iIndex ]; + else + return NULL; +} + +const char * hb_langID( void ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_langID()" ) ); + + return hb_langGetItem( NULL, HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ); +} + +/* NOTE: Caller must free the pointer. */ + +char * hb_langName( const char * pszID ) +{ + char * pszName; + PHB_LANG lang; + + lang = pszID ? hb_langFind( pszID ) : hb_vmLang(); + if( lang ) + { + pszName = ( char * ) hb_xgrab( 128 ); + hb_snprintf( pszName, 128, "Harbour Language: %s %s (%s)", + hb_langGetItem( pszID, HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ), + hb_langGetItem( pszID, HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ), + hb_langGetItem( pszID, HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) ); + } + else + pszName = hb_strdup( "Harbour Language: (not installed)" ); + + return pszName; +} + +/* Compatibility interfaces */ + +const char * hb_langDGetErrorDesc( int iIndex ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_langDGetErrorDesc(%i)", iIndex ) ); + + return hb_langGetItem( NULL, HB_LANG_ITEM_BASE_ERRDESC + iIndex ); +} + const char * hb_langDGetItem( int iIndex ) { PHB_LANG lang; @@ -407,44 +458,6 @@ const char * hb_langDGetItem( int iIndex ) return NULL; } -const char * hb_langID( void ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_langID()" ) ); - - return hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ); -} - -/* NOTE: Caller must free the pointer. */ - -char * hb_langName( void ) -{ - char * pszName; - PHB_LANG lang; - - lang = hb_vmLang(); - if( lang ) - { - pszName = ( char * ) hb_xgrab( 128 ); - hb_snprintf( pszName, 128, "Harbour Language: %s %s (%s)", - hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ), - hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ), - hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) ); - } - else - pszName = hb_strdup( "Harbour Language: (not installed)" ); - - return pszName; -} - -/* Compatibility interface */ - -const char * hb_langDGetErrorDesc( int iIndex ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_langDGetErrorDesc(%i)", iIndex ) ); - - return hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + iIndex ); -} - /* Harbour interface */ HB_FUNC( __HB_LANGSELECT ) @@ -460,7 +473,7 @@ HB_FUNC( __HB_LANGSELECT ) HB_FUNC( HB_LANGNAME ) { - hb_retc_buffer( hb_langName() ); + hb_retc_buffer( hb_langName( hb_parc( 1 ) ) ); } HB_FUNC( HB_LANGERRMSG ) @@ -470,7 +483,7 @@ HB_FUNC( HB_LANGERRMSG ) HB_FUNC( HB_LANGMESSAGE ) { - hb_retc_const( hb_langDGetItem( hb_parnl( 1 ) ) ); + hb_retc_const( hb_langGetItem( hb_parc( 2 ), hb_parnl( 1 ) ) ); } /* HB_LANGNEW( , , diff --git a/harbour/tests/langapi.prg b/harbour/tests/langapi.prg index 0985707c0b..429a1c4133 100644 --- a/harbour/tests/langapi.prg +++ b/harbour/tests/langapi.prg @@ -5,7 +5,7 @@ // ; Donated to the public domain by // Viktor Szakats (harbour syenar.net) -REQUEST HB_LANG_HU852 +REQUEST HB_LANG_HU REQUEST HB_LANG_KO PROCEDURE Main() @@ -17,7 +17,14 @@ PROCEDURE Main() ? CDoW( Date() ) ? "---------" - ? "Prev:", hb_langSelect( "HU852" ) + ? "Prev:", hb_langSelect( "hu" ) + ? hb_langName() + ? NationMsg( 1 ) + ? CMonth( Date() ) + ? CDoW( Date() ) + ? "---------" + + ? "Prev:", hb_langSelect( "ko" ) ? hb_langName() ? NationMsg( 1 ) ? CMonth( Date() ) @@ -31,11 +38,4 @@ PROCEDURE Main() ? CDoW( Date() ) ? "---------" - ? "Prev:", hb_langSelect( "KO" ) - ? hb_langName() - ? NationMsg( 1 ) - ? CMonth( Date() ) - ? CDoW( Date() ) - ? "---------" - RETURN diff --git a/harbour/utils/hbmk2/hbmk2.hu_HU.po b/harbour/utils/hbmk2/hbmk2.hu_HU.po index 66eac4c663..cf275c2153 100644 --- a/harbour/utils/hbmk2/hbmk2.hu_HU.po +++ b/harbour/utils/hbmk2/hbmk2.hu_HU.po @@ -362,11 +362,6 @@ msgstr "" msgid "marks beginning of common options belonging to all targets" msgstr "" -#: hbmk2.prg:7941 hbmk2.prg:11633 hbmk2.prg:13102 -#, c-format -msgid "select C compiler.\\nSpecial value:\\n - bld: use original build settings (default on *nix)" -msgstr "használja a megadott C fordítót.\\nSpeciális érték:\\n - bld: használja a Harbour fordításához használtat (*nix-okon alapértelmezés)" - #: hbmk2.prg:7941 hbmk2.prg:11633 hbmk2.prg:13102 #, c-format msgid "add/exclude C compiler debug info. For Harbour level debug, use Harbour option -b as usual" @@ -954,8 +949,13 @@ msgstr "kapcsolókat adja tovább a szerkesztőnek" #: hbmk2.prg:7941 hbmk2.prg:11633 hbmk2.prg:13102 #, c-format -msgid "select target platform." -msgstr "válasszon cél platformot." +msgid "force/select target platform (default: autodetection)" +msgstr "válassza a megadott cél platformot (alapértelmezés: automatikus)" + +#: hbmk2.prg:7941 hbmk2.prg:11633 hbmk2.prg:13102 +#, c-format +msgid "force/select C compiler (default: autodetection)\nSpecial value:\n - bld: use original build settings (default on *nix)" +msgstr "használja a megadott C fordítót (alapértelmezés: automatikus)\\nSpeciális érték:\\n - bld: használja a Harbour fordításához használtat (*nix-okon alapértelmezés)" #: hbmk2.prg:7941 hbmk2.prg:11633 hbmk2.prg:13102 #, c-format diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index ef4d5dc9ad..e7c9c41bd5 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -14862,8 +14862,8 @@ STATIC PROCEDURE ShowHelp( hbmk, lLong ) { "--hbdirinc" , I_( "output Harbour header directory" ) }, ; { "--hbinfo[=nested]" , I_( "output Harbour build information. Output is in JSON format. The included paths always contain forward slashes. Each JSON block is followed by an 0x0A byte." ) }, ; NIL, ; - { "-plat=" , I_( "select target platform." ) }, ; - { "-comp=" , I_( "select C compiler.\nSpecial value:\n - bld: use original build settings (default on *nix)" ) }, ; + { "-plat=" , I_( "force/select target platform (default: autodetection)" ) }, ; + { "-comp=" , I_( "force/select C compiler (default: autodetection)\nSpecial value:\n - bld: use original build settings (default on *nix)" ) }, ; { "-cpu=" , I_( "select target CPU. (EXPERIMENTAL)" ) }, ; { "-build=" , I_( "use a specific build name" ) }, ; { "-lang=" , I_( "override default language. Similar to HB_LANG envvar." ) }, ; diff --git a/harbour/utils/hbtest/hbtest.prg b/harbour/utils/hbtest/hbtest.prg index f68f172db2..e036212d21 100644 --- a/harbour/utils/hbtest/hbtest.prg +++ b/harbour/utils/hbtest/hbtest.prg @@ -224,7 +224,7 @@ STATIC PROCEDURE TEST_BEGIN( cParam ) /* Set up the initial state */ #ifdef __HARBOUR__ - hb_langSelect( "EN" ) + hb_langSelect( "en" ) #endif SET DATE ANSI SET CENTURY ON