Jump to content
Fivewin Brasil

FWSetLanguage( nNewLanguage )


kapiaba

Recommended Posts

É, acho que a minha versão não havia sido implementado ainda.



#include "FiveWin.ch"
#include "constant.ch"
#include "xbrowse.ch"

static nLanguage,cIniCalc

static oDlgTest

Function test()

//Dialog
Local nBottom := 16.5
Local nRight := 32
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local oDlg

cIniCalc := cFilePath( GetModuleFileName( GetInstance() ) ) + "Calc.ini"

FWAddString( { "+Tax","+Tax", "+Tax", "+Tax", "+Tax", "+Iva" })
FWAddString( { "-Tax","-Tax", "-Tax", "-Tax", "-Tax", "-Iva" })
FWAddString( { "Show","", "", "", "", "Visualizza" })
FWAddString( { "Help","", "", "", "", "Aiuto" })
FWAddString( { "Ribbon","", "", "", "", "Nastro Operazioni" })
FWAddString( { "Options","", "", "", "", "Opzioni" })
FWAddString( { "Preferences","", "", "", "", "Preferenze" })
FWAddString( { "Authors","", "", "", "", "Autori" })

//FWEditStrings() trace to see there are the strings

FWSetLanguage( 6 ) // Italian language

SavePreferences() // save on ini file

LoadPreferences() // read fron ini file

DEFINE DIALOG oDlgTest SIZE nWidth, nHeight PIXEL

ACTIVATE DIALOG oDlgTest CENTER;
on INIt (Load_Buttons(oDlgTest), oDlgTest:SetMenu(BuildMenu() ) )

return nil

Function Load_Buttons(oDlgTest)

Local nlinea5:=10
Local ncol1:= 8.5
Local ncol5:= 30.5
Local n:= 0
Local oBIvap,oBRes

@ n+nlinea5,ncol5 BUTTON oBRes PROMPT ("Change") OF oDlgTest ;
SIZE 63,25 ;
ACTION Preferences()

@ n+ nlinea5,ncol1 BUTTON oBIvap PROMPT FWString( "+Iva" ) OF oDlgtest SIZE 45, 13 ACTION oDlgTest:End()

return nil


function LoadPreferences()


GetIni( cIniCalc, "Lang", "Language", )

return nil

function SavePreferences()

DEFAULT nLanguage := FWSetLanguage()

SetIni( cIniCalc, "Lang", "Language", nLanguage )

return nil

//fron fwdbu source
function Preferences()

local oDlgPref

DEFINE DIALOG oDlgPref TITLE FWString( "Preferences" ) SIZE 400, 300

@ 4.6, 1.5 SAY FWString( "Language" ) OF oDlgPref

DEFAULT nLanguage := FWSetLanguage()

@ 6, 1.2 COMBOBOX nLanguage ;
ITEMS { FWString( "English" ), FWString( "Spanish" ), FWString( "French" ),;
FWString( "Portuguese" ), FWString( "German" ) , FWString( "Italian" ) } ;
OF oDlgPref SIZE 180, 150 ;
ON CHANGE ( FWSetLanguage( nLanguage ), oDlgtest:SetMenu( BuildMenu() ) )

@ 7, 7 BUTTON FWString( "&Ok" ) OF oDlgPref SIZE 45, 13 ;
ACTION ( SavePreferences(), oDlgPref:End() )

@ 7, 18 BUTTON FWString( "&Cancel" ) OF oDlgPref SIZE 45, 13 ACTION oDlgPref:End()

ACTIVATE DIALOG oDlgPref CENTERED

return nil

Function BuildMenu()

Local oMenu

MENU oMenu


MENUITEM fwstring("Visualizza")
MENU
MENUITEM fwstring("Nastro Operazioni") ACTION NIL
ENDMENU



MENUITEM "&?"
MENU
MENUITEM fwstring("Aiuto") ACTION HelpIndex()
SEPARATOR
MENUITEM fwstring("Opzioni") ACTION NIL

MENUITEM fwstring("Preferenze") Action NIL

SEPARATOR
MENUITEM fwstring("Autori") ACTION NIL
ENDMENU

ENDMENU

RETURN (oMenu)

STATIC FUNCTION SetIni( cIni, cSection, cEntry, xVar )

LOCAL oIni

// DEFAULT cIni := oApp:cIniFile

INI oIni FILE cIni
SET SECTION cSection ;
ENTRY cEntry ;
TO xVar ;
OF oIni
ENDINI

RETURN nil

//------------------------------------------------------------------//

STATIC FUNCTION GetIni( cIni, cSection, cEntry, xDefault )

LOCAL oIni
LOCAL xVar := xDefault

//DEFAULT cIni := oApp:cIniFile

INI oIni FILE cIni
GET xVar ;
SECTION cSection ;
ENTRY cEntry ;
DEFAULT xDefault ;
OF oIni
ENDINI

RETURN xVar


Link to comment
Share on other sites

Amiguinhos,

Recurso interessante e neste caso seria necessário um único .PRG contendo string de mensagens e labels do aplicativo em várias linguas.

Kapiaba

O melhor ainda seria voce utilizar o salvamento de strings em .RC e uma .DLL para cada lingua. Um SET RECOURCES TO ... resolveria em tempo de execução.

Dentro de seu aplicativo voce não mais colocaria strings de mensagens e labels o que economizaria na compilação. Cada string teria um identificador unico que poderia se referir a variavel unica contendo a string internacionalizada.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...