mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improve ability i18n algorithm
This commit is contained in:
parent
c10f722e25
commit
445b748e1a
@ -361,9 +361,20 @@ pub fn ability_description<'a>(
|
||||
) -> (Cow<'a, str>, Cow<'a, str>) {
|
||||
// TODO: Use fluent attribute mechanic
|
||||
let (name, desc) = (
|
||||
format!("{}.name", ability_id),
|
||||
format!("{}.desc", ability_id),
|
||||
format!("{}.name", ability_id).replace('.', "-"),
|
||||
format!("{}.desc", ability_id).replace('.', "-"),
|
||||
);
|
||||
|
||||
(loc.get(&name), loc.get(&desc))
|
||||
// 1) Try localize ability
|
||||
// 2) If not, say that ability is unknown
|
||||
// 3) If unknown key is missed, just return id
|
||||
// TODO: better algorithm?
|
||||
(
|
||||
loc.try_msg(&name)
|
||||
.or_else(|| loc.try_msg("common-abilities-unknown-name"))
|
||||
.unwrap_or(Cow::Owned(name)),
|
||||
loc.try_msg(&desc)
|
||||
.or_else(|| loc.try_msg("common-abilities-unknown-desc"))
|
||||
.unwrap_or(Cow::Owned(desc)),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user