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
This commit is contained in:
Viktor Szakats
2013-01-30 17:32:39 +00:00
parent b6eae0ed1d
commit 4cccb2bd26
10 changed files with 139 additions and 84 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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( <nMsg> ) --> cMessage
hb_langMessage( <nMsg>[, <cLangID>] ) --> cMessage
$ARGUMENTS$
<nMsg> is the message number to get.
<nMsg> is the message number to get.
<cLangID> 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 <nMsg>.
$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( [<cLangID>] ) --> cLangName
$ARGUMENTS$
None.
<cLangID> is an optional language module ID. Uses the currently
selected language module, if not specified.
$RETURNS$
<cLangName> Name of the current language in use
<cLangName> 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( "<non-existent>" )
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( [ <cNewLang> ][, <cCodepage> ] ) --> cOldLang
hb_langSelect( [<cNewLang>][, <cCodepage>] ) --> cOldLang
$ARGUMENTS$
<cNewLang> The optional ID of the country language module.
<cNewLang> The optional ID of the language module.
Possible values for <cNewLang> are below as defined in the
Lang library, sorted by language.
<cCodepage> Optional codepage ID into which the language
@@ -270,7 +278,7 @@
$SYNTAX$
hb_cdpSelect( [<cNewLang>] ) --> cOldLang
$ARGUMENTS$
<cNewLang> The optional ID of the country language module.
<cNewLang> The optional ID of the language module.
Possible values for <cNewLang> 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

View File

@@ -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

View File

@@ -4,5 +4,5 @@
/* Viktor Szakats (harbour syenar.net) */
#define HB_CP_UPPER "A~Á~À~Â~ÃBC~ÇD~ÐE~É~È~Ê~ËFGHI~Í~Ì~Î~ÏJKLMNO~Ó~Ò~Ô~ÕPQRSTU~Ú~Ù~ÛV~WXY~Ý~Ÿ~ÜZÅÄ~ÆÖ~Ø~Œ"
#define HB_CP_UPPER "A~Á~À~Â~ÄBCDE~É~È~Ê~ËFGHI~Í~Ì~Î~ÏJKLMNO~Ó~Ò~Ô~ÖPQRSTU~Ú~Ù~Û~ÜVWXYZ"
#define HB_CP_LOWER "a~á~à~â~äbcde~é~è~ê~ëfghi~í~ì~î~ïjklmno~ó~ò~ô~öpqrstu~ú~ù~û~üvwxyz"

View File

@@ -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( <cNewLangId>, <cNewLangCpId>,

View File

@@ -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

View File

@@ -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

View File

@@ -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=<platform>" , I_( "select target platform." ) }, ;
{ "-comp=<compiler>" , I_( "select C compiler.\nSpecial value:\n - bld: use original build settings (default on *nix)" ) }, ;
{ "-plat=<platform>" , I_( "force/select target platform (default: autodetection)" ) }, ;
{ "-comp=<compiler>" , I_( "force/select C compiler (default: autodetection)\nSpecial value:\n - bld: use original build settings (default on *nix)" ) }, ;
{ "-cpu=<cpu>" , I_( "select target CPU. (EXPERIMENTAL)" ) }, ;
{ "-build=<name>" , I_( "use a specific build name" ) }, ;
{ "-lang=<lang>" , I_( "override default language. Similar to HB_LANG envvar." ) }, ;

View File

@@ -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