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 pub(crate) fonts: Fonts,
12 pub(crate) metadata: LanguageMetadata,
13}
14
15impl crate::assets::Asset for Manifest {
16 type Loader = crate::assets::RonLoader;
17
18 const EXTENSION: &'static str = "ron";
19}
20
21// Newtype wrapper representing fluent resource.
22//
23// NOTE:
24// We store String, that later converted to FluentResource.
25// We can't do it at load time, because we might want to do utf8 to ascii
26// conversion and we know it only after we've loaded language manifest.
27//
28// Alternative solution is to make it hold Rc/Arc around FluentResource,
29// implement methods that give us mutable control around resource entries,
30// but doing it to eliminate Clone that happens N per programm life seems as
31// overengineering.
32//
33// N is time of fluent files, so about 20 for English and the same for target
34// localisation.
35#[derive(Clone)]
36pub(crate) struct Resource {
37 pub(crate) src: String,
38}
39
40impl From<String> for Resource {
41 fn from(src: String) -> Self { Self { src } }
42}
43
44impl crate::assets::Asset for Resource {
45 type Loader = loader::LoadFrom<String, StringLoader>;
46
47 const EXTENSION: &'static str = "ftl";
48}