Multi Language Menu?

Multi Language Menu?

Postby dutch » Tue Nov 29, 2011 11:21 am

Dear All,

I would like to put the menu language in text file (maybe INI or TXT).

Any idea most welcome.

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Multi Language Menu?

Postby ukoenig » Tue Nov 29, 2011 4:22 pm

Hello Dutch,

A INI-file will do the Job.
I will create a Sample for this.
Do You want to change the Language at Runtime or with a Setup at Start ?

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Multi Language Menu?

Postby ukservice » Tue Nov 29, 2011 5:01 pm

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: Multi Language Menu?

Postby FiveWiDi » Tue Nov 29, 2011 5:11 pm

dutch wrote:Dear All,

I would like to put the menu language in text file (maybe INI or TXT).

Any idea most welcome.

Regards,
Dutch


Yes,
Hola,

Esta es mi solución. Seguro que se puede mejorar.

Al principio de la ejecución de la aplicación se debe realizar:

SetFileIdioma( "C:\yourfolder\yourlenguages\spanishforexemple.ini" )
SetIdioma( "SPA" )

Durante la ejecución de la aplicación se puede realizar en cualquier momento:

SetFileIdioma( "C:\yourfolder\yourotherlenguages\inFrenchforexemple.ini" )
SetIdioma( "FRE" )


Y en los literales que se deseen traducir se debe usar:

GetTrad( "Esto es un Texto de EJEMPLO!" )

Se debe tener en cuenta que el parámetro que recibe la función GetTrad() es el literal escrito en el idioma original de la aplicación.

Esto vale para GET, MENU, MSGAlert(),... y cualquier función u objeto que tenga un texto a traducir.


Y además no es lo mismo:

"Esto es un Texto de EJEMPLO!"

que:

"ESTO ES UN TEXTO DE ejemplo!"


Saludos
Carlos G.

Code: Select all  Expand view



/* Cómo se usa:

   - Se asume que en la definición de los WINDOW/DIALOG/SAY/... estaran los literales en
     el idioma por defecto, los cuales no seran traducidos por esta utilidad.

   - En este código debemos substituir "CAT" por el código de nuestro idioma escogido
     como de la aplicación.


A tener en cuenta:

   -El idioma asumido de la aplicación és el CAT, buscar "CAT" i cambiar por el deseado.

   -En las condiciones de la licencia de nuestra aplicación debemos especificar que garantizamos
   su buen funcionamiento en este idioma, dado que el usuario podría crear el suyo propio y en
   ese caso sería su resonsabilidad.

   -Para su uso en nuestra aplicación, en sus primeras instrucciones debemos especificar en que
   fichero estan las traducciones ( SetFileIdioma( cFileIdioma ) ), y en que idioma estaremos
   trabajando ( SetIdioma( cIdioma ) ).
   --------------------------------------------------------------------------------------------- */


#include "FiveWin.ch"

/* Idioma de l'aplicació.
   ------------------- */

STATIC ScIdioma     := ""
/* ******************* */

/* Fitxer de l'Idioma de l'aplicació.
   ------------------------------- */

STATIC ScFileidioma := ""
/* ******************************* */
/* ******************************* */

/* Array d'arrays de 3 elements.
    1er. literal que es tornarà a l'aplicació; si no té contingut per defecte el del CAT precedit de "_".
    2on. literal original llegit del fitxer (conté "|").
    3er. literal natiu (en aquest cas en català).

   El seu ús té dues finalitats:

   - Guardar el literal per si es torna a usar i evitar així
     l'accés a disc.

   - Permetre l'enregistrament a fitxer dels literals usats.
   --------------------------------------------------------------------------------------------------- */

STATIC aTextes := {}
/* *************************************************************************************************** */
/* *************************************************************************************************** */

/* *************************************** */
/* *************************************** */
FUNCTION SetFileIdioma( cFileIdioma )
// Debe comenzar con el nombre de una carpeta o el nombre del fichero.
// No debe comenzar en '' ni con la letra de la unidad.
// cFileIdioma -->> micarpetita\chiquitita\elficherito.ini
// ó cFileIdioma -->> elficherito.ini
Local cDummy := ScFileIdioma

If .Not. Empty( cFileIdioma )
    ScFileidioma := cFileidioma
EndIf

Return cDummy
/* *************************************** */
/* *************************************** */
FUNCTION SetIdioma( cIdioma )
// cIdioma -->> ESP, CAS, CAT, LAT, VAL, GAL, EUS, ELMIO, ELTUYO, ELMASGUAY, etc.
Local cDummy := ScIdioma
Local oIni   := Nil

//Traza( 1, "cIdioma=", cIdioma )

If .Not. Empty( cIdioma )
    If ScIdioma <> cIdioma
        aSize( aTextes, 0 )
        ScIdioma := cIdioma

        If Empty( ScFileidioma )
            SetFileIdioma( cIdioma )
        EndIf

        INI oIni FILE cfilepath( Arg( 0 ) ) + ScFileidioma
        SaveIdiomaDescrip( oIni )
        ENDINI

    EndIf
EndIf

Return cDummy
/* *************************************** */
/* *************************************** */
STATIC FUNCTION SaveIdiomaDescrip( oIni )
Local cDummy := ""

// Els idiomes ARA, CAT, ESP, EUS, GAL, LAT i VAL tenen descriptiu ESPECÍFIC.

GET cDummy SECTION ScIdioma ENTRY "DESCRIP" OF oIni

If ScIdioma = "ARA" .and. cDummy <> "Aranès"    // A
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Aranès" OF oIni
ElseIf ScIdioma = "CAT" .and. cDummy <> "Català"  // C
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Català" OF oIni
ElseIf ScIdioma = "ESP" .and. cDummy <> "Español"  // E
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Español" OF oIni
ElseIf ScIdioma = "EUS" .and. cDummy <> "Euskera"  // U
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Euskera" OF oIni
ElseIf ScIdioma = "GAL" .and. cDummy <> "Galego"  // G
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Galego" OF oIni
ElseIf ScIdioma = "LAT" .and. cDummy <> "Latium"  // L
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Latium" OF oIni
ElseIf ScIdioma = "VAL" .and. cDummy <> "Valencià"  // V
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Valencià" OF oIni

/* La resta d'idiomes tenen el descriptiu per defecte o el que hagi
   enregistrat l'usuari. Per aquest motiu es fa un GET amb DEFAULT.
   ------------------------------------------------------------- */

ElseIf .Not. (ScIdioma $ "/ARA/CAT/ESP/EUS/GAL/LAT/VAL/")
    GET cDummy SECTION ScIdioma ENTRY "DESCRIP" OF oIni DEFAULT "*" + ScIdioma + "*"
EndIf


/*
// Els idiomes CAT, ESP, VAL, GAL, EUS i ARA tenen descriptiu ESPECÍFIC.
If ScIdioma = "ARA"   // A
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Aranès" OF oIni
ElseIf ScIdioma = "CAT"  // C
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Català" OF oIni
ElseIf ScIdioma = "ESP"  // E
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Español" OF oIni
ElseIf ScIdioma = "EUS"  // U
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Euskera" OF oIni
ElseIf ScIdioma = "GAL"  // G
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Galego" OF oIni
ElseIf ScIdioma = "LAT"  // L
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Latium" OF oIni
ElseIf ScIdioma = "VAL"  // V
    SET SECTION ScIdioma ENTRY "DESCRIP" TO "Valencià" OF oIni

 La resta d'idiomes tenen el descriptiu per defecte o el que hagi
   enregistrat l'usuari. Per aquest motiu es fa un GET amb DEFAULT.
   -------------------------------------------------------------
Else
    GET cDummy SECTION ScIdioma ENTRY "DESCRIP" OF oIni DEFAULT "*" + ScIdioma + "*"
EndIf
*/


Return Nil
/* ***************************************** */
/* Per compatibilitat amb versions anteriors */
FUNCTION GetText( nElemento, ccText )
Return GetTrad( nElemento, ccText )
/* *************************************** */
FUNCTION GetTrad( nElemento, ccText )
Local cText := ""
Local nText := 0

cText := nElemento

/* Per compatibilitat amb desenvolupament anterior.
   --------------------------------------------- */

If ValType( nElemento ) = "N"
    cText := ccText
EndIf


/* Si l'idioma és el de l'aplicació (en aquest cas CAT), es
   pren com a literal el rebut a cText.
   ----------------------------------------------------- */

If ScIdioma = "CAT"

    If AScan( aTextes, { |eTextes| eTextes[3] = cText } ) = 0
        ////AADD( aTextes, { cText, "|" + cText + "|", "|" + StrTran(cText, "=", chr(126) + "#") + "|" } )
        //AADD( aTextes, { cText, "|" + cText + "|", ConvertCadena( cText ) } )
        AADD( aTextes, { cText, "|" + cText + "|", cText  } )
    EndIf

    Return cText

ElseIf ScIdioma <> "" // Altres idiomes.

    ////If ( nText := AScan( aTextes, { |eTextes| eTextes[3] = ("|" + StrTran(cText, "=", chr(126) + "#") + "|") } ) ) = 0
    //If ( nText := AScan( aTextes, { |eTextes| eTextes[3] = ( ConvertCadena( cText ) ) } ) ) = 0
    If ( nText := AScan( aTextes, { |eTextes| eTextes[3] = cText } ) ) = 0

        LoadTexto( cText )

        nText := Len(aTextes)

    EndIf

    Return aTextes[ nText ][1]

EndIf

Return "_" + cText
/* *************************************** */
/* *************************************** */
STATIC FUNCTION LoadTexto( cText )
Local oIni      := Nil
Local cDummy    := ""

////AADD( aTextes, { "", "", "|" + StrTran( cText, "=", Chr(126) + "#" ) + "|" } )
//  AADD( aTextes, { "", "", ConvertCadena( cText ) } )
  AADD( aTextes, { "", "", cText } )

/* Inicio del objeto oIni utilizado para la captura de los valores de LGAMPA32.INI.
   ----------------------------------------------------------------------------- */

INI oIni FILE cfilepath( Arg( 0 ) ) + ScFileidioma
//GET cDummy SECTION ScIdioma ENTRY ("|" + StrTran( cText, "=", Chr(126) + "#" ) + "|") OF oIni DEFAULT ( "|_" + cText + "|" )
  GET cDummy SECTION ScIdioma ENTRY ( ConvertCadena( cText ) ) OF oIni DEFAULT ( "|_" + cText + "|" )
ENDINI


// Es guarda la captura original.
aTextes[ Len(aTextes) ][ 2 ] := cDummy

If LefT( cDummy, 1 ) = "|"
    cDummy := SubStr( cDummy, 2 )
EndIf

If Right( cDummy, 1 ) = "|"
    cDummy := Left( cDummy, Len(cDummy) -1 )
EndIf

// Es guarda el text que utilitzarà la aplicació.
aTextes[ Len(aTextes) ][ 1 ] := cDummy

Return Nil
/* *************************************** */
/* *************************************** */
FUNCTION SaveIdiomaTextos()
Local nDummy    := 0
Local nContador := 0
Local oIni      := Nil

nDummy    := Len( aTextes )

INI oIni FILE cfilepath( Arg( 0 ) ) + ScFileidioma

For nContador := 1 To nDummy

    SET SECTION ScIdioma ENTRY ConvertCadena( aTextes[ nContador ][3] ) TO aTextes[ nContador ][2] OF oIni

Next

ENDINI

Return Nil
/* *************************************** */
/* *************************************** */
FUNCTION ConvertCadena( cText )
Local nContador := 0
Local cDummy    := ""
Local lUpper    := .F.

//Traza( 1, "a-cText=", cText )

cText := " " + cText + " "

For nContador := 1 To Len( cText )

    If IsUpper( SubStr( cText, nContador, 1 ) ) .and. .Not. lUpper
        lUpper := .T.
        cDummy := cDummy + "|" + Chr(126) + SubStr( cText, nContador, 1 )
    ElseIf IsLower( SubStr( cText, nContador, 1 ) ) .and. lUpper
        lUpper := .F.
        cDummy := cDummy + Chr(126) + "|" + SubStr( cText, nContador, 1 )
    Else
        cDummy := cDummy + SubStr( cText, nContador, 1 )
    EndIf

Next

cDummy := SubStr( cDummy, 2 )
cDummy := Left( cDummy, Len( cDummy) - 1 )

cDummy := StrTran( cDummy, "=", Chr(126) + "#" )

cDummy := "|" +cDummy + "|"

//Traza( 1, "b-cDummy=", cDummy )

Return cDummy
/* *************************************** */
/* *************************************** */
FUNCTION CreaMenuIdioma( AMPAARRA )
Local oIni      := Nil
Local aIdiomas  := {}
Local nContador := 0
Local cDummy    := ""
Local cIdioma   := ""

INI oIni FILE cfilepath( Arg( 0 ) ) + ScFileidioma

aIdiomas := oIni:Sections()

For nContador := 1 To Len( aIdiomas )

    cIdioma   := aIdiomas[nContador]

    // L'idioma CAT no s'afegeix al menú per que ho ha estat directament des de codi.
    If cIdioma <> "CAT"

        GET cDummy SECTION aIdiomas[nContador] ENTRY "DESCRIP" OF oIni

        CreaMenuIdioma2( AMPAARRA, cDummy, cIdioma )

    EndIf

Next

ENDINI

Return Nil
/* *************************************** */
/* *************************************** */
STATIC FUNCTION CreaMenuIdioma2( AMPAARRA, cDummy, cIdioma )
Local oElMenu := Nil


MENUITEM oElMenu PROMPT cDummy + " <-> " + cIdioma ;
                                    MESSAGE cIdioma ;
                                    ACTION ( AMPAarra[1][2][ 11 ][ 3 ] := cIdioma, ;
                                             SetIdioma( AMPAarra[1][2][ 11 ][ 3 ] ), ;
                                             AMPAArra[1][1][2][1][1]:SetMenu( MenuMain( AMPAarra ) ) ;
                                           ) ;
                                    WHEN ( oElMenu:SetCheck(SetIdioma() == cIdioma), .T. )


//                                             AMPAArra[1][1][2][1][1]:SetMenu( MenuMain( AMPAarra ) ) ) ;
/*
oElMenu := MenuAddItem( cDummy + " <-> " + cIdioma, cIdioma, .F.,, {|oMenuItem|( AMPAarra[1][2][ 11 ][ 3 ] := cIdioma,  SetIdioma( AMPAarra[1][2][ 11 ][ 3 ] ), ;
                                                                                 AMPAArra[1][1][2][1][1]:SetMenu( MenuMain( AMPAarra ) ) ;
                                                                               ) ;
                                                                   }, ;
                        ,,,,,, .F.,, {|| ( oElMenu:SetCheck(SetIdioma() == cIdioma), .T. )}, .F. )
*/

/*
           MenuAddItem( cDummy + " <-> " + cIdioma, cIdioma, .F.,, {|oMenuItem|( AMPAarra[1][2][ 11 ][ 3 ] := cIdioma,  SetIdioma( AMPAarra[1][2][ 11 ][ 3 ] ), ;
                                                                                 AMPAArra[1][1][2][1][1]:SetMenu( MenuMain( AMPAarra ) ) ;
                                                                               ) ;
                                                                   }, ;
                        ,,,,,, .F.,, {|| ( SetIdioma() <> cIdioma)}, .F. )
*/

Return Nil
/* *************************************** */
/* *************************************** */

 
Un Saludo
Carlos G.

FiveWin 24.02 + Harbour 3.2.0dev (r2403071241), BCC 7.7 Windows 10
FiveWiDi
 
Posts: 1189
Joined: Mon Oct 10, 2005 2:38 pm

Re: Multi Language Menu?

Postby dutch » Wed Nov 30, 2011 3:19 am

Dear Uwe,

I just need on start-up program.

ukoenig wrote:Hello Dutch,

A INI-file will do the Job.
I will create a Sample for this.
Do You want to change the Language at Runtime or with a Setup at Start ?

Best Regards
Uwe :lol:

Thanks,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Multi Language Menu?

Postby dutch » Wed Nov 30, 2011 4:08 am

Dear All,

Can I use this INI file to contain the menu language?
How can I get all the menu language in 1 array without loop? Because I need to read all the menu language in array variable on start up program.
In this way, I think other people can add more language without change any program.
Code: Select all  Expand view
[MAIN]
LANGAUGE=English,Spanish,German
[MENU]
1001=Reservation,Reserva,Reservierung
1002=Search,Búsqueda,Suche


Any idea are most appreciated.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Multi Language Menu?

Postby Horizon » Wed Nov 30, 2011 9:29 am

Another way.

Code: Select all  Expand view
[MAIN]
LANGAUGE=English,Spanish,German
[English]
1001=Reservation
1002=Search
[Spanish]
1001=Reserva
1002=Búsqueda
[German]
1001=Reservierung
1002=Suche
 
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Multi Language Menu?

Postby ukoenig » Wed Nov 30, 2011 12:44 pm

Hello Hakan,

that is the Structure I`m working on. The logic workes fine ( tested ).
I will add a complete Sample.

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Multi Language Menu?

Postby StefanHaupt » Wed Nov 30, 2011 3:28 pm

Dutch,

look at the new errorsys, there you have one way, to get more than one language. You can also use several dll files, for every language another, like it´s done with preview.dll.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Multi Language Menu?

Postby dutch » Wed Nov 30, 2011 3:59 pm

Hi Hakan,

Do you get the menu language at runtime or read all to array on start-up?
How did you do?
Horizon wrote:Another way.

Code: Select all  Expand view
[MAIN]
LANGAUGE=English,Spanish,German
[English]
1001=Reservation
1002=Search
[Spanish]
1001=Reserva
1002=Búsqueda
[German]
1001=Reservierung
1002=Suche
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Multi Language Menu?

Postby ukoenig » Wed Nov 30, 2011 4:30 pm

Hello Dutch,
the promised sample :

Code: Select all  Expand view

#INCLUDE "FIVEWIN.CH"

STATIC cLanguage := "ENG"
STATIC aMenu

FUNCTION Main()
LOCAL oWnd

aMenu := { { "" }, { "" } }

GET_INI()

DEFINE WINDOW oWnd FROM 50, 200 TO 300, 700 TITLE "Testing Menus" ;
MENU BuildMenu() PIXEL

oWnd:bMenuSelect = { || MsgBeep() }   // Do whatever on each menuitem
                                         // selection!

SET MESSAGE OF oWnd TO FWVERSION + " Multi-Language-Menu"

ACTIVATE WINDOW oWnd

RETURN NIl

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

FUNCTION BUILDMENU()
local oMenu
local oFirst, oSecond
local oItHelp

MENU oMenu
    MENUITEM "&1. Menu"
    MENU
        MENUITEM oFirst PROMPT aMenu[1] MESSAGE "First option" ;
        ACTION If( oFirst:lActive, oFirst:Disable(), oFirst:Enable() ) ;
        ACCELERATOR ACC_ALT, VK_F2

        MENUITEM oSecond PROMPT aMenu[2] MESSAGE "Second option" ;
        ACTION oSecond:SetCheck( ! oSecond:lChecked ) ;
        ACCELERATOR ACC_CONTROL, VK_F2
      ENDMENU

      MENUITEM "& 2. Menu"
      MENU
        MENUITEM "&Enable" ACTION oFirst:Enable() ;
        MESSAGE "Ok, let's start again"
      ENDMENU

ENDMENU

RETURN OMENU

// --------- INI - Read -------------

FUNCTION GET_INI()
Local oInifile
Local cMen1S := "", cMen2S := ""
Local cMen1E := "", cMen2E := ""
Local cMen1G := "", cMen2G := ""

IF !FILE ( c_path + "\MENU.ini" )
    SAVE_INI()
ELSE
    INI oInifile FILE c_path + "\MENU.ini"
        GET  cLanguage  SECTION  "Select"       ENTRY   "Language"  OF oInifile 
       
        GET  cMen1S     SECTION  "1001"     ENTRY   "Spanish"       OF oInifile 
        GET  cMen2S     SECTION  "1002"     ENTRY   "Spanish"       OF oInifile 

        GET  cMen1E     SECTION  "1001"     ENTRY   "English"       OF oInifile 
        GET  cMen2E     SECTION  "1002"     ENTRY   "English"       OF oInifile        

        GET  cMen1G     SECTION  "1001"     ENTRY   "German"        OF oInifile 
        GET  cMen2G     SECTION  "1002"     ENTRY   "German"        OF oInifile 

        lSysini := .F.
    ENDINI
ENDIF
IF cLanguage = "SPA"
    aMenu[1] := cMen1S
    aMenu[2] := cMen2S
ENDIF
IF cLanguage = "ENG"
    aMenu[1] := cMen1E
    aMenu[2] := cMen2E
ENDIF
IF cLanguage = "GER"
    aMenu[1] := cMen1G
    aMenu[2] := cMen2G
ENDIF

// MsgAlert( aMenu[1], "Menu 1" )
// MsgAlert( aMenu[2], "Menu 2" )

RETURN( NIL )

// ---------  INI Write------------------------

FUNCTION SAVE_INI()
LOCAL lSysini := .T., cIniFile := c_path + "\MENU.INI"

Local cMen1S := "&Reserva", cMen2S := "&Búsqueda"
Local cMen1E := "&Reservation", cMen2E := "&Search"
Local cMen1G := "&Reservierung", cMen2G := "&Suche"

IF cLanguage = "SPA"
    cMen1S := aMenu[1]
    cMen2S := aMenu[2]
ENDIF
IF cLanguage = "ENG"
    cMen1E := aMenu[1]
    cMen2E := aMenu[2]
ENDIF
IF cLanguage = "GER"
    cMen1G := aMenu[1]
    cMen2G := aMenu[2]
ENDIF

IF WritePProString( "Select", "Language", cLanguage,  cIniFile ) = .F.
        lSysini := .F.
ENDIF
// --------------
IF WritePProString( "Spanish", "1001", cMen1S,  cIniFile ) = .F.
        lSysini := .F.
ENDIF
IF WritePProString( "Spanish", "1002", cMen2S,  cIniFile ) = .F.
        lSysini := .F.
ENDIF
// --------------
IF WritePProString( "English", "1001", cMen1E ) = .F.
        lSysini := .F.
ENDIF
IF WritePProString( "English", "1002", cMen2E ) = .F.
        lSysini := .F.
ENDIF
// --------------
IF WritePProString( "German", "1001", cMen1G,  cIniFile ) = .F.
        lSysini := .F.
ENDIF
IF WritePProString( "German", "1002", cMen2G,  cIniFile ) = .F.
        lSysini := .F.
ENDIF
// ---------------
IF lSysini = .F. .or. !FILE( cInifile )
    MsgAlert("Not possible, to write in  INI-File", "INI-File")
ENDIF

RETURN( NIL )
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Multi Language Menu?

Postby sambomb » Wed Nov 30, 2011 4:56 pm

Code: Select all  Expand view

****************************************************************************
function Get4Ini(pcSecao, pcVar, pcFileName)
****************************************************************************

local Result := ""

   oIni   := TIni():New( (pcFileName) )
   Result := oIni:Get( pcSecao, pcVar,, Result )
   oIni   := Nil

   if Right(Result,3) == "{N}"
      Result := Val( Left( Result , Len(Result)-3 ) )
   elseif Right(Result,3) == "{D}"
          Result := CToD( Left( Result , Len(Result)-3 ) )
   elseif Right(Result,3) == "{L}"
          Result := If("True" $ Result, .t. , .f. )
   end

return Result

/*------------------------------------------------------------------------*/

****************************************************************************
procedure Set4Ini(pcSecao, pcVar, puValor, pcFileName, lTag)
****************************************************************************

local oIni

   Default lTag := .t.

   if ValType(puValor) = "N"
      puValor := AllTrim(Str(puValor)) + if(lTag,"{N}","")
   elseif ValType(pcVar) = "D"
          puValor := AllTrim(DToC(puValor)) + if(lTag,"{D}","")
   elseif ValType(puValor) = "L"
          puValor := if(puValor,"True","False") + if(lTag,"{L}","")
   elseif ValType(puValor) = "C"
          puValor := AllTrim(puValor)
   end

   oIni := TIni():New( (pcFileName) )
   oIni:Set( pcSecao , pcVar , puValor )
   oIni := Nil

return nil

/*------------------------------------------------------------------------*/


cFileIni := "C:\MySystem.INI"
cLang := Get4Ini("GENERAL","LANG",cFileIni)

    menu Result 2007

        menuitem Get4Ini(cLang,"MENU100",cFileIni)
            menu
 
                menuitem    Get4Ini(cLang,"MENU1001",cFileIni);
            message     Get4Ini(cLang,"MENU1001A",cFileIni);
            accelerator ACC_NORMAL,VK_F10;
            resource    "Product16";
            action      DlgProd()
           
            separator
 
            menuitem    Get4Ini(cLang,"MENU1002",cFileIni);
            message     Get4Ini(cLang,"MENU1002A",cFileIni);
            accelerator ACC_NORMAL,VK_F10;
            resource    "Client16";
            action      DlgClient()
           
            endmenu
           
            menuitem    Get4Ini(cLang,"MENU1003",cFileIni);
            message     Get4Ini(cLang,"MENU1003A",cFileIni);
            accelerator ACC_NORMAL,VK_F9;
            resource    "Report16";
            action      Reports()              
           
        endmenu
   
        menuitem    Get4Ini(cLang,"MENU200",cFileIni);;
        message     Get4Ini(cLang,"MENU200A",cFileIni);;
        accelerator ACC_NORMAL, VK_ESCAPE;
        action      oWnd:End()

   endmenu
   
   
MySystem.INI   

[GENERAL]
LANG=ENUS
[ENUS]
MENU100="Manage"
MENU1001="Product"
MENU1001A="Open dialog to manage product"
MENU1002="Client"
MENU1002A="Open dialog to manage client"
MENU1003="Report"
MENU1003A="Open dialog to create reports"
MENU200="Exit"
MENU200A="Exit the system"
[PTBR]
MENU100="Gerenciar"
MENU1001="Produtos"
MENU1001A="Abrir dialogo para gerenciar produtos"
MENU1002="Clientes"
MENU1002A="Abrir dialogo para gerenciar clientes"
MENU1003="Relatórios"
MENU1003A="Abrir dialogo para gerar relatórios"
MENU200="Sair"
MENU200A="Sair do sistema"
 
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Multi Language Menu?

Postby dutch » Wed Nov 30, 2011 5:27 pm

Dear All,

Thanks for all kind help. I would like to know one more question.
Which is the best way for memory consumption and program speed.
1. read all menu language to array. (Uwe and Hakan idea)
2. read from ini file each time while building each menu. (Sambomb idea)

Regards,
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Multi Language Menu?

Postby Horizon » Wed Nov 30, 2011 10:14 pm

dutch wrote:Hi Hakan,

Do you get the menu language at runtime or read all to array on start-up?
How did you do?
Horizon wrote:Another way.

Code: Select all  Expand view
[MAIN]
LANGAUGE=English,Spanish,German
[English]
1001=Reservation
1002=Search
[Spanish]
1001=Reserva
1002=Búsqueda
[German]
1001=Reservierung
1002=Suche
 


Hi dutch,

I prefer read only the selected language texts on startup of application. I think the language selection can not be done very often. I dont read all language texts to memory.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: Multi Language Menu?

Postby dutch » Thu Dec 01, 2011 4:38 am

Dear Hakan,
Horizon wrote:Hi dutch,

I prefer read only the selected language texts on startup of application. I think the language selection can not be done very often. I dont read all language texts to memory.

I mean all menu text of chosen language, not only menu but say, msginfo and etc. also. I will read to array and use in all program by choose in array.

Thanks
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests