Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@sveltekit-i18n/parser-default
Advanced tools
customModifiers
?: Record<string, (value: string, options: Array<{ key: string; value: string; }>, defaultValue?: string, locale?: string) => string>You can use this parameter to include your own set of modifiers.
For example custom modifier eqAbs
...
{
eqAbs: (value, options, defaultValue, locale) => options.find(({ key }) => Math.abs(key) === Math.abs(value))?.value || defaultValue
}
...can be used in the definitions like this:
{{placeholder:eqAbs; key1:value1; key2:value2; default:defaultValue;}}
Read more about Modifiers.
Every placeholder or modifiers starts with {{
and ends with }}
and can be included in your translations like this:
{
"prop": "Some value",
"module": {
"placeholder": "Title with {{placeholder}}.",
"placeholder_with_default_value": "{{placeholder; default:Default value;}}.",
"modifier": "{{gender; female:She; male:He;}} has a dog.",
"combined": "You have {{number:gt; 0:{{number}} new {{number; 1:message; default:messages;}}!; default:no messages.;}}"
}
}
Placeholders work as a connection between static translations and dynamic content. They are usually replaced by dynamic values, which are same for all language mutations.
Placeholder notation looks like this:
{{placeholder}}
<!-- or: -->
{{placeholder;}}
You can also use default
value. This value is used in case there is no appropriate value in translation payload.
{{placeholder; default:This is default value;}}
The default
value can be also set dynamically using the translation payload in your .svelte
file. For example:
$t(`error.${code}`, { default: $t('error.default') })
This value is used in case no default
value is defined within the placeholder definition itself. For more, see Dynamic default
section in parser-default example.
Modifiers don't represent the payload value directly, but they can use it for further calculations. Currently, these modifiers are in place:
eq
– input value is equal to the value in your definition (string comparison, case insensitive).
ne
– input value is not equal to the value in your definition (string comparison, case insensitive).
lt
– input value is lower than the value in your definition.
lte
– input value is lower than or equal to the value in your definition.
gt
– input value is greater than the value in your definition.
gte
– input value is greater than or equal to the value in your definition.
number
– input value is converted to locale formatted number string.
date
– input value is converted to locale date string.
ago
– input value is converted to locale relative date string.
Each modifier returns a string value based on these input parameters:
When placeholder value is not matched and you don't specify the default
value, modifier returns an empty string.
You can include your own modifiers in Options! See parser-default
example in Examples.
Modifier definition looks like this:
{{placeholder:modifier; placeholderVal1:Interpolation value 1; placeholderVal2:Interpolation value 2; ... ; default:Default value;}}
In case you don't specify the modifier, but interpolation options are set, eq
modifier is used by default:
<!-- this modifier definition uses `eq` modifier by default -->
{{placeholder; placeholder_value:Interpolation value;}}
You are allowed to use nested placeholders
and modifiers
within your modifier definition.
NOTE: ;
, :
, {
and }
characters are used as placeholder identifiers and separators, so you shouldn't use them within your definition keys and values. You should use their escaped form insead (\\;
, \\:
, \\{
or \\}
).
FAQs
Default parser for sveltekit-i18n library.
The npm package @sveltekit-i18n/parser-default receives a total of 7,970 weekly downloads. As such, @sveltekit-i18n/parser-default popularity was classified as popular.
We found that @sveltekit-i18n/parser-default demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.