importtype { LocaleKeys, Scopes } from'international-types'typeLocale = {
hello: 'Hello''scope.nested.demo': 'Nested scope''scope.nested.another.demo': 'Another nested scope'
}
function scopedT<ScopeextendsScopes<Locale>>(scope: Scope) {
function t<KeyextendsLocaleKeys<Locale, Scope>>(key: Key) {
// ...
}
}
const t = scopedT('')
// scope | scope.nestedt('')
// For scope: nested.demo | nested.another.demo// For scope.nested: demo | another.demo
Type-safe params
importtype { LocaleKeys, LocaleValue } from'international-types'typeLocale = {
param: 'This is a {value}''hello.people': 'Hello {name}! You are {age} years old.'
}
function t<
KeyextendsLocaleKeys<Locale, undefined>,
ValueextendsLocaleValue = ScopedValue<Locale, undefined, Key>,
>(key: Key, param: ParamsObject<Value>) {
// ...
}
t('param', {
value: ''// value is required
})
t('hello.people', {
name: '',
age: ''// name and age are required
})
The npm package international-types receives a total of 17,320 weekly downloads. As such, international-types popularity was classified as popular.
We found that international-types 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.
Package last updated on 01 Sep 2022
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.
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."