Adding a Multilanguage-solution to Your App.

Adding a Multilanguage-solution to Your App.

Postby ukoenig » Fri Sep 21, 2012 12:10 pm

Hello,

I started the first time, adding a Multilanguage-option to a App.
First I wanted to use a DBF, but now I found a better Solution.

How it works ( Sample ) :

1.
Define a Static Var cLang[40] // contains the needed Keywords

2.
Array-Init
I := 1
FOR i := 1 TO 40
cLang[I] := " "
NEXT

3.
Load on Top of Your App
GET_LANG() // Get Keywords from INI

4.
Get Keywords from INI
Code: Select all  Expand view

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

FUNCTION GET_LANG()
Local oInifile

IF !FILE ( c_path + "\LANGUAGE.ini" )
    SAVE_LANG()
ELSE
    INI oInifile FILE c_path + "\LANGUAGE.INI"
        GET  cLang[1]  SECTION  "Language"  ENTRY "Game"            OF oInifile DEFAULT "Game"
        GET  cLang[2]  SECTION  "Language"  ENTRY "Trials"          OF oInifile DEFAULT "Trials"
        GET  cLang[3]  SECTION  "Language"  ENTRY "Scores"          OF oInifile DEFAULT "Scores"
        GET  cLang[4]  SECTION  "Language"  ENTRY "Select"          OF oInifile DEFAULT "Select"
        GET  cLang[5]  SECTION  "Language"  ENTRY "Player"          OF oInifile DEFAULT "Player"
        GET  cLang[6]  SECTION  "Language"  ENTRY "Training"      OF oInifile DEFAULT "Training"
        ...
        ...
        GET  cLang[14]  SECTION  "Language" ENTRY "There are missing"   OF oInifile DEFAULT "There are missing"
        ...
        ...
     ENDINI
ENDIF

RETURN( NIL )
 


5.
If not exist, create a new LANGUAGE.INI ( English )

Code: Select all  Expand view

FUNCTION SAVE_LANG()
LOCAL lSysini := .T., cIniFile := c_Path + "\LANGUAGE.INI"

WritePProString( "Language", "Game", "Game",  cIniFile )
WritePProString( "Language", "Trials", "Trials",  cIniFile )
WritePProString( "Language", "Scores", "Scores",  cIniFile )
WritePProString( "Language", "Select", "Select",  cIniFile )
WritePProString( "Language", "Player", "Player",  cIniFile )
WritePProString( "Language", "Training", "&Training",  cIniFile )
WritePProString( "Language", "Reset", "Reset",  cIniFile )
WritePProString( "Language", "Config", "Config",  cIniFile )
WritePProString( "Language", "Create", "Create",  cIniFile )
WritePProString( "Language", "Show", "Show",  cIniFile )
WritePProString( "Language", "Next", "&Next",  cIniFile )
...
...
RETURN( NIL )
 


Samples how to use :

a) Accelerator defined inside the PRG

@ 25, 405 BTNBMP oBtnP[1] FILENAME c_path + "\System\Player1.bmp" ;
SIZE 40, 45 OF oDlg1 PIXEL NOBORDER ;
TOP ;
PROMPT cLang[5] + " &1" ;
FONT oTxtfont ;
ACTION ( nAktPlayer := 1, SET_PLAYER() )
oBtnP[1]:cTooltip := cLang[4] + " 1." + cLang[5]
oBtnP[1]:lTransparent := .T.
oBtnP[1]:l2007 := .F.
oBtnP[1]:SetColor( 128 )

b) Accelerator defined inside the INI
-- Keyword also used for Tooltipps
using a Keyword from INI with a defined Accelerator for Tooltipps, You can use SUBSTR(

@ 140, 455 BTNBMP oBtn[14] FILENAME c_path + "\System\Preview.bmp" ;
SIZE 40, 45 OF oDlg1 PIXEL NOBORDER ;
TOP ;
PROMPT cLang[10] ;
FONT oTxtfont ;
ACTION ( lVISIBLE := .T., ;
READ_GAME(), ;
oBrw1:SetArray( aImg ), oBrw1:Refresh() )
oBtn[14]:cTooltip := cLang[10] + " " + cLang[1]
oBtn[14]:lTransparent := .T.
oBtn[14]:l2007 := .F.
oBtn[14]:SetColor( 16312263 )

The Accelerator is defined inside the INI !!!
Show=&Show

Copy the English LANGUAGE.INI to a new German.ini

with defined Accelerators

[Language]
Game=&Spiel
Trials=&Versuche
Score=&Punkte
Select=&Auswahl
Player=Spie&ler
Training=T&raining
Reset=&zurücksetzen
...
...
Rename to LANGUAGE.INI

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: Adding a Multilanguage-solution to Your App.

Postby Eoeo » Fri Sep 21, 2012 5:35 pm

Sorry BUT xharbour can have the multilanguage system it create on comilation file hil ot hit

and you can call the language on your application using i18n() function


you must first insert on your application the text with i18n() function :
sample :

DEFINE MSGITEM ::oMsgItem2;
OF ::oWndMain:oMsgBar ;
PROMPT ::cEmpresa ;
SIZE 170 ;
TOOLTIP " " + i18n("Company ") + " " FONT ::oFontMsgItem

then you must compile the prg with the parameter /J

for sample /jit_IT.hil

the compilator create a file hil with all words you insert on your app


then on your app :
HB_I18NSetLanguage( fcGetLang() )
....
MENUITEM i18n("Modifica la lingua")
MENU
MENUITEM i18n( "Seleziona la lingua" ) ;
ACTION oApp():Idiomas()
MENUITEM i18n( "Modificare l'archivio della lingua" );
ACTION TLanguage():New() :Activar()
ENDMENU



then you have Idiomas() and Tlanguage()

Idiomas() is a function where you can select the file of the lang

Image



Tlanguage() is a class where you can create another file from yout hil or change the words into the language you want :

Image
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Adding a Multilanguage-solution to Your App.

Postby Eoeo » Sat Sep 22, 2012 7:29 am

for the sources i sad on prev topic i sent all to Antonio Linares Last year, it has never been taken as important and is not uncork never published in packages of fw. But i use current this for create Multilanguage application easy!!!!
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Adding a Multilanguage-solution to Your App.

Postby ukoenig » Sat Sep 22, 2012 8:32 am

Silvio,

Thank You for the Response.
It sounds good.
In my special Situation, I want to make it possible,
( not only a Translation ) also that the User can change the complete Text byhimself.
Buttons,Resources...
I finished with Testing and it works fine.
Using just only 38 Words, it is OK.

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: Adding a Multilanguage-solution to Your App.

Postby Eoeo » Sat Sep 22, 2012 9:00 am

the problem is when you must translate many and many words
I''m afraid a file ini with many and many words then it can result eating of resources

my solution is easy and the final user can modify the language file creating himself
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Adding a Multilanguage-solution to Your App.

Postby FiveWiDi » Sat Sep 22, 2012 9:19 am

Hello,

I use a solution like i18n() function, but with ini files, it work perfect for SAY, Buttons, Title, menu, anywhere.

Exemple ini file:

[ESP]
DESCRIP=Español
||~AMPA32, G~|estió de |~F~|acturacions de l'|~AMPA (~|domiciliacions, famílies, pares, alumnes, rebuts)|=|AMPA32, Gestión de Facturaciones de la AMPA (domiciliaciones, families, padres, alumnos, recibos)|
| |~F~|itxers &|~M~|estres|=| Ficheros &Maestros|
|&|~F~|amílies |~AMPA|=|&Familias AMPA|
|&|~P~|ares/|~M~|ares|=|&Padres/Madres|
|&|~A~|lumnes|=|&Alumnos|

Exemple in SAY:

@ 25,15 SAY GetTrad( "Alumnes:" ) OF oAlumne01 COLORS J02CLRTEXTO,J02CLRFONDO FONT ;
J02FONTSAY PIXEL SIZE 120,16

Regards,
Un Saludo
Carlos G.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 18 guests