Improve French and Chinese localization for figures (#2542)

This commit is contained in:
MALO 2023-11-10 17:17:39 +01:00 committed by GitHub
parent 010084e2d6
commit 13f1a4386f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 36 deletions

View File

@ -1,6 +1,5 @@
use std::borrow::Cow;
use std::str::FromStr;
use typst::util::option_eq;
use super::{Count, Counter, CounterKey, CounterUpdate, Numbering, NumberingPattern};
use crate::layout::{BlockElem, PlaceElem, VElem};
@ -499,20 +498,12 @@ pub struct FigureCaption {
impl FigureCaption {
/// Gets the default separator in the given language and (optionally)
/// region.
fn local_separator(lang: Lang, region: Option<Region>) -> &'static str {
fn local_separator(lang: Lang, _: Option<Region>) -> &'static str {
match lang {
Lang::CHINESE => "",
Lang::FRENCH if option_eq(region, "CH") => "\u{202f}: ",
Lang::FRENCH => "\u{a0}: ",
Lang::CHINESE => "\u{2003}",
Lang::FRENCH => ".\u{a0} ",
Lang::RUSSIAN => ". ",
Lang::DANISH
| Lang::DUTCH
| Lang::ENGLISH
| Lang::GERMAN
| Lang::ITALIAN
| Lang::SPANISH
| Lang::SWEDISH
| _ => ": ",
Lang::ENGLISH | _ => ": ",
}
}

View File

@ -234,7 +234,7 @@ impl LocalName for ImageElem {
Lang::DUTCH => "Figuur",
Lang::FILIPINO => "Pigura",
Lang::FINNISH => "Kuva",
Lang::FRENCH => "Figure",
Lang::FRENCH => "Fig.",
Lang::GERMAN => "Abbildung",
Lang::HUNGARIAN => "Ábra",
Lang::ITALIAN => "Figura",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -0,0 +1,17 @@
// Test localization-related figure features.
---
// Test French
#set text(lang: "fr")
#figure(
circle(),
caption: [Un cercle.],
)
---
// Test Chinese
#set text(lang: "zh")
#figure(
rect(),
caption: [一个矩形],
)

View File

@ -109,25 +109,3 @@ We can clearly see that @fig-cylinder and
table(columns: 2)[a][b],
caption: [The table with custom separator.],
)
---
// Test localized default separator
#set text(lang: "fr", region: "CH")
#figure(
circle(),
caption: [Un cercle.],
)
#set text(lang: "es")
#figure(
polygon.regular(size: 1cm, vertices: 3),
caption: [Un triángulo.],
)
#set text(lang: "fr", region: "CA")
#figure(
square(),
caption: [Un carré.],
)