本文整理汇总了TypeScript中@wordpress/i18n.__函数的典型用法代码示例。如果您正苦于以下问题:TypeScript __函数的具体用法?TypeScript __怎么用?TypeScript __使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了__函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: parseCSL
export async function parseCSL(file: File): Promise<Style> {
const content = await readFile(file);
const xml = new DOMParser().parseFromString(content, 'application/xml');
const error = xml.querySelector('parsererror');
const label = xml.querySelector('info title');
const shortTitle = xml.querySelector('info title-short');
if (error) {
const message = error.querySelector('div');
throw new Error(
message && message.textContent
? message.textContent
: __('Error parsing CSL file.', 'academic-bloggers-toolkit'),
);
}
if (!label || !label.textContent) {
throw new Error(
__('Error parsing CSL file.', 'academic-bloggers-toolkit'),
);
}
// trim away unnecessary whitespace
const value = content
.replace(/(?:[\r\n]|<!--.*?-->)/g, '')
.replace(/(>)(\s+?)(<)/g, '$1$3');
return {
kind: StyleKind.CUSTOM,
value,
label: label.textContent,
shortTitle:
shortTitle && shortTitle.textContent
? shortTitle.textContent
: undefined,
};
}
示例2: __
import { __ } from '@wordpress/i18n';
import { FormatConfig } from '@wordpress/rich-text';
import { FootnoteElement } from 'utils/element';
import Footnote from './footnote';
export const name = 'abt/footnote';
export const config: FormatConfig = {
tagName: 'span',
className: FootnoteElement.className,
title: __('Footnote', 'academic-bloggers-toolkit'),
attributes: {
editable: 'contenteditable',
id: 'id',
note: 'data-note',
},
edit: Footnote,
};
export default [name, config] as [string, typeof config];
示例3: __
import { __ } from '@wordpress/i18n';
import FootnotesEdit from './edit';
import FootnotesSave from './save';
export interface Attributes {
items: Array<{
id: string;
content: string;
}>;
}
export const name = 'abt/footnotes';
export const config: BlockConfig<Attributes> = {
title: __('Footnotes', 'academic-bloggers-toolkit'),
category: 'widgets',
description: __('Display a list of footnotes', 'academic-bloggers-toolkit'),
icon: 'testimonial',
attributes: {
items: {
type: 'array',
default: [],
source: 'query',
selector: 'li',
query: {
id: {
source: 'attribute',
type: 'string',
attribute: 'id',
},
示例4: __
export interface InputField extends BaseField<keyof CSL.Data> {
readonly inputProps?: Readonly<HTMLProps<HTMLInputElement>>;
}
export type PersonField = BaseField<CSL.PersonFieldKey>;
export interface FieldMapping {
readonly title: string;
readonly fields: InputField[];
readonly people: PersonField[];
}
const CSL_FIELDS: Readonly<Record<string, FieldMapping>> = {
bill: {
title: __('Bill', 'academic-bloggers-toolkit'),
fields: [
{
key: 'title',
label: __('Title', 'academic-bloggers-toolkit'),
inputProps: {
required: true,
},
},
{
key: 'number',
label: __('Bill Number', 'academic-bloggers-toolkit'),
},
{
key: 'page',
label: __('Code Pages', 'academic-bloggers-toolkit'),