Open sfiera opened 8 years ago
Launching in a different language on Mac:
./Antares.app/Contents/MacOS/Antares -AppleLanguages '(ja,fr,de)'
On Linux, something like this would be appropriate:
LC_ALL= LC_MESSAGES= LANGUAGE=ja_JP:fr_FR:de_DE ./antares
I’ve been thinking about how to do this, and I think that there’s a good method that inherits some ideas from HiDPI resources (@2x
) and object templates.
Given an object resource like dev/stealth/item.pn, and a locale like es_AR
, search for dev/stealth/item~es.pn
and dev/stealth/item~es_AR.pn
. Load the base resource and either/both localized resources, and merge the languages on top of the base resource. So, dev/stealth/item~es.pn
would be something like this:
long_name: "Campo de ocultación"
short_name: "OCULTACN"
This works well for objects, but less well for other types of resources, in particular where array resources are used. There isn’t currently any merging process for arrays; they are replaced wholesale. For example, in an interface, a localizer might want to change only the text
and label
fields, but there isn’t a way to do that. With levels, it’s even more difficult, such as a win
action in an action list in an owner
condition in a condition list.
The best thing to do might be to allow a map in all these contexts as an alternative to arrays (Procyon dicts are order-preserving). For compatibility, an array would still be allowed, but where localization is needed, [x, y, z]
would be changed to {0: x, 1: y, 2: z}
(the values of the strings are not actually important; only the order really matters). This seems pretty reasonable for conditions, briefings, players, and initials. It seems a little overkill for actions, but I don’t really see a better option there.
So, for example, a fully-updated ch08.pn
would look like this:
type: "solo"
chapter: 11
title:
> \i Chapter 8
| \iAstrotrash Plus!
players:
0:
type: "human"
race: "ish"
name: "The Human/Ishiman Cooperative"
earning_power: 1.0
1:
type: "cpu"
race: "can"
name: "The Cantharan Order"
earning_power: 1.0
status:
0:
text: "Collect 10"
1:
text: "asteroid samples"
underline: true
2:
prefix: "Collected: "
counter: {player: 0, which: 1}
suffix: "/10"
song: "targetron"
initials:
0:
base: "ish/hvc"
owner: 0
at: {x: -22956, y: -1391}
flagship: true
1:
base: "can/fighter"
owner: 1
at: {x: 0, y: -3565}
hide: true
2:
base: "ast/shoot/narrow/up"
at: {x: 0, y: 32768}
3:
base: "ast/shoot/narrow/down"
at: {x: 0, y: -32768}
4:
base: "ish/etc/astrominer"
owner: 0
at: {x: -24000, y: -2259}
hide: true
target: {initial: 0}
5:
base: "ish/etc/astrominer"
owner: 0
at: {x: -24000, y: -2259}
hide: true
target: {initial: 0}
6:
base: "ish/etc/astrominer"
owner: 0
at: {x: -23305, y: -2259}
hide: true
target: {initial: 0}
7:
base: "can/etc/spawner/obj"
owner: 1
at: {x: 32768, y: 0}
hide: true
conditions:
0:
when:
type: "time"
op: "ge"
duration: "-2s"
action:
* type: "reveal"
reflexive: true
initial: [1, 2, 3]
* type: "reveal"
reflexive: true
initial: [4, 5, 6]
1:
when:
type: "time"
op: "ge"
duration: "11s40t"
action:
* type: "reveal"
reflexive: true
initial: [7]
2:
when:
type: "time"
op: "ge"
duration: "-3m59.85s"
action:
* type: "stop"
reflexive: true
override:
subject: {initial: 0}
3:
persistent: true
when:
type: "score"
op: "ge"
counter: {player: 0, which: 1}
value: 10
action:
0:
type: "win"
player: 0
next: "ch09"
text:
> Mission completed. You collected enough asteroid samples for a thorough
> analysis.
briefings:
0:
title: "Palyos Belt"
content:
> We need to determine how prolific the bio-mechanical Boodan Virus has
> been. Therefore, we're dropping you in the Palyos Belt so you can
> collect some samples from the asteroids there.
1:
initial: 0
title: "Heavy Cruiser"
content:
> ^Pish/hvc^You'll be using this heavy cruiser. Several small Cantharan
> ships are in the area; they may be investigating the asteroids as well,
> or they may simply try to prevent us from doing so.
2:
initial: 4
title: "Astrominer"
content:
> ^Pish/etc/astrominer^Since we'll need at least ten samples, you'll have
> three astrominers at your command for this mission. While we'd prefer it
> if all three survived this mission, we will not abort even if all three
> are destroyed.
3:
title: "Asteroid"
content:
> ^Past/regular/big^Remember, to collect an asteroid sample, it must be
> first broken down to the smallest possible size. Also remember that we
> need at least ten samples before we'll pull you out.
>
> Finally, watch out for the parasitic zerbilite organisms, which are
> frequently found in mineral-rich asteroid belts. And make sure you or
> your astrominers don't collide with one of the green unstable asteroids.
> A collision with one of those giants is fatal.
starmap: {left: 270, top: 199, right: 302, bottom: 223}
start_time: "4m"
par:
time: "4m30s"
kills: 6
losses: 1
no_ships:
> You lost all of your ships. Without more data, we cannot determine the
> level of threat presented by the Boodan Mechanism.
And the localized resource, ch08~en.pn
:
title:
> \i Chapter 8
| \iAstrotrash Plus!
players:
0: {name: "The Human/Ishiman Cooperative"}
1: {name: "The Cantharan Order"}
status:
0: {text: "Collect 10"}
1: {text: "asteroid samples"}
2: {prefix: "Collected: "}
conditions:
3: {action: {0: {text: "Mission completed. You collected enough asteroid samples for a thorough analysis.\n"}}}
briefings:
0:
title: "Palyos Belt"
content:
> We need to determine how prolific the bio-mechanical Boodan Virus has
> been. Therefore, we're dropping you in the Palyos Belt so you can
> collect some samples from the asteroids there.
1:
title: "Heavy Cruiser"
content:
> ^Pish/hvc^You'll be using this heavy cruiser. Several small Cantharan
> ships are in the area; they may be investigating the asteroids as well,
> or they may simply try to prevent us from doing so.
2:
title: "Astrominer"
content:
> ^Pish/etc/astrominer^Since we'll need at least ten samples, you'll have
> three astrominers at your command for this mission. While we'd prefer it
> if all three survived this mission, we will not abort even if all three
> are destroyed.
3:
title: "Asteroid"
content:
> ^Past/regular/big^Remember, to collect an asteroid sample, it must be
> first broken down to the smallest possible size. Also remember that we
> need at least ten samples before we'll pull you out.
>
> Finally, watch out for the parasitic zerbilite organisms, which are
> frequently found in mineral-rich asteroid belts. And make sure you or
> your astrominers don't collide with one of the green unstable asteroids.
> A collision with one of those giants is fatal.
no_ships:
> You lost all of your ships. Without more data, we cannot determine the
> level of threat presented by the Boodan Mechanism.
Note to self: changing the data files as above will break some of the line numbers linked from the plugin documentation. https://github.com/search?q=repo%3Aarescentral%2Farescentral.org+%22antares-data%22&type=code
Further note to self: if it becomes standard to list initials and conditions by name, it ought to be possible to reference them by name too (briefing → initial; action → condition; etc.)
Right now data bundles don't have any support for including different languages. There should be a directory structure that supports finding different resources for different languages, and picks one according to the users's system language.
On Mac, this means using
[NSLocale preferredLanguages]
On Linux, this means using
$LANGUAGE
, with a number of things checked before or as a fallback.