i18n.js 780 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.createI18N = createI18N;
  5. var _ = require("..");
  6. var _string = require("../format/string");
  7. var _locale = _interopRequireDefault(require("../../locale"));
  8. function createI18N(name) {
  9. var prefix = (0, _string.camelize)(name) + '.';
  10. return function (path) {
  11. var messages = _locale.default.messages();
  12. var message = (0, _.get)(messages, prefix + path) || (0, _.get)(messages, path);
  13. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  14. args[_key - 1] = arguments[_key];
  15. }
  16. return (0, _.isFunction)(message) ? message.apply(void 0, args) : message;
  17. };
  18. }