![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@markuplint/i18n
Advanced tools
markuplint
package includes this package.
$ npm install @markuplint/i18n
$ yarn add @markuplint/i18n
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:
type T = (template?: string, ...values: string[]) => string;
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」の値が重複しています
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.
:warning: It is experimental.
import { taggedTemplateTranslator } from '@markuplint/i18n';
const _ = taggedTemplateTranslator({
locale: 'ja',
...require('path/to/dictionary/ja.json'),
});
const message = _`${
//
_`${
//
_`the ${'value'}`
} of ${
//
_`the "${'id'}" ${'attribute'}`
}`
} is ${
//
'c:duplicated'
}`;
console.log(message);
// => 属性「id」の値が重複しています
type T = (phrase: string) => string;
const phrase = t('element');
console.log(phrase);
// => 要素
type T = (phrases: string[]) => string;
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 | Separator | Before Char | After Char |
---|---|---|---|
en | , (comma + space) | " (double quote) | " (double quote) |
ja | none (empty string) | 「 (left corner bracket) | 」 (right corner bracket) |
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.
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.
const phrase = t('the "{0}" {1}', '%autocomplete%', 'attribute');
console.log(phrase);
// => 属性「autocomplete」
const list = t(['element', '%attribute%', 'value']);
console.log(list);
// => 「要素」「attribute」「値」
FAQs
Internationalization for markuplint
The npm package @markuplint/i18n receives a total of 5,260 weekly downloads. As such, @markuplint/i18n popularity was classified as popular.
We found that @markuplint/i18n demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.