consul/ui/packages/consul-ui/app/utils/intl/missing-message.js
John Cowen 7761d0abe4
ui: Fix intl keys in order to render correct messages for empty states (#13409)
* ui: Fix intl keys in order to render correct messages for empty states

* Add a debug only debug log to warn about missing keys
2022-06-16 12:07:04 +01:00

17 lines
485 B
JavaScript

/* eslint no-console: ["error", { allow: ["debug"] }] */
import { runInDebug } from '@ember/debug';
// if we can't find the message, take the last part of the identifier and
// ucfirst it so it looks human
export default function missingMessage(key, locales) {
runInDebug(
_ => console.debug(`Translation key not found: ${key}`)
);
const last = key
.split('.')
.pop()
.split('-')
.join(' ');
return `${last.substr(0, 1).toUpperCase()}${last.substr(1)}`;
}