Catalogs in RapaGui
Catalogs in RapaGui
Sorry I can't figure how they should work. Any hint?
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Catalogs in RapaGui
Just check out the documentation:
http://www.hollywood-mal.com/docs/html/ ... tNote.html
http://www.hollywood-mal.com/docs/html/ ... tNote.html
Re: Catalogs in RapaGui
I'm also having trouble with this. My catalog strings work when used in the hws script but nos when used in the xml file. I get this message:airsoftsoftwair wrote:Just check out the documentation:
http://www.hollywood-mal.com/docs/html/ ... tNote.html
Error parsing XML: not well-formed (invalid token) (line 4)
File: convi.hws (current line: 124 - In function: CreateApp)
Is there any small example on how to call the catalog strings in the xml file?
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
Re: Catalogs in RapaGui
Possibly you have some special characters like german "ä" "ö" or french accents in your xml-file??
Try to avoid them.
Possibly changing from ISO to UTF might help, too.
Best regards
George
Try to avoid them.
Possibly changing from ISO to UTF might help, too.
Best regards
George
Re: Catalogs in RapaGui
No special characters. I tried only with english as default and english catalog too. The catalog table with the strings works when the string variables are called inside the HW script for each corresponding catalog, as shown by debugprinting the variables. But the same variables written in the xml file dont't work.evil wrote:Possibly you have some special characters like german "ä" "ö" or french accents in your xml-file??
For example, I have this:
Code: Select all
def_cat$={} ;default language table
def_cat$[0]="File"
def_cat$[1]="About..."
def_cat$[2]="About RapaGui..."
def_cat$[3]="Quit"
def_cat$[4]="Input filename"
OpenCatalog("convi.catalog")
convi_cat$={} ;catalog table
convi_cat$[0]=GetCatalogString(0, def_cat$[0])
convi_cat$[1]=GetCatalogString(1, def_cat$[1])
convi_cat$[2]=GetCatalogString(2, def_cat$[2])
convi_cat$[3]=GetCatalogString(3, def_cat$[3])
convi_cat$[4]=GetCatalogString(4, def_cat$[4])
I suppose the FileToString function converts all, including the catalog variables to string and hence the malformed call I get. There must be a way to localize the .xml file, right?
My workaround for now, to have english, spanish and catalan GUI, is:
Code: Select all
day$=GetWeekday()
If(day$="lunes" Or day$="martes" Or day$="miércoles" Or day$="jueves" Or day$="viernes" Or day$="sábado" Or day$="domingo")
moai.CreateApp(FileToString("data/convi_esp.xml"))
ElseIf(day$="dilluns" Or day$="dimarts" Or day$="dimecres" Or day$="dijous" Or day$="divendres" Or day$="dissabte" Or day$="diumenge")
moai.CreateApp(FileToString("data/convi_cat.xml"))
Else
moai.CreateApp(FileToString("data/convi.xml"))
EndIf
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Catalogs in RapaGui
You can't access catalogs from XML files because XML doesn't contain code. You need to find a way to workaround this, e.g. use something like this:
Then write a parser which replaces all %CATALOGID% strings with calls to GetCatalogString(). The number after %CATALOGID is the index and the string is the default string. Not sure if my idea is the nicest solution, though.
Code: Select all
<button>%CATALOGID:0,Hello%</button>
Re: Catalogs in RapaGui
@airsoftsoftwair
that is too complex for me now. But I found a solutions that is working nicely for the small GUIs I'm writing now and simpler than the one posted before for using an xml file for each language that have a catalog.
Maybe it is usefull for someone else.
that is too complex for me now. But I found a solutions that is working nicely for the small GUIs I'm writing now and simpler than the one posted before for using an xml file for each language that have a catalog.
Code: Select all
/**** Read GUI file ****/
;detect system's language, change
;encoding from MorphOS char set to UTF-8
;and switch to the corresponding xml GUI
language$=ConvertStr(GetEnv("language"), #ENCODING_AMIGA, #ENCODING_UTF8)
Switch language$
Case "español":
moai.CreateApp(FileToString("data/convi_esp.xml"))
Case "català":
moai.CreateApp(FileToString("data/convi_cat.xml"))
Default:
moai.CreateApp(FileToString("data/convi.xml"))
EndSwitch
/***********************/
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
- airsoftsoftwair
- Posts: 5446
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Catalogs in RapaGui
Of course, this contradicts the DRY programming paradigm ("don't repeat yourself") but for smaller projects it probably doesn't matter
Re: Catalogs in RapaGui
At the end I applied what is the proper way (at least I think) as follow:
1. Create a table with the translations...use the conventional catalog way as described in the manual.
2. assign an ID to your xml items like <text ID="Year" align="Right">Year:</text>
3. after creating the moai application set the ID with the translation as follow
moai.CreateApp(f$)
moai.Set("Year", "Text", Cat_string$[6]..":")
and you will have your application in your language. It is bit boring because you have to do that for all text items of your interface, but works.
Drop me an e-mail and I send you copy of my source for reference (sb5@libero.it).
1. Create a table with the translations...use the conventional catalog way as described in the manual.
2. assign an ID to your xml items like <text ID="Year" align="Right">Year:</text>
3. after creating the moai application set the ID with the translation as follow
moai.CreateApp(f$)
moai.Set("Year", "Text", Cat_string$[6]..":")
and you will have your application in your language. It is bit boring because you have to do that for all text items of your interface, but works.
Drop me an e-mail and I send you copy of my source for reference (sb5@libero.it).
Re: Catalogs in RapaGui
@ilbarbax
Thanks! I followed your instructions and got it working.
Thanks! I followed your instructions and got it working.
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE