Skip to content

Commit f63882e

Browse files
committed
Merge branch 'main' into translate-from-mdbook
2 parents 98dbcae + 021f1bf commit f63882e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

i18n-helpers/src/bin/mdbook-i18n.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ struct I18nConfiguration {
2929
translate_all_languages: bool,
3030
/// Whether to move the translations to the html directory, defaults to false.
3131
///
32-
/// By default, translations's HTML output will live in `book/i18n/<language>/html`. If this is set to true, they will be moved to `book/html/<language>`.
32+
/// By default, translations' output will live in `book/i18n/<language>/<renderer>`.
33+
/// For all renderers in this list, we will move individual translations to `book/<renderer>/<language>`.
3334
#[serde(default)]
34-
move_translations_to_html_directory: bool,
35+
move_translations_directories: Vec<String>,
3536
}
3637

3738
fn main() {
@@ -68,12 +69,6 @@ fn main() {
6869
let output_directory = ctx.destination;
6970
let default_language = &i18n_config.default_language;
7071

71-
// Create html directory if it doesn't exist.
72-
if i18n_config.move_translations_to_html_directory {
73-
std::fs::create_dir_all(output_directory.parent().unwrap().join("html"))
74-
.unwrap_or_else(|_| panic!("Failed to create html directory in output directory"));
75-
}
76-
7772
for language in i18n_config.languages.keys() {
7873
// Skip current language and default language.
7974
if Some(language) == ctx.config.book.language.as_ref() {
@@ -93,13 +88,15 @@ fn main() {
9388
mdbook
9489
.build()
9590
.unwrap_or_else(|_| panic!("Failed to build translation for language: {}", language));
96-
if i18n_config.move_translations_to_html_directory {
91+
for renderer in &i18n_config.move_translations_directories {
92+
std::fs::create_dir_all(output_directory.parent().unwrap().join(renderer))
93+
.unwrap_or_else(|_| panic!("Failed to create html directory in output directory"));
9794
std::fs::rename(
98-
output_directory.join(language).join("html"),
95+
output_directory.join(language).join(renderer),
9996
output_directory
10097
.parent()
10198
.unwrap()
102-
.join("html")
99+
.join(renderer)
103100
.join(language),
104101
)
105102
.unwrap_or_else(|_| {

0 commit comments

Comments
 (0)