pub struct Translator { /* private fields */ }Expand description
核心翻译器
提供简化的翻译功能,支持文本和HTML翻译。
Implementations§
Source§impl Translator
impl Translator
Sourcepub fn new(config: TranslationConfig) -> TranslationResult<Self>
pub fn new(config: TranslationConfig) -> TranslationResult<Self>
创建新的翻译器实例
Sourcepub async fn translate_text(
&self,
text: &str,
target_lang: &str,
) -> TranslationResult<String>
pub async fn translate_text( &self, text: &str, target_lang: &str, ) -> TranslationResult<String>
翻译文本
Sourcepub async fn translate_html(
&self,
html: &str,
target_lang: &str,
) -> TranslationResult<String>
pub async fn translate_html( &self, html: &str, target_lang: &str, ) -> TranslationResult<String>
HTML翻译
Sourcepub async fn translate_dom(
&self,
dom: RcDom,
target_lang: &str,
) -> TranslationResult<RcDom>
pub async fn translate_dom( &self, dom: RcDom, target_lang: &str, ) -> TranslationResult<RcDom>
DOM翻译
Sourcepub async fn translate_texts(
&self,
texts: Vec<&str>,
target_lang: &str,
) -> TranslationResult<Vec<String>>
pub async fn translate_texts( &self, texts: Vec<&str>, target_lang: &str, ) -> TranslationResult<Vec<String>>
批量翻译文本
Trait Implementations§
Source§impl Clone for Translator
impl Clone for Translator
Source§fn clone(&self) -> Translator
fn clone(&self) -> Translator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Translator
impl !RefUnwindSafe for Translator
impl Send for Translator
impl Sync for Translator
impl Unpin for Translator
impl !UnwindSafe for Translator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more