veloren/client/i18n/src/raw.rs

52 lines
1.6 KiB
Rust
Raw Normal View History

2022-08-18 21:09:39 +00:00
use crate::{
assets::{loader, StringLoader},
Fonts, LanguageMetadata,
};
use serde::{Deserialize, Serialize};
2021-07-23 11:32:00 +00:00
/// Localization metadata from manifest file
2021-07-23 11:32:00 +00:00
/// See `Language` for more info on each attributes
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub(crate) struct Manifest {
2022-08-18 21:09:39 +00:00
/// Whether to convert the input text encoded in UTF-8
/// into a ASCII version by using the `deunicode` crate.
2021-07-23 11:32:00 +00:00
pub(crate) convert_utf8_to_ascii: bool,
pub(crate) fonts: Fonts,
pub(crate) metadata: LanguageMetadata,
}
impl crate::assets::Asset for Manifest {
type Loader = crate::assets::RonLoader;
const EXTENSION: &'static str = "ron";
2021-07-23 11:32:00 +00:00
}
2022-08-18 21:09:39 +00:00
// Newtype wrapper representing fluent resource.
//
// NOTE:
// We store String, that later converted to FluentResource.
// We can't do it at load time, because we might want to do utf8 to ascii
2022-08-18 21:09:39 +00:00
// conversion and we know it only after we've loaded language manifest.
//
// Alternative solution is to make it hold Rc/Arc around FluentResource,
// implement methods that give us mutable control around resource entries,
// but doing it to eliminate Clone that happens N per programm life seems as
// overengineering.
//
// N is time of fluent files, so about 20 for English and the same for target
// localisation.
#[derive(Clone)]
pub(crate) struct Resource {
pub(crate) src: String,
2021-07-23 11:32:00 +00:00
}
2022-08-18 21:09:39 +00:00
impl From<String> for Resource {
fn from(src: String) -> Self { Self { src } }
2021-07-23 11:32:00 +00:00
}
impl crate::assets::Asset for Resource {
2022-08-18 21:09:39 +00:00
type Loader = loader::LoadFrom<String, StringLoader>;
2021-07-23 11:32:00 +00:00
const EXTENSION: &'static str = "ftl";
}