mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Clean i18n lifetimes
This commit is contained in:
parent
27e67e79ec
commit
3d1b2735a2
@ -80,14 +80,12 @@ struct Language {
|
||||
|
||||
impl Language {
|
||||
/// Get a localized text from the given key
|
||||
pub fn get<'a>(&'a self, key: &str) -> Option<&str> {
|
||||
self.string_map.get(key).map(String::as_str)
|
||||
}
|
||||
pub fn get(&self, key: &str) -> Option<&str> { self.string_map.get(key).map(String::as_str) }
|
||||
|
||||
/// Get a variation of localized text from the given key
|
||||
///
|
||||
/// `index` should be a random number from `0` to `u16::max()`
|
||||
pub fn get_variation<'a>(&'a self, key: &str, index: u16) -> Option<&str> {
|
||||
pub fn get_variation(&self, key: &str, index: u16) -> Option<&str> {
|
||||
self.vector_map.get(key).and_then(|v| {
|
||||
if v.is_empty() {
|
||||
None
|
||||
@ -182,7 +180,7 @@ impl LocalizationGuard {
|
||||
///
|
||||
/// First lookup is done in the active language, second in
|
||||
/// the fallback (if present).
|
||||
pub fn get_or<'a>(&'a self, key: &str, fallback_key: &str) -> Option<&'a str> {
|
||||
pub fn get_or(&self, key: &str, fallback_key: &str) -> Option<&str> {
|
||||
self.get_opt(key).or_else(|| self.get_opt(fallback_key))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user