You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
539 B
JavaScript

// External dependencies.
import { get } from 'lodash';
// Internal dependencies.
import config from './config';
const i18n = (context, key, ...args) => {
const value = get(context, key, '');
if ('production' !== process.env.NODE_ENV && '' === value) {
console.error('Failed to find i18n string:', key);
}
if (args.length > 0) {
const sprintf = get(window, 'wp.i18n.sprintf');
return sprintf(value, ...args);
}
return value;
};
export default (path, key, ...args) => i18n(config.i18n, [path, key], ...args);