veloren_client_i18n/
raw.rs

1use crate::{
2    Fonts, LanguageMetadata,
3    assets::{StringLoader, loader},
4};
5use serde::{Deserialize, Serialize};
6
7/// Localization metadata from manifest file
8/// See `Language` for more info on each attributes
9#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
10pub(crate) struct Manifest {
11    /// Whether to convert the input text encoded in UTF-8
12    /// into a ASCII version by using the `deunicode` crate.
13    pub(crate) convert_utf8_to_ascii: bool,
14    pub(crate) fonts: Fonts,
15    pub(crate) metadata: LanguageMetadata,
16}
17
18impl crate::assets::Asset for Manifest {
19    type Loader = crate::assets::RonLoader;
20
21    const EXTENSION: &'static str = "ron";
22}
23
24// Newtype wrapper representing fluent resource.
25//
26// NOTE:
27// We store String, that later converted to FluentResource.
28// We can't do it at load time, because we might want to do utf8 to ascii
29// conversion and we know it only after we've loaded language manifest.
30//
31// Alternative solution is to make it hold Rc/Arc around FluentResource,
32// implement methods that give us mutable control around resource entries,
33// but doing it to eliminate Clone that happens N per programm life seems as
34// overengineering.
35//
36// N is time of fluent files, so about 20 for English and the same for target
37// localisation.
38#[derive(Clone)]
39pub(crate) struct Resource {
40    pub(crate) src: String,
41}
42
43impl From<String> for Resource {
44    fn from(src: String) -> Self { Self { src } }
45}
46
47impl crate::assets::Asset for Resource {
48    type Loader = loader::LoadFrom<String, StringLoader>;
49
50    const EXTENSION: &'static str = "ftl";
51}