Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How to handle localization strings in AMOS?  (Read 605 times)

Cucurbitacée

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
  • Generic Amiga User
How to handle localization strings in AMOS?
« on: April 19, 2017, 05:02:58 PM »

Hello people,

I hope you'll be nice with the newbie that I am. I tried AMOS 20+ years ago, and unfortunately it failed to connect with my stupid young mind and my experiences never went further than moving an object on screen with the joystick.

Anyway, I'm playing with Lua/LÖVE for some years now and I feel comfortable enough to code whatever comes to my mind.

I make small games that almost all have a 16 bit feeling to them. That's why I now really want to make a true Amiga OCS/ECS game, something I failed to do at the time.

I've been reading AMOS the Creator and AMOS Pro documentation and after some weeks most of my experiment are going well, and I could find all the answer by myself... Until now.

One my main priority is to have my project localizable (occupational hazard, I suppose), and I'm not sure how to do it.

My first conclusion was I need to avoid loading unnecessary languages in RAM, and from the documentation the INCLUDE command looked like it would do the trick. My code would look like this:

Code: [Select]
LANG$="en"
LEVEL$="A
PATH$="PROJECT:Level"+LEVEL$"+"/script_"+LANG$"+".AMOS"
Include PATH$

But it doesn't work, it reports a syntax error. It seems I can't use a variable with INCLUDE, the following code works:

Code: [Select]
LANG$="en"
LEVEL$="A"
If LANG$="en"
    If LEVEL$="A"
        Include "Project:Level_A/script_en.AMOS"
    Else
        Include "Project:Level_B/script_en.AMOS"
    End If
Else
    If LEVEL$="A"
        Include "Project:Level_A/script_fr.AMOS"
    Else
        Include "Project:Level_B/script_fr.AMOS"
    End If
End If
But I can't imagine this is viable solution. So my guess Is That I'm missing something and went on the wrong road. What would be the correct method to store and load localized strings?

Thanks. :)
Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 305
  • Online Online
  • Posts: 3,266
  • Don't forget... Ameboid's need love too!
    • Amiga Online
Re: How to handle localization strings in AMOS?
« Reply #1 on: April 20, 2017, 06:15:35 AM »

Are  you sure PATH isn't a reserved name?

Tried using LevelPath$ or something?
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Hungry Horace's Artwork Available
Buy my work

http://twitter.com/horaceandspider

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 3
  • Offline Offline
  • Posts: 821
  • Compile-time wierdo
Re: How to handle localization strings in AMOS?
« Reply #2 on: April 20, 2017, 12:22:06 PM »

I personally wouldn't mess with Include for this type of feature.  I'd make a data bank format for your strings and use the PEEK$ function for each string you want to print.  The only other thing is that since the strings will be at different offsets within the bank, the string data will need to be prefixed by a list of offsets.  If you'd like, I can give a simple example.
Logged

Hungry Horace

  • Amorphous Blue-Blob Man
  • Site Admin
  • A4000T
  • ******
  • Karma: 305
  • Online Online
  • Posts: 3,266
  • Don't forget... Ameboid's need love too!
    • Amiga Online
Re: How to handle localization strings in AMOS?
« Reply #3 on: April 20, 2017, 01:11:02 PM »

I just tried using PATH$ myself, and i noticed it did tokenise (changing to "Path$")

So i'm pretty sure it's just an unfortunate choice of variable name.
Logged
Quote from: KillerGorilla
because winuae is made of code and your amiga is made of stuff

Hungry Horace's Artwork Available
Buy my work

http://twitter.com/horaceandspider

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 3
  • Offline Offline
  • Posts: 821
  • Compile-time wierdo
Re: How to handle localization strings in AMOS?
« Reply #4 on: April 20, 2017, 01:19:45 PM »

I'm pretty sure it won't work with a compiled Amos source because there would need to be a separate executable for every language.  I stand by my data bank suggestion.
Logged

Cucurbitacée

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
  • Generic Amiga User
Re: How to handle localization strings in AMOS?
« Reply #5 on: April 20, 2017, 04:01:25 PM »

Hi guys,

Thanks for the replies. I candidly try to reproduce the way I code nowadays, and obviously it's not meant to work. I'm reading further the documentation about memory banks, and as it's not my usual way to think (basically unlimited RAM and processing power for what I do) I need to really figure out how this works before going further.

I'll most probably come back later for some newbie questions. :P
Logged

Mia

  • A600
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 101
  • Generic Amiga User
Re: How to handle localization strings in AMOS?
« Reply #6 on: April 21, 2017, 05:17:46 PM »

and as it's not my usual way to think (basically unlimited RAM and processing power for what I do)

cool, and AMOS will be able keep up with you...

The "Include" command doesn't work for the compiler, so I'm thinking reading and parsing text files into an array would work.
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Posts: 423
  • WINUAE Amiga User
Re: How to handle localization strings in AMOS?
« Reply #7 on: April 22, 2017, 12:43:29 AM »

Why not use data banks?  If you can live with the restrictions on strings in a Resource bank (255 characters per string and 256 strings max) use those.  If not, just store the strings as length (1 word) + text.  Be careful of word alignment, you may need a zero pad byte for some strings.  The code to extract a specific string is then the AMOS Basic equivalent of the assembler in the Ed_GetMessage() function in +Edit.s (Deek length, jump text until target position is reached - then pull out the string with Peek$() ).

The advantage with a Resource bank is that you can simply use Resource$(number) to get at the text after the appropriate bank is loaded.  Unfortunately, AMOS has no Case statement, so you're stuck with On ... Goto or On ... Proc to pick the data bank you need.  Tailor your selection criteria into an integer series using a lookup table.
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

Cucurbitacée

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
  • Generic Amiga User
Re: How to handle localization strings in AMOS?
« Reply #8 on: May 01, 2017, 07:48:10 PM »

OK, I've been reading the documentation on and off this past week. I'm slowly getting the concept of memory banks, but it still feels very alien to me. I need more time to process all of this.

On the subject, is it possible to have several resource bank in memory at the same time?
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 3
  • Offline Offline
  • Posts: 821
  • Compile-time wierdo
Re: How to handle localization strings in AMOS?
« Reply #9 on: May 03, 2017, 09:41:30 AM »

I think you can have only one active resource bank at a time but you can have more than one in memory.  See the Bank Swap command to switch between banks.
Logged

Dan

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 3
  • Amos Fan
    • Emu.Zone
Re: How to handle localization strings in AMOS?
« Reply #10 on: May 07, 2017, 04:30:06 PM »


Hi,

Lately, just for fun, iv tried to test how a program could use multiple languages.


So i had a sourcecode from winbasic basic (pc) converted to the BlitzBasic PC.
The game was simple guess the number.


First, i decided to use an array, so i copied each text to the data statements, replacing it from the code with an increasing array number.
Then i wrote the translation to English and to  fictional Language, as you can see here:


(Pc BlitzBasic sourcecode)


Code: [Select]

Graphics 640,480,32,2


 
;Setup number of text and number of languages available
Read aa,bb
For x=1 To bb
   Read L$
   Print x+" = "+L$
Next




Dim Language$(aa)


CH=Input("Choose 1-"+(x-1)+" >")
If ch<=0 Or ch>bb Then ch=1
y=0
x=0


;Reads the language data
Repeat
   x=x+1
   y=y+1: If y>bb Then y=1
   
   Read l$
   If l$="*end*" Then Goto O1
   If y=ch Then c=c+1 : Language(c)=l$ ; Print c+" = "+l$
   
Forever




.O1
Cls
Text 18*14,12*14, String("*",17)
Text 18*14,13*14, Language(1)
Text 18*14,14*14, String("*",17)
Text 30*14,18*14, Language(2)


While Not GetKey()
   Delay 5
Wend


Cls
Locate 0,0
SeedRnd MilliSecs()
Print
zahl=Input(Language(3)) ; ZAHL
If zahl=<2 Then zahl=Int(Rand(1,100))+2
.o2
Cls
Print
Print Language(4)+ ZAHL+Language(5)
Print
ZUFALL = Int(Rand(1,ZAHL))
If ZUFALL = 0 Then Goto o2
For VERSUCHE = 1 To 10
;  Print
   RATEN=Input(VERSUCHE+Language(6) )
   Print
   If RATEN = ZUFALL Then
      Print Language(7)+VERSUCHE+Language(
      Goto O10
   End If
   If RATEN < ZUFALL Then Print Language(9)
   If RATEN > ZUFALL Then Print Language(10)
   Print
Next
Print "GAME OVER"
Print Language(11)+ZUFALL
Goto O10
A$=Input()
Cls
End


.O10
Print ""
Print Language(12)
a$=Input(Language(13))
If a$="E" Or a$="e" Then
   End
End If
Goto O1


; number of words (needed to dim the Language() array,  number of languages (starting from 1)
Data 14,3


; Names of the Languages, uses the number of languages from above
Data "German","English","Hulkster"


;Text in all languages: Depends on the number of languages
Data "*ZAHLENGENERATOR*","*NUMBERGENERATOR*","*  HULK SMASH   *"
Data "<Bitte eine Taste drücken>","<Press any key to Continue>","Yo SMASH KEY"
Data "Wie groß soll die Zufallszahl sein :","Enter a number to play with , between 1 and :","Punny little HUMAN enter a number :"
Data "Ich denke mir eine Zahl zwischen 1 und ","Im choosing a number between 1 and ","HULK CHOOSE TO : "
Data " aus.","."," NUMBER"
Data ". Versuch> "," try > "," SMASH NUMBER: >"
Data "Sie haben die gesuchte Zahl mit ","You have guessed the number in ","YOU DID "
Data " Versuchen erraten!"," rounds"," SMASHES"
Data "Die eingegebene zahl ist kleiner als meine !","That number is lower than mine","YOU ARE WEAKER !!"
Data "Die eingegebene zahl ist größer als meine !","That number is higher than mine","YOU ARE STRONGER ? IMPOSSIBILE!"
Data "Die gesuchte Zahl war ","I was looking for: ","HULK HAS CHOOSEN: "
Data "Return = nochmal","Return = Play again","SMASH RETURN TO PLAY AGAIN"
Data "E + Return beendet dieses Spiel.> ","E + Return to Quit.> ","SMASH E TO END "
Data "*end*","*end*"



The language definition could be loaded from a text file into the array.


I hope it can help you further.
Logged

SamuraiCrow

  • compile-time wierdo
  • Forum Mod
  • A1200
  • *****
  • Karma: 3
  • Offline Offline
  • Posts: 821
  • Compile-time wierdo
Re: How to handle localization strings in AMOS?
« Reply #11 on: May 08, 2017, 04:25:10 PM »

@Dan

Scanning the file for linefeeds would slow down the load process.  Storing the offsets at the beginning of an .ABK (Amos BanK) file would load faster with only a little 4 byte per string cost in terms of overhead compared to a text file.  Plus, version information could be stored in a header before the offsets to insure the correct number of strings.
Logged
Pages: [1]   Go Up