SetLanguage
指定处理当前段落内容时用于检查拼写和语法(如果请求)的语言。
语法
expression.SetLanguage(langId);
expression - 表示 ApiParagraph 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| langId | 必需 | string | null | 此参数的可能值为 RFC 4646/BCP 47 定义的语言标识符。示例:"en-CA"。传递 null 可移除语言。 |
返回值
ApiParagraph | null
示例
为文档中段落的全部文本设置拼写检查语言。
// How do I tell the editor which language to use when checking a whole paragraph in a document?
// Set the language of the paragraph and print it in a document.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a paragraph with the spell-check language set.");
paragraph.SetLanguage("en-CA");
let resultParagraph = Api.CreateParagraph();
resultParagraph.AddText("Paragraph language: " + paragraph.GetRange().GetTextPr().GetLanguage());
doc.Push(resultParagraph);