本文整理匯總了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'),