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 126 times)

Cucurbitacée

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
  • 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
  • Offline Offline
  • Posts: 3,259
  • 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: 800
  • 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
  • Offline Offline
  • Posts: 3,259
  • 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: 800
  • 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: 2
  • 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: 0
  • Offline Offline
  • Posts: 83
  • 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: 420
  • 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."
Pages: [1]   Go Up