mirror of
https://github.com/typst/typst
synced 2025-05-21 04:25:28 +08:00
Improve French and Chinese localization for figures (#2542)
This commit is contained in:
parent
010084e2d6
commit
13f1a4386f
@ -1,6 +1,5 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use typst::util::option_eq;
|
|
||||||
|
|
||||||
use super::{Count, Counter, CounterKey, CounterUpdate, Numbering, NumberingPattern};
|
use super::{Count, Counter, CounterKey, CounterUpdate, Numbering, NumberingPattern};
|
||||||
use crate::layout::{BlockElem, PlaceElem, VElem};
|
use crate::layout::{BlockElem, PlaceElem, VElem};
|
||||||
@ -499,20 +498,12 @@ pub struct FigureCaption {
|
|||||||
impl FigureCaption {
|
impl FigureCaption {
|
||||||
/// Gets the default separator in the given language and (optionally)
|
/// Gets the default separator in the given language and (optionally)
|
||||||
/// region.
|
/// region.
|
||||||
fn local_separator(lang: Lang, region: Option<Region>) -> &'static str {
|
fn local_separator(lang: Lang, _: Option<Region>) -> &'static str {
|
||||||
match lang {
|
match lang {
|
||||||
Lang::CHINESE => ":",
|
Lang::CHINESE => "\u{2003}",
|
||||||
Lang::FRENCH if option_eq(region, "CH") => "\u{202f}: ",
|
Lang::FRENCH => ".\u{a0}– ",
|
||||||
Lang::FRENCH => "\u{a0}: ",
|
|
||||||
Lang::RUSSIAN => ". ",
|
Lang::RUSSIAN => ". ",
|
||||||
Lang::DANISH
|
Lang::ENGLISH | _ => ": ",
|
||||||
| Lang::DUTCH
|
|
||||||
| Lang::ENGLISH
|
|
||||||
| Lang::GERMAN
|
|
||||||
| Lang::ITALIAN
|
|
||||||
| Lang::SPANISH
|
|
||||||
| Lang::SWEDISH
|
|
||||||
| _ => ": ",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ impl LocalName for ImageElem {
|
|||||||
Lang::DUTCH => "Figuur",
|
Lang::DUTCH => "Figuur",
|
||||||
Lang::FILIPINO => "Pigura",
|
Lang::FILIPINO => "Pigura",
|
||||||
Lang::FINNISH => "Kuva",
|
Lang::FINNISH => "Kuva",
|
||||||
Lang::FRENCH => "Figure",
|
Lang::FRENCH => "Fig.",
|
||||||
Lang::GERMAN => "Abbildung",
|
Lang::GERMAN => "Abbildung",
|
||||||
Lang::HUNGARIAN => "Ábra",
|
Lang::HUNGARIAN => "Ábra",
|
||||||
Lang::ITALIAN => "Figura",
|
Lang::ITALIAN => "Figura",
|
||||||
|
BIN
tests/ref/meta/figure-localization.png
Normal file
BIN
tests/ref/meta/figure-localization.png
Normal file
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 |
17
tests/typ/meta/figure-localization.typ
Normal file
17
tests/typ/meta/figure-localization.typ
Normal 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: [一个矩形],
|
||||||
|
)
|
@ -109,25 +109,3 @@ We can clearly see that @fig-cylinder and
|
|||||||
table(columns: 2)[a][b],
|
table(columns: 2)[a][b],
|
||||||
caption: [The table with custom separator.],
|
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é.],
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user