TO Antonio : Languages

TO Antonio : Languages

Postby Silvio.Falconi » Thu Sep 19, 2013 10:01 am

Antonio,
Ithinked to create the possibility to have a file type Lang.lng and insert on this all texts

sample :

Code: Select all  Expand view

[Lang]
1=Attention |Atención|Attention|Atenção|Achtung |Attenzione
2=PDF Plugin Error|Error del plugin de PDF|Erreur de plugin du PDF|Erro do plugin do PDF|PDF Plugin Fehler|Errore del plug PDF
3=PDF not saved to send Email|No se ha guardado el PDF a enviar por Email|PDF Non enregistré pour envoi Email|PDF não foi salvo para mandar por email|PDF nicht gespeichert. um E-Mail zu senden|PDF non salvato per inviare e-mail
 



and then I made this function to load astrings from lang.lng
Code: Select all  Expand view
#INCLUDE "FiveWin.ch"
#INCLUDE "Xbrowse.ch"



Function test()
   Local cIni:=cFilePath(GetModuleFileName( GetInstance() ) ) + "lang.lng"
   LOCAL cString    :=""
   LOCAL aStrings   := {}
   LOCAL i          := 1
   LOCAL lContinue  := .T.


 DO WHILE lContinue = .T.
         cString :=  GetIni( cIni, "LANG", ALLTRIM(STR(i++,4)), "" )
      IF .NOT. EMPTY( cString )
         AADD( aStrings, { ALLTRIM( StrToken( cString, 1, "|" ) ), ;
                          ALLTRIM( StrToken(  cString, 2, "|" ) ), ;
                          ALLTRIM( StrToken(  cString, 3, "|" ) ), ;
                          ALLTRIM( StrToken(  cString, 4, "|" ) ), ;
                          ALLTRIM( StrToken(  cString, 5, "|" ) ), ;
                          ALLTRIM( StrToken(  cString, 6, "|" ) ) } )
      ELSE
         lContinue := .F.
      ENDIF
   ENDDO
   IF LEN( aStrings ) = 0
      MsgStop( "No languages defined in " + ALLTRIM( cIni ) )
      RETURN(.F.)
   ELSE
      //only for trace
      xbrowser aStrings
   ENDIF
   RETURN (.T.)

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

 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





then we can have a file into application folder and modify it with a xbrowse

What Do you think about ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: TO Antonio : Languages

Postby Silvio.Falconi » Thu Sep 19, 2013 2:32 pm

to create Lang file od fwdbu you can use this

Function Crea_File()
Local aStrings := {{ "Attention", "Atención", "Attention", "Atenção", "Achtung", "Attenzione" } }

Local cIni:=cFilePath(GetModuleFileName( GetInstance() ) ) + "lang.lng"
Local cReport := ""

xbrowser astrings

FOR i:=1 TO Len(aStrings)
cReport := alltrim(aStrings[i][1]) + "|" +;
alltrim(aStrings[i][2]) + "|" +;
alltrim(aStrings[i][3]) + "|" +;
alltrim(aStrings[i][4]) + "|" +;
alltrim(aStrings[i][5]) + "|" +;
alltrim(aStrings[i][6])
WritePProString("LANG",ALLTRIM(STR(i,4)),cReport,cIni)
NEXT i
RETURN NIL


the problem is if on astring[i] not found the text it make error
and I have not the last astring of fwdbu to try
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 104 guests