Add gettext po/pot support

This commit is contained in:
2025-09-06 17:05:29 +08:00
parent 65b22ccddf
commit ca3cd41c0a
4 changed files with 843 additions and 0 deletions

View File

@@ -58,6 +58,25 @@ impl Encoding {
_ => false,
}
}
/// Returns the charset name
pub fn charset(&self) -> Option<&'static str> {
match self {
Self::Auto => None,
Self::Utf8 => Some("UTF-8"),
Self::Cp932 => Some("shift_jis"),
Self::Gb2312 => Some("gbk"),
Self::Utf16LE => Some("utf-16le"),
#[cfg(windows)]
Self::CodePage(code_page) => match *code_page {
932 => Some("shift_jis"),
65001 => Some("utf-8"),
1200 => Some("utf-16le"),
936 => Some("gbk"),
_ => None,
},
}
}
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
@@ -90,6 +109,10 @@ pub enum OutputScriptType {
Json,
/// YAML (same as JSON, but with YAML syntax)
Yaml,
/// Gettext .pot file
Pot,
/// Gettext .po file
Po,
/// Custom output
Custom,
}
@@ -110,6 +133,8 @@ impl AsRef<str> for OutputScriptType {
OutputScriptType::M3tTxt => "txt",
OutputScriptType::Json => "json",
OutputScriptType::Yaml => "yaml",
OutputScriptType::Pot => "pot",
OutputScriptType::Po => "po",
OutputScriptType::Custom => "",
}
}