💼 This rule is enabled in the 🔥 ember
config.
Using string interpolation for constructing translation keys makes it difficult to search for them to determine where and if they are used.
This rule disallows string interpolation for constructing translation keys, particularly with calls to the ember-intl service t
helper.
Examples of incorrect code for this rule:
this.intl.t(`key.${variable}`);
Examples of correct code for this rule:
this.intl.t('some.translation.key');
function getStatusString(status) {
switch (status) {
case Status.INVALID_EMAIL: {
return this.intl.t('error.email');
}
case Status.INVALID_PHONE: {
return this.intl.t('error.phone');
}
default: {
return this.intl.t('error.unknown');
}
}
}
This rule takes an optional object containing:
string
--serviceName
-- optional override for service name to look for (default isintl
)boolean
--enforceStringLiteralKeys
-- optional override to restrict translation keys to only string literals (when disabled, function calls and variables are allowed) (default isfalse
)