by MdaSolution » Mon Dec 13, 2010 10:37 am
on new xharbour you must insert this parameter
/jnamefilelanguage.HIT
and xharbour create this files
then you can use i18n() function to call values
sample :
x,y say osay prompt i18n("me gustaria...")
on main.prg
you must insert
REQUEST HB_Lang_ES
REQUEST HB_CODEPAGE_ESWIN
and then you must insert also
HB_LangSelect("ES")
to select lang tou can add into your application this function/methods
METHOD Idiomas() CLASS tApplication
LOCAL aMat := GetLang(), oBmp
LOCAL oDlg, oLbx, lSeguir := .F.
IF Empty( aMat )
MsgStop( i18n( "No hay idiomas que cargar!" ), oApp:cTitulo )
RETURN NIL
ENDIF
aMat := GetCodes( aMat )
DEFINE DIALOG oDlg FROM 117, 412 TO 430, 832 PIXEL ;
TITLE i18n( "Seleccione el Idioma a utilizar" )
@0.8,0.2 LISTBOX oLbx FIELDS ;
HEADERS i18n( "Codigo" ), i18n( "Descripcion" ) ;
size 203,80 OF oDlg FIELDSIZES 80, 200 UPDATE ;
ON DBLCLICK ( lSeguir := .T., oDlg:END() )
oLbx:nAt := 1
oLbx:bLine := { || { ;
aMat[ oLbx:nAt, 1 ] , ;
aMat[ oLbx:nAt, 2 ] ;
} }
oLbx:bGoTop := { || oLbx:nAt := 1 }
oLbx:bGoBottom := { || oLbx:nAt := Eval( oLbx:bLogicLen ) }
oLbx:bSkip := { | nWant, nOld | nOld := oLbx:nAt, oLbx:nAt += nWant, ;
oLbx:nAt := Max( 1, Min( oLbx:nAt, Eval( oLbx:bLogicLen ) ) ), ;
oLbx:nAt - nOld }
oLbx:bLogicLen := { || Len( aMat ) }
oLbx:SetArray( aMat )
oLbx:lCellStyle := .F.
oLbx:nLineStyle := 3
@ 120, 75 BUTTON i18n( "&Aceptar" ) OF oDlg SIZE 50, 12 PIXEL ACTION ( lSeguir := .T., oDlg:END() )
@ 120, 142 BUTTON i18n( "&Cancelar" ) OF oDlg SIZE 50, 12 PIXEL ACTION ( oDlg:END() )
ACTIVATE DIALOG oDlg CENTERED
IF lSeguir
HB_I18NSetLanguage( aMat[ oLbx:nAt, 1 ] )
fSetLang( aMat[ oLbx:nAt, 1 ],::cFileIni )
ENDIF
RETURN NIL
// -------------------------------------------------------------------------------------------- //
FUNCTION GetCodes( aFiles )
LOCAL aIdiomas := {}, i, aLang
LOCAL cPath := ( CurDrive() + ":\" + CurDir() ) + "\i18n\"
LOCAL cFile
FOR i:= 1 TO Len( aFiles )
cFile := cPath + aFiles[ i ] + ".hil"
aLang := HB_I18nLoadTable( cFile )
AAdd( aIdiomas, { aLang[ 1, 5 ], aLang[ 1, 3 ] } )
NEXT i
RETURN aIdiomas
// -------------------------------------------------------------------------------------------- //
FUNCTION fSetLang( cLang,cFileIni )
LOCAL oIni
INI oIni FILE cFileIni
SET SECTION "Config" ENTRY "Idioma" TO cLang OF oIni
ENDINI
RETURN NIL
FWH .. BC582.. xharbour