Add translation for Chinese (Traditional) (#1000)
This commit is contained in:
parent
86d7ac881b
commit
e0d5930405
@ -34,6 +34,7 @@ use ttf_parser::{GlyphId, Rect};
|
||||
use typst::eval::{Module, Scope};
|
||||
use typst::font::{Font, FontWeight};
|
||||
use typst::model::Guard;
|
||||
use typst::util::option_eq;
|
||||
use unicode_math_class::MathClass;
|
||||
|
||||
use self::ctx::*;
|
||||
@ -277,10 +278,11 @@ impl Count for EquationElem {
|
||||
}
|
||||
|
||||
impl LocalName for EquationElem {
|
||||
fn local_name(&self, lang: Lang, _: Option<Region>) -> &'static str {
|
||||
fn local_name(&self, lang: Lang, region: Option<Region>) -> &'static str {
|
||||
match lang {
|
||||
Lang::ARABIC => "معادلة",
|
||||
Lang::BOKMÅL => "Ligning",
|
||||
Lang::CHINESE if option_eq(region, "TW") => "方程式",
|
||||
Lang::CHINESE => "等式",
|
||||
Lang::CZECH => "Rovnice",
|
||||
Lang::FRENCH => "Équation",
|
||||
|
@ -7,6 +7,7 @@ use ecow::{eco_vec, EcoVec};
|
||||
use hayagriva::io::{BibLaTeXError, YamlBibliographyError};
|
||||
use hayagriva::style::{self, Brackets, Citation, Database, DisplayString, Formatting};
|
||||
use hayagriva::Entry;
|
||||
use typst::util::option_eq;
|
||||
|
||||
use super::{LinkElem, LocalName, RefElem};
|
||||
use crate::layout::{BlockElem, GridElem, ParElem, Sizing, TrackSizings, VElem};
|
||||
@ -210,10 +211,11 @@ impl Finalize for BibliographyElem {
|
||||
}
|
||||
|
||||
impl LocalName for BibliographyElem {
|
||||
fn local_name(&self, lang: Lang, _: Option<Region>) -> &'static str {
|
||||
fn local_name(&self, lang: Lang, region: Option<Region>) -> &'static str {
|
||||
match lang {
|
||||
Lang::ARABIC => "المراجع",
|
||||
Lang::BOKMÅL => "Bibliografi",
|
||||
Lang::CHINESE if option_eq(region, "TW") => "書目",
|
||||
Lang::CHINESE => "参考文献",
|
||||
Lang::CZECH => "Bibliografie",
|
||||
Lang::FRENCH => "Bibliographie",
|
||||
|
@ -1,4 +1,5 @@
|
||||
use typst::font::FontWeight;
|
||||
use typst::util::option_eq;
|
||||
|
||||
use super::{Counter, CounterUpdate, LocalName, Numbering, Refable};
|
||||
use crate::layout::{BlockElem, HElem, VElem};
|
||||
@ -234,10 +235,11 @@ impl Refable for HeadingElem {
|
||||
}
|
||||
|
||||
impl LocalName for HeadingElem {
|
||||
fn local_name(&self, lang: Lang, _: Option<Region>) -> &'static str {
|
||||
fn local_name(&self, lang: Lang, region: Option<Region>) -> &'static str {
|
||||
match lang {
|
||||
Lang::ARABIC => "الفصل",
|
||||
Lang::BOKMÅL => "Kapittel",
|
||||
Lang::CHINESE if option_eq(region, "TW") => "小節",
|
||||
Lang::CHINESE => "小节",
|
||||
Lang::CZECH => "Kapitola",
|
||||
Lang::FRENCH => "Chapitre",
|
||||
|
@ -259,7 +259,14 @@ enum NumberingKind {
|
||||
Roman,
|
||||
Symbol,
|
||||
Hebrew,
|
||||
Chinese,
|
||||
SimplifiedChinese,
|
||||
// TODO: Pick the numbering pattern based on languages choice.
|
||||
// As the `1st` numbering character of Chinese (Simplifed) and
|
||||
// Chinese (Traditional) is same, we are unable to determine
|
||||
// if the context is Simplified or Traditional by only this
|
||||
// character.
|
||||
#[allow(unused)]
|
||||
TraditionalChinese,
|
||||
HiraganaIroha,
|
||||
KatakanaIroha,
|
||||
}
|
||||
@ -273,7 +280,7 @@ impl NumberingKind {
|
||||
'i' => NumberingKind::Roman,
|
||||
'*' => NumberingKind::Symbol,
|
||||
'א' => NumberingKind::Hebrew,
|
||||
'一' | '壹' => NumberingKind::Chinese,
|
||||
'一' | '壹' => NumberingKind::SimplifiedChinese,
|
||||
'い' => NumberingKind::HiraganaIroha,
|
||||
'イ' => NumberingKind::KatakanaIroha,
|
||||
_ => return None,
|
||||
@ -288,7 +295,8 @@ impl NumberingKind {
|
||||
Self::Roman => 'i',
|
||||
Self::Symbol => '*',
|
||||
Self::Hebrew => 'א',
|
||||
Self::Chinese => '一',
|
||||
Self::SimplifiedChinese => '一',
|
||||
Self::TraditionalChinese => '一',
|
||||
Self::HiraganaIroha => 'い',
|
||||
Self::KatakanaIroha => 'イ',
|
||||
}
|
||||
@ -437,18 +445,22 @@ impl NumberingKind {
|
||||
}
|
||||
fmt
|
||||
}
|
||||
Self::Chinese => {
|
||||
let chinesecase = match case {
|
||||
l @ (Self::SimplifiedChinese | Self::TraditionalChinese) => {
|
||||
let chinese_case = match case {
|
||||
Case::Lower => ChineseCase::Lower,
|
||||
Case::Upper => ChineseCase::Upper,
|
||||
};
|
||||
|
||||
match (n as u8).to_chinese(
|
||||
ChineseVariant::Simple,
|
||||
chinesecase,
|
||||
match l {
|
||||
Self::SimplifiedChinese => ChineseVariant::Simple,
|
||||
Self::TraditionalChinese => ChineseVariant::Traditional,
|
||||
_ => unreachable!(),
|
||||
},
|
||||
chinese_case,
|
||||
ChineseCountMethod::TenThousand,
|
||||
) {
|
||||
Ok(chinesestring) => EcoString::from(chinesestring),
|
||||
Ok(num_str) => EcoString::from(num_str),
|
||||
Err(_) => '-'.into(),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user