i18n.js 566 B

12345678910111213141516
  1. import { get, isFunction } from '..';
  2. import { camelize } from '../format/string';
  3. import locale from '../../locale';
  4. export function createI18N(name) {
  5. var prefix = camelize(name) + '.';
  6. return function (path) {
  7. var messages = locale.messages();
  8. var message = get(messages, prefix + path) || get(messages, path);
  9. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10. args[_key - 1] = arguments[_key];
  11. }
  12. return isFunction(message) ? message.apply(void 0, args) : message;
  13. };
  14. }