@intlify/cli

  • Version 0.13.1
  • Published
  • 108 kB
  • 18 dependencies
  • MIT license

Install

npm i @intlify/cli
yarn add @intlify/cli
pnpm add @intlify/cli

Overview

CLI Tooling for i18n development

Index

Variables

variable DEFAULT_PRETTIER_OPTIONS

const DEFAULT_PRETTIER_OPTIONS: {
printWidth: number;
tabWidth: number;
jsonRecursiveSort: boolean;
plugins: string[];
};
  • The default prettier options for formatting the content of i18n custom blocks

    Modifiers

    • @public

Functions

function annotate

annotate: (
source: string,
filepath: string,
options?: AnnotateOptions
) => Promise<string>;
  • Annoate the Vue SFC block

    Parameter source

    The source code of the Vue SFC

    Parameter filepath

    The file path of the Vue SFC

    Parameter options

    The options of the annotate function

    Returns

    The annotated source code of the Vue SFC

    Modifiers

    • @public

function compile

compile: (
source: string,
output: string,
options?: CompileOptions
) => Promise<boolean>;
  • Compile i18n resources

    Parameter source

    the i18n resource source path, you can use glob pattern

    Parameter output

    the compiled i18n resource output path

    Parameter options

    CompileOptions

    Returns

    true when all i18n resource successfuly compile, not false

    Remarks

    This functoin is **asyncronous** function. If you want to get about error details, use the handler of CompileOptions and CompileErrorCodes

    Modifiers

    • @public

function format

format: (
source: string,
filepath: string,
options?: FormatOptions
) => Promise<string>;
  • Format the Vue SFC block

    Parameter source

    The source code of the Vue SFC

    Parameter filepath

    The file path of the Vue SFC

    Parameter options

    The options of the format function

    Returns

    The formatted source code of the Vue SFC

    Remarks

    Currently, only i18n custom blocks supporting

    Modifiers

    • @public

Classes

class FormatLangNotFoundError

class FormatLangNotFoundError extends Error {}
  • Fortmat lang fwnot found error

    Remarks

    The error that not specified lang attribute in i18n custom block

    Modifiers

    • @public

constructor

constructor(message: string, filepath: string);
  • Constructor

    Parameter message

    The error message

    Parameter filepath

    The filepath of the target file at formatting processing

property filepath

filepath: string;
  • The filepath of the target file at formatting processing

class SFCAnnotateError

class SFCAnnotateError extends Error {}
  • The Annocation error

    Modifiers

    • @public

constructor

constructor(message: string, filepath: string);
  • Constructor

    Parameter message

    The error message

    Parameter filepath

    The filepath of the target file at annotate processing

property filepath

filepath: string;
  • The filepath of the target file at annotate processing

Interfaces

interface AnnotateOptions

interface AnnotateOptions {}
  • Annotate options of annotate function

    Modifiers

    • @public

property attrs

attrs?: Record<string, any>;
  • The Attributes to be annotated on the block tag

    Remarks

    default as {}

property force

force?: boolean;
  • Whether to force annotations

    Remarks

    Force annotation of the attribute values of attrs option to the block tag. Even if the actual lang of the block content in the lang attribute is different, it will be enforced if this flag is turned on. default as false

property onWarn

onWarn?: (code: number, args: Record<string, any>, block: SFCBlock) => void;
  • The warning handler

    Remarks

    Notify warnings generated by the annotate process

property type

type?: string;
  • The type of the block

    Remarks

    Only i18n type is supported, if you don't specify it. If any other type is specified, the function will raise the SFCAnnotateError.

    default as i18n

property vue

vue?: number;
  • The Vue template compiler version

    Remarks

    The version of the Vue template to be parsed by the annotate function. If 2 is specified, the vue-template-compiler used by Vue 2 is used; if 3 is specified, the @vue/compiler-sfc used by Vue 3 is used. defalt as 3

interface CompileOptions

interface CompileOptions {}
  • Compile Options

    Remarks

    This optioins is used at compile function

    Modifiers

    • @public

property ast

ast?: boolean;
  • Whether to generate AST format

    Remarks

    default false, it will output the function format.

property mode

mode?: DevEnv;
  • Compile mode

    Remarks

    The mode of code generation. Default production for optimization. If development, code generated with meta information from i18n resources.

property onCompile

onCompile?: (source: string, output: string) => void;
  • Compile handler

property onError

onError?: (code: number, source: string, output: string, msg?: string) => void;
  • Compile Error handler

interface FormatOptions

interface FormatOptions {}
  • Format options of format function

    Modifiers

    • @public

property prettier

prettier?: Options;
  • The prettier options

    Remarks

    The options for formatting the content of i18n custom blocks with prettier default as DEFAULT_PRETTIER_OPTIONS

property vue

vue?: number;
  • The Vue template compiler version

    Remarks

    The version of the Vue template to be parsed by the annotate function. If 2 is specified, the vue-template-compiler used by Vue 2 is used; if 3 is specified, the @vue/compiler-sfc used by Vue 3 is used. defalt as 3

interface SFCParseError

interface SFCParseError extends SyntaxError {}
  • Vue SFC compiler error

    Remarks

    This is the error wrapping the error that occurred in Vue SFC compiler

    Modifiers

    • @public

property erorrs

erorrs: CompilerError[];
  • The error that occurred in Vue SFC compiler

property filepath

filepath: string;
  • The filepath of the source file

Enums

enum AnnotateWarningCodes

const enum AnnotateWarningCodes {
NOT_SUPPORTED_TYPE = 1,
LANG_MISMATCH_IN_SRC_AND_CONTENT = 2,
LANG_MISMATCH_IN_OPTION_AND_CONTENT = 3,
LANG_MISMATCH_IN_ATTR_AND_CONTENT = 4,
}
  • Annotate Warning Codes

    Remarks

    The warning codes of annotate function

    Modifiers

    • @public

member LANG_MISMATCH_IN_ATTR_AND_CONTENT

LANG_MISMATCH_IN_ATTR_AND_CONTENT = 4
  • Lang mismatch lang and block content

member LANG_MISMATCH_IN_OPTION_AND_CONTENT

LANG_MISMATCH_IN_OPTION_AND_CONTENT = 3
  • Lang mismatch option and block content

member LANG_MISMATCH_IN_SRC_AND_CONTENT

LANG_MISMATCH_IN_SRC_AND_CONTENT = 2
  • Lang mismatch block src and block content

member NOT_SUPPORTED_TYPE

NOT_SUPPORTED_TYPE = 1
  • Not supported type

enum CompileErrorCodes

const enum CompileErrorCodes {
NOT_SUPPORTED_FORMAT = 1,
INTERNAL_COMPILE_WARNING = 2,
INTERNAL_COMPILE_ERROR = 3,
}
  • Compile Error Codes

    Remarks

    The error codes of compile function

    Modifiers

    • @public

member INTERNAL_COMPILE_ERROR

INTERNAL_COMPILE_ERROR = 3
  • Internal compile error

member INTERNAL_COMPILE_WARNING

INTERNAL_COMPILE_WARNING = 2
  • Internal compile warning

member NOT_SUPPORTED_FORMAT

NOT_SUPPORTED_FORMAT = 1
  • Not supported format

Package Files (1)

Dependencies (18)

Dev Dependencies (24)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@intlify/cli.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@intlify/cli)
  • HTML
    <a href="https://www.jsdocs.io/package/@intlify/cli"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>