Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@markuplint/i18n

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@markuplint/i18n - npm Package Compare versions

Comparing version 2.0.0-dev.20211115.0 to 2.0.0-dev.20211213.0

260

$schema.json

@@ -20,59 +20,126 @@ {

"properties": {
"tag": { "type": "string" },
"tag name": { "type": "string" },
"tag names": { "type": "string" },
"element": { "type": "string" },
"html elements": { "type": "string" },
"attribute": { "type": "string" },
"attributes": { "type": "string" },
". ": { "type": "string" },
"1": { "type": "string" },
"2": { "type": "string" },
"3": { "type": "string" },
"4": { "type": "string" },
"absolute url": { "type": "string" },
"accessible name": { "type": "string" },
"allow-list": { "type": "string" },
"alpha channel value": { "type": "string" },
"angle": { "type": "string" },
"aria in html specification": { "type": "string" },
"aria state/property": { "type": "string" },
"attribute name": { "type": "string" },
"attribute names": { "type": "string" },
"attribute value": { "type": "string" },
"attribute": { "type": "string" },
"attributes": { "type": "string" },
"autocomplete": { "type": "string" },
"autofill field name": { "type": "string" },
"autofill named group": { "type": "string" },
"boolean attribute": { "type": "string" },
"browsing context name": { "type": "string" },
"c:deprecated": { "type": "string" },
"c:disallowed": { "type": "string" },
"c:duplicated": { "type": "string" },
"c:ineffective": { "type": "string" },
"c:invalid": { "type": "string" },
"c:non-standard": { "type": "string" },
"c:obsolete": { "type": "string" },
"character": { "type": "string" },
"characters": { "type": "string" },
"class name": { "type": "string" },
"role": { "type": "string" },
"the abstract role": { "type": "string" },
"the implicit role": { "type": "string" },
"aria state/property": { "type": "string" },
"global state/property": { "type": "string" },
"value": { "type": "string" },
"default value": { "type": "string" },
"comma-separated list": { "type": "string" },
"comma": { "type": "string" },
"commas": { "type": "string" },
"content": { "type": "string" },
"contents": { "type": "string" },
"coron": { "type": "string" },
"custom element name": { "type": "string" },
"date time": { "type": "string" },
"date": { "type": "string" },
"datetime": { "type": "string" },
"declarate": { "type": "string" },
"default value": { "type": "string" },
"deprecated": { "type": "string" },
"descendant": { "type": "string" },
"semantics": { "type": "string" },
"accessible name": { "type": "string" },
"lowercase": { "type": "string" },
"uppercase": { "type": "string" },
"directive": { "type": "string" },
"disallowed": { "type": "string" },
"doctype": { "type": "string" },
"double-quote": { "type": "string" },
"duplicated": { "type": "string" },
"element": { "type": "string" },
"empty": { "type": "string" },
"empty string": { "type": "string" },
"extension": { "type": "string" },
"feature-identifier": { "type": "string" },
"escape in character reference": { "type": "string" },
"floating-point number": { "type": "string" },
"format": { "type": "string" },
"fractional part": { "type": "string" },
"global state/property": { "type": "string" },
"hash name": { "type": "string" },
"hash-name reference": { "type": "string" },
"hash": { "type": "string" },
"hour": { "type": "string" },
"html elements": { "type": "string" },
"http(s) schema": { "type": "string" },
"hyphen": { "type": "string" },
"illegal characters": { "type": "string" },
"empty string": { "type": "string" },
"zero": { "type": "string" },
"one": { "type": "string" },
"illegal combination": { "type": "string" },
"integer": { "type": "string" },
"invalid": { "type": "string" },
"keyword": { "type": "string" },
"list": { "type": "string" },
"lowercase": { "type": "string" },
"mime type with no parameters": { "type": "string" },
"mime type": { "type": "string" },
"minute": { "type": "string" },
"month": { "type": "string" },
"newline": { "type": "string" },
"non-negative integer": { "type": "string" },
"floating-point number": { "type": "string" },
"angle": { "type": "string" },
"alpha channel value": { "type": "string" },
"doctype": { "type": "string" },
"non-standard": { "type": "string" },
"number": { "type": "string" },
"obsolete doctype": { "type": "string" },
"hash-name reference": { "type": "string" },
"top level": { "type": "string" },
"declarate": { "type": "string" },
"obsolete": { "type": "string" },
"one code point character": { "type": "string" },
"one": { "type": "string" },
"origin": { "type": "string" },
"password": { "type": "string" },
"property name": { "type": "string" },
"query": { "type": "string" },
"quote": { "type": "string" },
"regular expression": { "type": "string" },
"role": { "type": "string" },
"second": { "type": "string" },
"semantics": { "type": "string" },
"serialized-origin": { "type": "string" },
"single-quote": { "type": "string" },
"space-separated list": { "type": "string" },
"space": { "type": "string" },
"spaces": { "type": "string" },
"tag name": { "type": "string" },
"tag names": { "type": "string" },
"tag": { "type": "string" },
"the abstract role": { "type": "string" },
"the content of the list": { "type": "string" },
"the html specification": { "type": "string" },
"the implicit role": { "type": "string" },
"the svg specification": { "type": "string" },
"the wai-aria specification": { "type": "string" },
"aria in html specification": { "type": "string" },
"deprecated": { "type": "string" },
"c:deprecated": { "type": "string" },
"obsolete": { "type": "string" },
"c:obsolete": { "type": "string" },
"non-standard": { "type": "string" },
"c:non-standard": { "type": "string" },
"duplicated": { "type": "string" },
"c:duplicated": { "type": "string" },
"disallowed": { "type": "string" },
"c:disallowed": { "type": "string" },
"invalid": { "type": "string" },
"c:invalid": { "type": "string" },
"escape in character reference": { "type": "string" },
". ": { "type": "string" }
"time-zone": { "type": "string" },
"time": { "type": "string" },
"token": { "type": "string" },
"top level": { "type": "string" },
"unit": { "type": "string" },
"uppercase": { "type": "string" },
"url who schema is an http(s) schema": { "type": "string" },
"username": { "type": "string" },
"value": { "type": "string" },
"whitespace": { "type": "string" },
"whitespaces": { "type": "string" },
"xml name": { "type": "string" },
"year": { "type": "string" },
"zero": { "type": "string" }
}

@@ -84,48 +151,83 @@ },

"properties": {
"the {0}": { "type": "string" },
"the \"{0}\"": { "type": "string" },
"the \"{0}\" {1}": { "type": "string" },
"the current \"{0}\" {1}": { "type": "string" },
"the implicit \"{0}\" {1}": { "type": "string" },
"{0} of {1}": { "type": "string" },
"{0:c} and {1:c}": { "type": "string" },
"either {0}": { "type": "string" },
"{0:c} on {1}": { "type": "string" },
"{0} ({1})": { "type": "string" },
"{0} according to {1}": { "type": "string" },
"{0} as {1}": { "type": "string" },
"{0} behaves the same as {1} if {2}": { "type": "string" },
"{0} chars": { "type": "string" },
"{0} contradicts {1}": { "type": "string" },
"{0} digits": { "type": "string" },
"{0} does not exist": { "type": "string" },
"{0} expects {1:c}": { "type": "string" },
"{0} expects {1}": { "type": "string" },
"{0} greater than {1} less than {2}": { "type": "string" },
"{0} greater than {1} less than or equal to {2}": { "type": "string" },
"{0} greater than {1}": { "type": "string" },
"less than {0}": { "type": "string" },
"less than or equal to {0}": { "type": "string" },
"in the range between {0} and {1}": { "type": "string" },
"valid {0}": { "type": "string" },
"unique {0}": { "type": "string" },
"{0} as {1}": { "type": "string" },
"the same {0} as {1}": { "type": "string" },
"{0} to {1}": { "type": "string" },
"{0} or {1}": { "type": "string" },
"{0} greater than or equal to {1} less than {2}": { "type": "string" },
"{0} greater than or equal to {1} less than or equal to {2}": { "type": "string" },
"{0} greater than or euqal to {1}": { "type": "string" },
"{0} has {1}": { "type": "string" },
"{0} includes {1}": { "type": "string" },
"{0} is {1:c}": { "type": "string" },
"{0} is {1}": { "type": "string" },
"{0} is {1:c}": { "type": "string" },
"{0} is disallowed": { "type": "string" },
"{0} is not {1}": { "type": "string" },
"It is {0}": { "type": "string" },
"It is {0:c}": { "type": "string" },
"{0} is unmatched with the below patterns: {1}": { "type": "string" },
"{0} less than {1}": { "type": "string" },
"{0} less than or equal to {1}": { "type": "string" },
"{0} must {1}": { "type": "string" },
"{0} must be {1}": { "type": "string" },
"{0} must not {1}": { "type": "string" },
"{0} must not be {1}": { "type": "string" },
"{0} needs {1}": { "type": "string" },
"{0} of {1}": { "type": "string" },
"{0} or {1}": { "type": "string" },
"{0} or more chars": { "type": "string" },
"{0} or more digits": { "type": "string" },
"{0} part of {1}": { "type": "string" },
"{0} should {1}": { "type": "string" },
"{0} must be {1}": { "type": "string" },
"{0} should be {1}": { "type": "string" },
"{0} must not {1}": { "type": "string" },
"{0} should not {1}": { "type": "string" },
"{0} must not be {1}": { "type": "string" },
"{0} should not be {1}": { "type": "string" },
"{0} expects {1}": { "type": "string" },
"{0} expects {1:c}": { "type": "string" },
"{0} has {1}": { "type": "string" },
"{0} behaves the same as {1} if {2}": { "type": "string" },
"{0} does not exist": { "type": "string" },
"{0} contradicts {1}": { "type": "string" },
"{0} syntax": { "type": "string" },
"{0} to {1} chars": { "type": "string" },
"{0} to {1} digits": { "type": "string" },
"{0} to {1}": { "type": "string" },
"a {0}": { "type": "string" },
"an {0}": { "type": "string" },
"Allowed values are: {0}": { "type": "string" },
"Cannot overwrite {0} to {1}": { "type": "string" },
"Cannot overwrite {0}": { "type": "string" },
"Did you mean \"{0}\"?": { "type": "string" },
"either {0}": { "type": "string" },
"extra {0}": { "type": "string" },
"Found {0}": { "type": "string" },
"in the range between {0} and {1}": { "type": "string" },
"It doesn't need {0}": { "type": "string" },
"It expects {0:c}": { "type": "string" },
"It expects {0}": { "type": "string" },
"It includes {0}": { "type": "string" },
"It is {0:c}": { "type": "string" },
"It is {0}": { "type": "string" },
"It needs {0}": { "type": "string" },
"less than {0}": { "type": "string" },
"less than or equal to {0}": { "type": "string" },
"Missing {0} in {1}": { "type": "string" },
"Missing {0}": { "type": "string" },
"Never {0} {1}": { "type": "string" },
"Require {0}": { "type": "string" },
"Never {0} {1}": { "type": "string" },
"Cannot overwrite {0}": { "type": "string" },
"Cannot overwrite {0} to {1}": { "type": "string" },
"{0:c} on {1}": { "type": "string" },
"{0} according to {1}": { "type": "string" },
"{0} is unmatched with the below patterns: {1}": { "type": "string" },
"Arrowed values are: {0}": { "type": "string" },
"Did you mean \"{0}\"?": { "type": "string" }
"the {0} format": { "type": "string" },
"the {0} part": { "type": "string" },
"the {0}": { "type": "string" },
"the \"{0}\" {1}": { "type": "string" },
"the \"{0}\"": { "type": "string" },
"the CSS Syntax \"{0}\"": { "type": "string" },
"the current \"{0}\" {1}": { "type": "string" },
"the implicit \"{0}\" {1}": { "type": "string" },
"the list of {0}": { "type": "string" },
"the same {0} as {1}": { "type": "string" },
"unexpected {0}": { "type": "string" },
"unique {0}": { "type": "string" },
"valid {0}": { "type": "string" }
}

@@ -132,0 +234,0 @@ }

@@ -1,2 +0,6 @@

import type { LocaleSet, Translator } from './types';
import type { LocaleSet, Primitive, Translator } from './types';
export declare function translator(localeSet?: LocaleSet): Translator;
/**
* @experimental
*/
export declare function taggedTemplateTranslator(localeSet?: LocaleSet): (strings: TemplateStringsArray, ...keys: Primitive[]) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.translator = void 0;
exports.taggedTemplateTranslator = exports.translator = void 0;
const defaultListFormat = {

@@ -11,18 +11,18 @@ quoteStart: '"',

return (messageTmpl, ...keywords) => {
var _a, _b;
var _a;
let message = messageTmpl;
if (Array.isArray(messageTmpl)) {
const format = (localeSet === null || localeSet === void 0 ? void 0 : localeSet.listFormat) || defaultListFormat;
return `${format.quoteStart}${messageTmpl.join(`${format.quoteEnd}${format.separator}${format.quoteStart}`)}${format.quoteEnd}`;
return `${format.quoteStart}${messageTmpl
.map(keyword => translateKeyword(keyword, '', localeSet))
.join(`${format.quoteEnd}${format.separator}${format.quoteStart}`)}${format.quoteEnd}`;
}
if (keywords.length === 0) {
const keyword = (_a = localeSet === null || localeSet === void 0 ? void 0 : localeSet.keywords) === null || _a === void 0 ? void 0 : _a[messageTmpl];
return keyword || messageTmpl;
return translateKeyword(messageTmpl, '', localeSet);
}
const sentence = (_b = localeSet === null || localeSet === void 0 ? void 0 : localeSet.sentences) === null || _b === void 0 ? void 0 : _b[messageTmpl];
if (sentence) {
messageTmpl = sentence;
}
const noTranslateIndex = Array.from(messageTmpl.matchAll(/(?<=\{)[0-9]+(?=\*\})/g)).map(m => m[0]);
const key = messageTmpl.replace(/(?<=\{[0-9]+)\*(?=\})/g, '');
const sentence = (_a = localeSet === null || localeSet === void 0 ? void 0 : localeSet.sentences) === null || _a === void 0 ? void 0 : _a[key];
messageTmpl = sentence !== null && sentence !== void 0 ? sentence : key;
message = messageTmpl.replace(/\{([0-9]+)(?::([c]))?\}/g, ($0, number, flag) => {
var _a, _b;
const num = parseInt(number);

@@ -33,10 +33,7 @@ if (isNaN(num)) {

const keyword = keywords[num] != null ? toString(keywords[num], localeSet === null || localeSet === void 0 ? void 0 : localeSet.locale) : '';
const key = flag ? `${flag}:${keyword}` : keyword;
const replacedWord =
// finding with flag
((_a = localeSet === null || localeSet === void 0 ? void 0 : localeSet.keywords) === null || _a === void 0 ? void 0 : _a[key.toLowerCase()]) ||
(
// finding without flag
(_b = localeSet === null || localeSet === void 0 ? void 0 : localeSet.keywords) === null || _b === void 0 ? void 0 : _b[keyword.toLowerCase()]);
return replacedWord || keyword;
// No translate
if (noTranslateIndex.includes(number)) {
return keyword;
}
return translateKeyword(keyword, flag, localeSet);
});

@@ -47,2 +44,39 @@ return message;

exports.translator = translator;
/**
* @experimental
*/
function taggedTemplateTranslator(localeSet) {
const t = translator(localeSet);
return (strings, ...keys) => {
let i = 0;
const template = strings.raw
.map((place, index) => {
if (index === strings.raw.length - 1)
return place;
const value = keys[i];
const cFlag = /^c:/.test(typeof value === 'string' ? value : '') ? ':c' : '';
return `${place}{${i++}${cFlag}}`;
})
.join('');
return t(template, ...keys);
};
}
exports.taggedTemplateTranslator = taggedTemplateTranslator;
function translateKeyword(keyword, flag, localeSet) {
var _a, _b;
// No translate
if (/^%[^%]+%$/.test(keyword)) {
return keyword.replace(/^%|%$/g, '');
}
// "%" prefix and suffix escaped
keyword = keyword.replace(/^%%|%%$/g, '%');
const key = flag ? `${flag}:${keyword}` : keyword;
const replacedWord =
// finding with flag
((_a = localeSet === null || localeSet === void 0 ? void 0 : localeSet.keywords) === null || _a === void 0 ? void 0 : _a[key.toLowerCase()]) ||
(
// finding without flag
(_b = localeSet === null || localeSet === void 0 ? void 0 : localeSet.keywords) === null || _b === void 0 ? void 0 : _b[keyword.toLowerCase()]);
return replacedWord || keyword;
}
function toString(value, locale = 'en') {

@@ -49,0 +83,0 @@ switch (typeof value) {

{
"keywords": {
"1": "one",
"2": "two",
"3": "three",
"4": "four",
"html elements": "HTML elements",

@@ -4,0 +8,0 @@ "the html specification": "the HTML specification",

@@ -8,108 +8,209 @@ {

"keywords": {
"tag": "タグ",
"tag name": "タグ名",
"tag names": "タグ名",
"element": "要素",
"html elements": "HTML要素",
"attribute": "属性",
"attributes": "属性",
". ": "。",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"absolute url": "絶対URL",
"accessible name": "アクセシブルな名前",
"allow-list": "許可リスト",
"alpha channel value": "不透明度",
"angle": "角度",
"aria in html specification": "ARIA in HTMLの仕様",
"aria state/property": "ARIAステート/プロパティ",
"attribute name": "属性名",
"attribute names": "属性名",
"attribute value": "属性値",
"attribute": "属性",
"attributes": "属性",
"autocomplete": "オートコンプリート",
"autofill field name": "オートフィルフィールド名",
"autofill named group": "オートフィルグループ名",
"boolean attribute": "論理属性",
"browsing context name": "閲覧コンテキスト名",
"c:deprecated": "は非推奨です",
"c:disallowed": "は許可されていません",
"c:duplicated": "が重複しています",
"c:ineffective": "は効果がありません",
"c:invalid": "は妥当ではありません",
"c:non-standard": "は非標準です",
"c:obsolete": "は廃止されています",
"character": "文字",
"characters": "文字",
"class name": "クラス名",
"role": "ロール",
"the abstract role": "抽象ロール",
"the implicit role": "暗黙のロール",
"aria state/property": "ARIAステート/プロパティ",
"global state/property": "グローバルステート/プロパティ",
"value": "値",
"default value": "デフォルト値",
"comma-separated list": "カンマ区切りのリスト",
"comma": "カンマ",
"commas": "カンマ",
"content": "内容",
"contents": "内容",
"coron": "コロン",
"custom element name": "カスタム要素名",
"date time": "日時",
"date": "日",
"datetime": "日時",
"declarate": "宣言",
"default value": "デフォルト値",
"deprecated": "非推奨",
"descendant": "子孫",
"semantics": "セマンティクス",
"accessible name": "アクセシブルな名前",
"lowercase": "小文字",
"uppercase": "大文字",
"directive": "ディレクティブ",
"disallowed": "未許可",
"doctype": "文書型",
"double-quote": "ダブルクオート",
"duplicated": "重複",
"element": "要素",
"empty string": "空文字",
"empty": "空",
"escape in character reference": "文字参照でエスケープ",
"extension": "拡張子",
"feature-identifier": "機能ID",
"floating-point number": "浮動小数点数",
"format": "形式",
"fractional part": "小数部",
"global state/property": "グローバルステート/プロパティ",
"hash name": "ハッシュ名",
"hash-name reference": "ハッシュ名参照",
"hash": "ハッシュ",
"hour": "時",
"html elements": "HTML要素",
"http(s) schema": "HTTP(S)スキーマ",
"hyphen": "ハイフン",
"illegal characters": "不正な文字",
"empty string": "空文字",
"zero": "ゼロ",
"one": "1",
"illegal combination": "不正な組み合わせ",
"integer": "整数",
"invalid": "不正",
"keyword": "キーワード",
"list": "リスト",
"lowercase": "小文字",
"mime type with no parameters": "パラメータなしMIMEタイプ",
"mime type": "MIMEタイプ",
"minute": "分",
"month": "月",
"newline": "改行",
"non-negative integer": "正の整数",
"floating-point number": "浮動小数点数",
"angle": "角度",
"alpha channel value": "不透明度",
"doctype": "文書型",
"non-standard": "非標準",
"number": "数値",
"obsolete doctype": "廃止された文書型",
"hash-name reference": "ハッシュ名参照",
"top level": "トップレベル",
"declarate": "宣言",
"obsolete": "廃止ずみ",
"one code point character": "1つのコードポイントから成る文字",
"one": "1",
"origin": "オリジン",
"password": "パスワード",
"property name": "プロパティ名",
"query": "クエリ",
"quote": "クオート",
"regular expression": "正規表現",
"role": "ロール",
"second": "秒",
"semantics": "セマンティクス",
"serialized-origin": "シリアル化されたオリジン",
"single-quote": "シングルクオート",
"space-separated list": "空白区切りのリスト",
"space": "空白",
"spaces": "空白",
"tag name": "タグ名",
"tag names": "タグ名",
"the abstract role": "抽象ロール",
"the content of the list": "リストの内容",
"the html specification": "HTMLの仕様",
"the implicit role": "暗黙のロール",
"the svg specification": "SVGの仕様",
"the wai-aria specification": "WAI-ARIAの仕様",
"aria in html specification": "ARIA in HTMLの仕様",
"deprecated": "非推奨",
"c:deprecated": "は非推奨です",
"obsolete": "廃止ずみ",
"c:obsolete": "は廃止されています",
"non-standard": "非標準",
"c:non-standard": "は非標準です",
"duplicated": "重複",
"c:duplicated": "が重複しています",
"disallowed": "未許可",
"c:disallowed": "は許可されていません",
"invalid": "不正",
"c:invalid": "は妥当ではありません",
"escape in character reference": "文字参照でエスケープ",
". ": "。"
"time-zone": "タイムゾーン",
"time": "時間",
"token": "トークン",
"top level": "トップレベル",
"unit": "単位",
"uppercase": "大文字",
"url who schema is an http(s) schema": "HTTP(S)スキーマのURL",
"username": "ユーザー名",
"value": "値",
"whitespace": "ホワイトスペース",
"whitespaces": "ホワイトスペース",
"xml name": "XML名",
"year": "年",
"zero": "ゼロ"
},
"sentences": {
"the {0}": "その{0}",
"the \"{0}\"": "「{0}」",
"the \"{0}\" {1}": "{1}「{0}」",
"the current \"{0}\" {1}": "現在の{1}「{0}」",
"the implicit \"{0}\" {1}": "暗黙の{1}「{0}」",
"{0} of {1}": "{1}の{0}",
"{0:c} and {1:c}": "{0}且つ、{1}",
"either {0}": "{0}のいずれか",
"{0:c} on {1}": "{1}では、{0:c}",
"{0} ({1})": "{0}({1})",
"{0} according to {1}": "{1}において、{0}",
"{0} as {1}": "{1}として{0}",
"{0} behaves the same as {1} if {2}": "{0}は{2}の場合、{1}と同じ振る舞いをします",
"{0} chars": "{0}文字",
"{0} contradicts {1}": "{0}は{1}と矛盾しています",
"{0} digits": "{0}桁",
"{0} does not exist": "{0}は存在しません",
"{0} expects {1:c}": "{0}は{1}である必要があります",
"{0} expects {1}": "{0}には{1}が必要です",
"{0} greater than {1} less than {2}": "{1}より大きく{2}より小さい{0}",
"{0} greater than {1} less than or equal to {2}": "{1}より大きく{2}以下の{0}",
"{0} greater than {1}": "{1}より大きい{0}",
"less than {0}": "{0}未満",
"less than or equal to {0}": "{0}以下",
"in the range between {0} and {1}": "{0}から{1}の範囲",
"valid {0}": "妥当な{0}",
"unique {0}": "一意の{0}",
"{0} as {1}": "{1}として{0}",
"the same {0} as {1}": "{1}と同等の{0}",
"{0} to {1}": "{0}から{1}",
"{0} or {1}": "{0}もしくは{1}",
"{0} greater than or equal to {1} less than {2}": "{1}以上で{2}より小さい{0}",
"{0} greater than or equal to {1} less than or equal to {2}": "{1}以上で{2}以下の{0}",
"{0} greater than or euqal to {1}": "{1}以上の{0}",
"{0} has {1}": "{0}は{1}を持っています",
"{0} includes {1}": "{0}は{1}を含んでいます",
"{0} is {1:c}": "{0}{1:c}",
"{0} is {1}": "{0}は{1}です",
"{0} is {1:c}": "{0}{1:c}",
"{0} is disallowed": "{0}は禁止されています",
"{0} is not {1}": "{0}は{1}ではありません",
"It is {0}": "{0}です",
"It is {0:c}": "{0:c}",
"{0} is unmatched with the below patterns: {1}": "{0}は次のパターンにマッチしませんでした {1}",
"{0} less than {1}": "{1}より小さい{0}",
"{0} less than or equal to {1}": "{1}以下の{0}",
"{0} must {1}": "{0}は{1}するべきです",
"{0} must be {1}": "{0}は{1}にするべきです",
"{0} must not {1}": "{0}は{1}するべきではありません",
"{0} must not be {1}": "{0}は{1}にするべきではありません",
"{0} needs {1}": "{0}には{1}が必要です",
"{0} of {1}": "{1}の{0}",
"{0} or {1}": "{0}もしくは{1}",
"{0} or more chars": "{0}文字以上",
"{0} or more digits": "{0}桁以上",
"{0} part of {1}": "{1}の{0}の部分",
"{0} should {1}": "{0}は{1}したほうがよいです",
"{0} must be {1}": "{0}は{1}にするべきです",
"{0} should be {1}": "{0}は{1}にしたほうがよいです",
"{0} must not {1}": "{0}は{1}するべきではありません",
"{0} should not {1}": "{0}は{1}しないほうがよいです",
"{0} must not be {1}": "{0}は{1}にするべきではありません",
"{0} should not be {1}": "{0}は{1}にしないほうがよいです",
"{0} expects {1}": "{0}には{1}が必要です",
"{0} expects {1:c}": "{0}は{1}である必要があります",
"{0} has {1}": "{0}は{1}を持っています",
"{0} behaves the same as {1} if {2}": "{0}は{2}の場合、{1}と同じ振る舞いをします",
"{0} does not exist": "{0}は存在しません",
"{0} contradicts {1}": "{0}は{1}と矛盾しています",
"{0} syntax": "{0}構文",
"{0} to {1} chars": "{0}から{1}文字",
"{0} to {1} digits": "{0}から{1}桁",
"{0} to {1}": "{0}から{1}",
"a {0}": "{0}",
"an {0}": "{0}",
"Allowed values are: {0}": "許可されている値は次のとおりです {0}",
"Cannot overwrite {0} to {1}": "{0}を{1}に上書きすることはできません",
"Cannot overwrite {0}": "{0}を上書きすることはできません",
"Did you mean \"{0}\"?": "「{0}」ではありませんか?",
"either {0}": "{0}のいずれか",
"extra {0}": "余計な{0}",
"Found {0}": "{0}が発見されました",
"in the range between {0} and {1}": "{0}から{1}の範囲",
"It doesn't need {0}": "{0}は不要です",
"It expects {0:c}": "{0}である必要があります",
"It expects {0}": "{0}が必要です",
"It includes {0}": "{0}を含んでいます",
"It is {0:c}": "{0:c}",
"It is {0}": "{0}です",
"It needs {0}": "{0}が必要です",
"less than {0}": "{0}未満",
"less than or equal to {0}": "{0}以下",
"Missing {0} in {1}": "{1}に{0}がありません",
"Missing {0}": "{0}がありません",
"Never {0} {1}": "{1}を{0}しないでください",
"Require {0}": "{0}が必要です",
"Never {0} {1}": "{1}を{0}しないでください",
"Cannot overwrite {0}": "{0}を上書きすることはできません",
"Cannot overwrite {0} to {1}": "{0}を{1}に上書きすることはできません",
"{0:c} on {1}": "{1}では、{0:c}",
"{0} according to {1}": "{1}において、{0}",
"{0} is unmatched with the below patterns: {1}": "{0}は次のパターンにマッチしませんでした {1}",
"Arrowed values are: {0}": "許可されている値は次のとおりです {0}",
"Did you mean \"{0}\"?": "「{0}」ですか?"
"the {0} format": "{0}形式",
"the {0} part": "{0}の部分",
"the {0}": "{0}",
"the \"{0}\" {1}": "{1}「{0}」",
"the \"{0}\"": "「{0}」",
"the CSS Syntax \"{0}\"": "CSS構文として「{0}」",
"the current \"{0}\" {1}": "現在の{1}「{0}」",
"the implicit \"{0}\" {1}": "暗黙の{1}「{0}」",
"the list of {0}": "{0}のリスト",
"the same {0} as {1}": "{1}と同等の{0}",
"unexpected {0}": "期待されない{0}",
"unique {0}": "一意の{0}",
"valid {0}": "妥当な{0}"
}
}
{
"name": "@markuplint/i18n",
"version": "2.0.0-dev.20211115.0",
"version": "2.0.0-dev.20211213.0",
"description": "HTML parser for markuplint",

@@ -18,3 +18,3 @@ "repository": "git@github.com:markuplint/markuplint.git",

},
"gitHead": "11bcb81138ae11362add9b502124011735cc784a"
"gitHead": "8f4682ca3e0937082af8c39b999443afa4a1aef3"
}

@@ -17,2 +17,150 @@ # @markuplint/i18n

## API
```ts
import { translator } from '@markuplint/i18n';
const t = translator({
locale: 'ja',
...require('@markuplint/i18n/locales/ja.json'),
});
```
The `translator` function creates the `t` function.
It is an overloading function that accepts kind of arguments below:
### Translate sentence
```ts
type T = (template?: string, ...values: string[]) => string;
```
```ts
const message = t(
// Template #1
'{0} is {1:c}',
// The {0} value of template #1
t(
// Template #2
'{0} of {1}',
// The {0} value of template #2
t(
// Template #3
'the {0}',
// The {0} value of template #3
'value',
),
// The {1} value of template #2
t(
// Template #4
'the "{0*}" {1}',
// The {0} value of template #4
'id',
// The {1} value of template #4
'attribute',
),
),
// The {1} value of template #1
'duplicated',
);
console.log(message);
// => 属性「id」の値が重複しています
```
#### Placeholder
There is a placeholder that the number is surrounded by `{}` on template strings. It is replaced argument as a phrase. It translates the phrase if it matches the keyword defined in the dictionary.
#### Tagged templates syntax
⚠️ It is experimental.
```ts
import { taggedTemplateTranslator } from '@markuplint/i18n';
const _ = taggedTemplateTranslator(ja);
const message = _`${
//
_`${
//
_`the ${'value'}`
} of ${
//
_`the "${'id'}" ${'attribute'}`
}`
} is ${
//
'c:duplicated'
}`;
console.log(message);
// => 属性「id」の値が重複しています
```
### Translate a phrase
```ts
type T = (phrase: string) => string;
```
```ts
const phrase = t('element');
console.log(phrase);
// => 要素
```
### Translate listed phrases
```ts
type T = (phrases: string[]) => string;
```
```ts
const list = t(['element', 'attribute', 'value']);
console.log(list);
// => 「要素」「属性」「値」
/* If locale is "en" */
console.log(list);
// => "element", "attribute", "value"
```
It converts the character-separated list specified in each locale.
| Locale | Separater | Before Char | After Char |
| ------ | -------------------- | -------------------------- | --------------------------- |
| **en** | `, ` (camma + space) | `"` (double quote) | `"` (double quote) |
| **ja** | none (empty string) | `「` (left corner bracket) | `」` (right corner bracket) |
### Avoid translation
The `autocomplete` is defined as `オートコンプリート` in the **JA** dictionary.
However, It avoids translation if the number placeholder includes `*` (asterisk).
It is an effective means if you want a code or a specific name.
```ts
const phrase = t('the "{0}" {1}', 'autocomplete', 'attribute');
console.log(phrase);
// => 属性「オートコンプリート」
const phrase = t('the "{0*}" {1}', 'autocomplete', 'attribute');
console.log(phrase);
// => 属性「autocomplete」
```
Another means is that it surrounds `%` (percentage) to a phrase. It is effective when you use listing.
```ts
const phrase = t('the "{0}" {1}', '%autocomplete%', 'attribute');
console.log(phrase);
// => 属性「autocomplete」
const list = t(['element', '%attribute%', 'value']);
console.log(list);
// => 「要素」「attribute」「値」
```
## Contributing

@@ -19,0 +167,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc