Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@skyscanner/babel-plugin-skyscanner-i18n
Advanced tools
A Babel transform plugin to replace strings with their translations.
A Babel transform plugin to replace strings with their translations.
.babelrc
{
"plugins": [
["skyscanner-i18n", {
"dictionary": {
"Hello": "Bonjour",
"Hello, {name}!": "Bonjour, {name}!"
}
}]
]
}
In
const name = 'Brad';
const hello = t('Hello');
const helloWithName = t('Hello, {name}!', {
name
})
Out
const name = 'Brad';
const hello = 'Bonjour';
const helloWithName = 'Bonjour, ' + name + '!';
npm i -D babel-plugin-skyscanner-i18n
.babelrc
{
"plugins": [
["skyscanner-i18n", {
"functionName": "t",
"dictionary": {}
}]
]
}
require('babel-core').transform('code', {
plugins: [
['skyscanner-i18n', {
functionName: 't',
dictionary: {}
}]
]
});
There are two options available, both are optional:
dictionary
A mapping of the strings passed to the translation function to their translated versions. If no dictionary is passed, calls to the translation function will be replaced with the original string.
functionName
The name of the function that wraps the strings. Defaults to t
.
leftDelimiter
, rightDelimiter
The delimiter to be used for templating. Defaults to {
}
.
delimiter
Shorthand for when both leftDelimiter
and rightDelimiter
are the same. Example: @@
FAQs
A Babel transform plugin to replace strings with their translations.
The npm package @skyscanner/babel-plugin-skyscanner-i18n receives a total of 2 weekly downloads. As such, @skyscanner/babel-plugin-skyscanner-i18n popularity was classified as not popular.
We found that @skyscanner/babel-plugin-skyscanner-i18n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.