index.js 1005 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = buildLocalizeFn;
  6. function buildLocalizeFn(args) {
  7. return function (dirtyIndex, dirtyOptions) {
  8. var options = dirtyOptions || {};
  9. var context = options.context ? String(options.context) : 'standalone';
  10. var valuesArray;
  11. if (context === 'formatting' && args.formattingValues) {
  12. var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
  13. var width = options.width ? String(options.width) : defaultWidth;
  14. valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
  15. } else {
  16. var _defaultWidth = args.defaultWidth;
  17. var _width = options.width ? String(options.width) : args.defaultWidth;
  18. valuesArray = args.values[_width] || args.values[_defaultWidth];
  19. }
  20. var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
  21. return valuesArray[index];
  22. };
  23. }
  24. module.exports = exports.default;