mirror of
https://github.com/lise-henry/crowbook
synced 2024-05-09 11:46:11 +02:00
Split lang/ into separate subdirectories
This commit is contained in:
parent
3ffb506b3c
commit
bdd37776e3
4
build.rs
4
build.rs
|
@ -11,10 +11,10 @@ fn main() {
|
|||
// Extract and localize src/lib
|
||||
let mut extractor = Extractor::new();
|
||||
extractor.add_messages_from_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/src/lib")).unwrap();
|
||||
extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/crowbook.pot")).unwrap();
|
||||
extractor.write_pot_file(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/crowbook.pot")).unwrap();
|
||||
|
||||
let mut localizer = Localizer::new(&extractor);
|
||||
localizer.add_lang("fr", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/fr.po"))).unwrap();
|
||||
localizer.add_lang("fr", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/lang/lib/fr.po"))).unwrap();
|
||||
let dest_path = Path::new(&env::var("OUT_DIR").unwrap())
|
||||
.join("localize_macros.rs");
|
||||
localizer.write_macro_file(dest_path).unwrap();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
Language directory
|
||||
======================
|
||||
|
||||
This directory, and its subdirectories, contains the files that allow
|
||||
Crowbook to be translated in other languages:
|
||||
|
||||
* the [document](document/) directory contains YAML files that are
|
||||
used to translate the (few) strings that Crowbook inserts in the
|
||||
generated documents according to the `lang` option, such as the
|
||||
translations for "Chapter", or "Table of Contents". To add a new
|
||||
translation, just translate
|
||||
the [document/en.yaml](document/en.yaml) into a new language. This
|
||||
is probably the easier translation job to do, and also the most
|
||||
important, since these strings are embedded in the generated
|
||||
documents.
|
||||
* the [lib](lib/) and [bin](bin/) directories respectively contains PO
|
||||
files that are used to translate the strings used in Crowbook's
|
||||
library and binary. These files contain a lot more strings, and are
|
||||
only used when Crowbook is run (that is, if you don't have a
|
||||
translation for your language here, you may have to use Crowbook in
|
||||
english, but as long as there is a translation in
|
||||
the [document](document/) directory it will at least display the
|
||||
correct translation in the documents it generates).
|
||||
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use yaml_rust::{YamlLoader, Yaml};
|
||||
use yaml_rust::yaml::Hash;
|
||||
|
||||
static EN: &'static str = include_str!("../../lang/en.yaml");
|
||||
static ES: &'static str = include_str!("../../lang/es.yaml");
|
||||
static FR: &'static str = include_str!("../../lang/fr.yaml");
|
||||
static EN: &'static str = include_str!("../../lang/document/en.yaml");
|
||||
static ES: &'static str = include_str!("../../lang/document/es.yaml");
|
||||
static FR: &'static str = include_str!("../../lang/document/fr.yaml");
|
||||
|
||||
/// Get the hashmap for a given language
|
||||
pub fn get_hash(lang: &str) -> Hash {
|
||||
|
|
Loading…
Reference in New Issue