ember-intl
Version:
Internationalization for Ember projects
32 lines (25 loc) • 763 B
text/typescript
import Helper from '@ember/component/helper';
import service from '../-private/utils/service';
import type IntlService from '../services/intl';
type TParameters = Parameters<IntlService['t']>;
type Key = TParameters[0];
type Options = TParameters[1];
interface TSignature {
Args: {
Named?: Options;
Positional: [Key] | [Key, Options];
};
Return: string;
}
export default class THelper extends Helper<TSignature> {
declare intl: IntlService;
compute(
[key, positionalOptions]: TSignature['Args']['Positional'],
namedOptions: TSignature['Args']['Named'],
) {
const options = positionalOptions
? Object.assign({}, positionalOptions, namedOptions)
: namedOptions;
return this.intl.t(key, options);
}
}