Merge branch 'juliancoffee/articled-bodies' into 'master'

Improve translator documentation and wording

See merge request veloren/veloren!4303
This commit is contained in:
Illia Denysenko 2024-02-04 16:34:36 +00:00
commit c645031c3f
6 changed files with 103 additions and 50 deletions

View File

@ -1,11 +1,14 @@
body-generic = creature
body-biped_large-ogre = ogre
body-biped_large-cyclops = cyclops
body-biped_large-wendigo = wendigo
body-biped_large-werewolf = werewolf
body-biped_large-cave_troll = cave troll
body-biped_large-mountain_troll = mountain troll
body-biped_large-swamp_troll = swamp troll
body-biped_large-blue_oni = blue oni
body-biped_large-red_oni = red oni
body-biped_large-tursus = tursus
## Monster descriptions, used ONLY in npc-speech-tell_monster
body-npc-speech-generic = some creature
body-npc-speech-biped_large-ogre-male = an ogre
body-npc-speech-biped_large-ogre-female = an ogre
body-npc-speech-biped_large-cyclops = a cyclops
body-npc-speech-biped_large-wendigo = a wendigo
body-npc-speech-biped_large-werewolf = a werewolf
body-npc-speech-biped_large-cave_troll = a cave troll
body-npc-speech-biped_large-mountain_troll = a mountain troll
body-npc-speech-biped_large-swamp_troll = a swamp troll
body-npc-speech-biped_large-blue_oni = a blue oni
body-npc-speech-biped_large-red_oni = a red oni
body-npc-speech-biped_large-tursus = a tursus

View File

@ -1,3 +1,5 @@
## Generic NPC messages
npc-speech-villager =
.a0 = I love cheese.
npc-speech-villager_open =
@ -249,14 +251,54 @@ npc-speech-merchant_sell_directed =
.a0 = You there! Are you in need of a new thingamabob?
.a1 = Are you hungry? I'm sure I've got some cheese you can buy.
.a2 = You look like you could do with some new armour!
## NPC site hints
## Available variables:
## - $dir references npc-speech-dir-* variables below
## - $dist references npc-speech-dist-* variables below
## - $site represents hard-coded site in the world
npc-speech-tell_site =
.a0 = Have you visited { $site }? It's just { $dir } of here!
.a0 = There's { $site } { $dir } of here. Have you visited it?
.a1 = You should visit { $site } some time.
.a2 = If you travel { $dist } to the { $dir }, you can get to { $site }.
.a3 = To the { $dir } you'll find { $site }, it's { $dist }.
.a2 = If you travel { $dist } { $dir }, you can get to { $site }.
.a3 = { $dir } you'll find { $site }, it's { $dist }.
## NPC monster hints
## Available variables:
## - $dir references npc-speech-dir-* variables below
## - $dist references npc-speech-dist-* variables below
## - $body references body-npc-speech-* variables in `body` component
npc-speech-tell_monster =
.a0 = They say there's a { $body } to the { $dir }, { $dist }...
.a1 = You think you're tough? To the { $dir } there's a { $body }.
.a0 = They say there's { $body } { $dir }, { $dist } ...
.a1 = You think you're tough? There's { $body } { $dir }.
## Direction hints, used ONLY in npc-speech-tell* above
npc-speech-dir_north = to the north
npc-speech-dir_north_east = to the north-east
npc-speech-dir_east = to the east
npc-speech-dir_south_east = to the south-east
npc-speech-dir_south = to the south
npc-speech-dir_south_west = to the south-west
npc-speech-dir_west = to the west
npc-speech-dir_north_west = to the north-west
## Distance hints, used ONLY in npc-speech-tell* above
npc-speech-dist_very_far = very far away
npc-speech-dist_far = far away
npc-speech-dist_ahead = some way away
npc-speech-dist_near = nearby
npc-speech-dist_near_to = very close
## NPC proposals
npc-speech-arena = Let's sit over there!
## NPC reactions
npc-speech-witness_murder =
.a0 = Murderer!
.a1 = How could you do this?
@ -273,18 +315,3 @@ npc-speech-welcome-aboard =
.a0 = Welcome aboard!
.a1 = Can I see your ticket... just kidding it's free!
.a2 = Have a nice ride!
npc-speech-dir_north = north
npc-speech-dir_north_east = north-east
npc-speech-dir_east = east
npc-speech-dir_south_east = south-east
npc-speech-dir_south = south
npc-speech-dir_south_west = south-west
npc-speech-dir_west = west
npc-speech-dir_north_west = north-west
npc-speech-dist_very_far = very far away
npc-speech-dist_far = far away
npc-speech-dist_ahead = some way away
npc-speech-dist_near = nearby
npc-speech-dist_near_to = very close
npc-speech-arena = Let's sit over there!

View File

@ -1346,11 +1346,19 @@ impl Body {
Vec3::new(0.0, self.dimensions().y * 0.6, self.dimensions().z * 0.7)
}
pub fn localize(&self) -> Content {
match self {
Self::BipedLarge(biped_large) => biped_large.localize(),
_ => Content::localized("body-generic"),
/// Should be only used with npc-tell_monster.
///
/// If you want to use for displaying names in HUD, add new strings.
/// If you want to use for anything else, add new strings.
pub fn localize_npc(&self) -> Content {
fn try_localize(body: &Body) -> Option<Content> {
match body {
Body::BipedLarge(biped_large) => biped_large.localize_npc(),
_ => None,
}
}
try_localize(self).unwrap_or_else(|| Content::localized("body-npc-speech-generic"))
}
}

View File

@ -25,20 +25,29 @@ impl Body {
Self { species, body_type }
}
pub fn localize(&self) -> Content {
Content::localized(match &self.species {
Species::Ogre => "body-biped_large-ogre",
Species::Cyclops => "body-biped_large-cyclops",
Species::Wendigo => "body-biped_large-wendigo",
Species::Werewolf => "body-biped_large-werewolf",
Species::Cavetroll => "body-biped_large-cave_troll",
Species::Mountaintroll => "body-biped_large-mountain_troll",
Species::Swamptroll => "body-biped_large-swamp_troll",
Species::Blueoni => "body-biped_large-blue_oni",
Species::Redoni => "body-biped_large-red_oni",
Species::Tursus => "body-biped_large-tursus",
_ => "body-generic",
})
/// Should be only used with npc-tell_monster.
///
/// If you want to use for displaying names in HUD, add new strings.
/// If you want to use for anything else, add new strings.
pub fn localize_npc(&self) -> Option<Content> {
let key = match &self.species {
Species::Ogre => match self.body_type {
BodyType::Male => "body-npc-speech-biped_large-ogre-male",
BodyType::Female => "body-npc-speech-biped_large-ogre-female",
},
Species::Cyclops => "body-npc-speech-biped_large-cyclops",
Species::Wendigo => "body-npc-speech-biped_large-wendigo",
Species::Werewolf => "body-npc-speech-biped_large-werewolf",
Species::Cavetroll => "body-npc-speech-biped_large-cave_troll",
Species::Mountaintroll => "body-npc-speech-biped_large-mountain_troll",
Species::Swamptroll => "body-npc-speech-biped_large-swamp_troll",
Species::Blueoni => "body-npc-speech-biped_large-blue_oni",
Species::Redoni => "body-npc-speech-biped_large-red_oni",
Species::Tursus => "body-npc-speech-biped_large-tursus",
_ => return None,
};
Some(Content::localized(key))
}
}

View File

@ -54,6 +54,9 @@ impl Direction {
}
}
/// Should be only used with care with npc-tell_monster and npc-tell_site
///
/// If you add new usages for it, please consult i18n team.
pub fn localize_npc(&self) -> Content {
Content::localized(match self {
Direction::North => "npc-speech-dir_north",
@ -103,6 +106,9 @@ impl Distance {
}
}
/// Should be only used with care with npc-tell_monster and npc-tell_site
///
/// If you add new usages for it, please consult i18n team.
pub fn localize_npc(&self) -> Content {
Content::localized(match self {
Self::VeryFar => "npc-speech-dist_very_far",

View File

@ -610,7 +610,7 @@ fn talk_to<S: State>(tgt: Actor, _subject: Option<Subject>) -> impl Action<S> +
.min_by_key(|other| other.wpos.xy().distance(ctx.npc.wpos.xy()) as i32)
{
Content::localized_with_args("npc-speech-tell_monster", [
("body", monster.body.localize()),
("body", monster.body.localize_npc()),
("dir", Direction::from_dir(monster.wpos.xy() - ctx.npc.wpos.xy()).localize_npc()),
("dist", Distance::from_length(monster.wpos.xy().distance(ctx.npc.wpos.xy()) as i32).localize_npc()),
])