當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript i18n.__函數代碼示例

本文整理匯總了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,
    };
}
開發者ID:dsifford,項目名稱:academic-bloggers-toolkit,代碼行數:33,代碼來源:file.ts

示例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];
開發者ID:dsifford,項目名稱:academic-bloggers-toolkit,代碼行數:21,代碼來源:index.ts

示例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',
                },
開發者ID:dsifford,項目名稱:academic-bloggers-toolkit,代碼行數:31,代碼來源:index.ts

示例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'),
開發者ID:dsifford,項目名稱:academic-bloggers-toolkit,代碼行數:30,代碼來源:fieldmaps.ts


注:本文中的@wordpress/i18n.__函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。