@markuplint/i18n
Advanced tools
Comparing version 2.0.0-rc.5 to 2.0.0
@@ -6,2 +6,4 @@ import type { LocaleSet, Primitive, Translator } from './types'; | ||
*/ | ||
export declare function taggedTemplateTranslator(localeSet?: LocaleSet): (strings: TemplateStringsArray, ...keys: Primitive[]) => string; | ||
export declare function taggedTemplateTranslator( | ||
localeSet?: LocaleSet, | ||
): (strings: TemplateStringsArray, ...keys: Primitive[]) => string; |
export declare type Translator = (messageTmpl: string | string[], ...keywords: Primitive[]) => string; | ||
export declare type LocaleSet = { | ||
locale: string; | ||
listFormat?: ListFormat; | ||
keywords?: LocalesKeywords; | ||
sentences?: LocalesKeywords; | ||
locale: string; | ||
listFormat?: ListFormat; | ||
keywords?: LocalesKeywords; | ||
sentences?: LocalesKeywords; | ||
}; | ||
export declare type ListFormat = { | ||
quoteStart: string; | ||
quoteEnd: string; | ||
separator: string; | ||
quoteStart: string; | ||
quoteEnd: string; | ||
separator: string; | ||
}; | ||
export declare type Primitive = string | number | boolean; | ||
export declare type LocalesKeywords = { | ||
[messageId: string]: string | void; | ||
[messageId: string]: string | void; | ||
}; |
{ | ||
"name": "@markuplint/i18n", | ||
"version": "2.0.0-rc.5", | ||
"version": "2.0.0", | ||
"description": "HTML parser for markuplint", | ||
@@ -18,3 +18,3 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
}, | ||
"gitHead": "7c93367a86f935f6b94780b1fa14f3293f900b87" | ||
"gitHead": "de81fc514acdf472f87184e3499e9364258f9b66" | ||
} |
@@ -9,4 +9,2 @@ # @markuplint/i18n | ||
Prerequisites: [Node.js](https://nodejs.org) (Version 12.4.0 or later) | ||
```sh | ||
@@ -24,4 +22,4 @@ $ npm install @markuplint/i18n | ||
const t = translator({ | ||
locale: 'ja', | ||
...require('@markuplint/i18n/locales/ja.json'), | ||
locale: 'ja', | ||
...require('@markuplint/i18n/locales/ja.json'), | ||
}); | ||
@@ -41,27 +39,27 @@ ``` | ||
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', | ||
// 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', | ||
); | ||
@@ -83,16 +81,20 @@ | ||
import { taggedTemplateTranslator } from '@markuplint/i18n'; | ||
const _ = taggedTemplateTranslator(ja); | ||
const _ = taggedTemplateTranslator({ | ||
locale: 'ja', | ||
...require('path/to/dictionary/ja.json'), | ||
}); | ||
const message = _`${ | ||
// | ||
_`${ | ||
// | ||
_`the ${'value'}` | ||
} of ${ | ||
// | ||
_`the "${'id'}" ${'attribute'}` | ||
}` | ||
// | ||
_`${ | ||
// | ||
_`the ${'value'}` | ||
} of ${ | ||
// | ||
_`the "${'id'}" ${'attribute'}` | ||
}` | ||
} is ${ | ||
// | ||
'c:duplicated' | ||
// | ||
'c:duplicated' | ||
}`; | ||
@@ -168,14 +170,1 @@ | ||
``` | ||
## Contributing | ||
``` | ||
$ git clone git@github.com:markuplint/markuplint.git -b main | ||
$ yarn | ||
$ yarn build | ||
$ yarn test | ||
``` | ||
--- | ||
Copyright © 2021 markuplint. Under the MIT License. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
592
1
68047
166