rb-document-form-constructor 0.8.89 → 0.8.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import Vue$1 from 'vue';
1
+ import Vue from 'vue';
2
2
 
3
3
  const UtFormConfig = {
4
4
  findField(fieldName, formConfig) {
@@ -465,2247 +465,6 @@ const UtFormConstructor = {
465
465
  }
466
466
  };
467
467
 
468
- /*!
469
- * vue-i18n v8.28.2
470
- * (c) 2022 kazuya kawaguchi
471
- * Released under the MIT License.
472
- */
473
- /* */
474
-
475
- /**
476
- * constants
477
- */
478
-
479
- var numberFormatKeys = [
480
- 'compactDisplay',
481
- 'currency',
482
- 'currencyDisplay',
483
- 'currencySign',
484
- 'localeMatcher',
485
- 'notation',
486
- 'numberingSystem',
487
- 'signDisplay',
488
- 'style',
489
- 'unit',
490
- 'unitDisplay',
491
- 'useGrouping',
492
- 'minimumIntegerDigits',
493
- 'minimumFractionDigits',
494
- 'maximumFractionDigits',
495
- 'minimumSignificantDigits',
496
- 'maximumSignificantDigits'
497
- ];
498
-
499
- var dateTimeFormatKeys = [
500
- 'dateStyle',
501
- 'timeStyle',
502
- 'calendar',
503
- 'localeMatcher',
504
- "hour12",
505
- "hourCycle",
506
- "timeZone",
507
- "formatMatcher",
508
- 'weekday',
509
- 'era',
510
- 'year',
511
- 'month',
512
- 'day',
513
- 'hour',
514
- 'minute',
515
- 'second',
516
- 'timeZoneName' ];
517
-
518
- /**
519
- * utilities
520
- */
521
-
522
- function warn (msg, err) {
523
- if (typeof console !== 'undefined') {
524
- console.warn('[vue-i18n] ' + msg);
525
- /* istanbul ignore if */
526
- if (err) {
527
- console.warn(err.stack);
528
- }
529
- }
530
- }
531
-
532
- function error (msg, err) {
533
- if (typeof console !== 'undefined') {
534
- console.error('[vue-i18n] ' + msg);
535
- /* istanbul ignore if */
536
- if (err) {
537
- console.error(err.stack);
538
- }
539
- }
540
- }
541
-
542
- var isArray = Array.isArray;
543
-
544
- function isObject (obj) {
545
- return obj !== null && typeof obj === 'object'
546
- }
547
-
548
- function isBoolean (val) {
549
- return typeof val === 'boolean'
550
- }
551
-
552
- function isString (val) {
553
- return typeof val === 'string'
554
- }
555
-
556
- var toString$1 = Object.prototype.toString;
557
- var OBJECT_STRING = '[object Object]';
558
- function isPlainObject (obj) {
559
- return toString$1.call(obj) === OBJECT_STRING
560
- }
561
-
562
- function isNull (val) {
563
- return val === null || val === undefined
564
- }
565
-
566
- function isFunction (val) {
567
- return typeof val === 'function'
568
- }
569
-
570
- function parseArgs () {
571
- var args = [], len = arguments.length;
572
- while ( len-- ) args[ len ] = arguments[ len ];
573
-
574
- var locale = null;
575
- var params = null;
576
- if (args.length === 1) {
577
- if (isObject(args[0]) || isArray(args[0])) {
578
- params = args[0];
579
- } else if (typeof args[0] === 'string') {
580
- locale = args[0];
581
- }
582
- } else if (args.length === 2) {
583
- if (typeof args[0] === 'string') {
584
- locale = args[0];
585
- }
586
- /* istanbul ignore if */
587
- if (isObject(args[1]) || isArray(args[1])) {
588
- params = args[1];
589
- }
590
- }
591
-
592
- return { locale: locale, params: params }
593
- }
594
-
595
- function looseClone (obj) {
596
- return JSON.parse(JSON.stringify(obj))
597
- }
598
-
599
- function remove (arr, item) {
600
- if (arr.delete(item)) {
601
- return arr
602
- }
603
- }
604
-
605
- function arrayFrom (arr) {
606
- var ret = [];
607
- arr.forEach(function (a) { return ret.push(a); });
608
- return ret
609
- }
610
-
611
- function includes (arr, item) {
612
- return !!~arr.indexOf(item)
613
- }
614
-
615
- var hasOwnProperty = Object.prototype.hasOwnProperty;
616
- function hasOwn (obj, key) {
617
- return hasOwnProperty.call(obj, key)
618
- }
619
-
620
- function merge (target) {
621
- var arguments$1 = arguments;
622
-
623
- var output = Object(target);
624
- for (var i = 1; i < arguments.length; i++) {
625
- var source = arguments$1[i];
626
- if (source !== undefined && source !== null) {
627
- var key = (void 0);
628
- for (key in source) {
629
- if (hasOwn(source, key)) {
630
- if (isObject(source[key])) {
631
- output[key] = merge(output[key], source[key]);
632
- } else {
633
- output[key] = source[key];
634
- }
635
- }
636
- }
637
- }
638
- }
639
- return output
640
- }
641
-
642
- function looseEqual (a, b) {
643
- if (a === b) { return true }
644
- var isObjectA = isObject(a);
645
- var isObjectB = isObject(b);
646
- if (isObjectA && isObjectB) {
647
- try {
648
- var isArrayA = isArray(a);
649
- var isArrayB = isArray(b);
650
- if (isArrayA && isArrayB) {
651
- return a.length === b.length && a.every(function (e, i) {
652
- return looseEqual(e, b[i])
653
- })
654
- } else if (!isArrayA && !isArrayB) {
655
- var keysA = Object.keys(a);
656
- var keysB = Object.keys(b);
657
- return keysA.length === keysB.length && keysA.every(function (key) {
658
- return looseEqual(a[key], b[key])
659
- })
660
- } else {
661
- /* istanbul ignore next */
662
- return false
663
- }
664
- } catch (e) {
665
- /* istanbul ignore next */
666
- return false
667
- }
668
- } else if (!isObjectA && !isObjectB) {
669
- return String(a) === String(b)
670
- } else {
671
- return false
672
- }
673
- }
674
-
675
- /**
676
- * Sanitizes html special characters from input strings. For mitigating risk of XSS attacks.
677
- * @param rawText The raw input from the user that should be escaped.
678
- */
679
- function escapeHtml(rawText) {
680
- return rawText
681
- .replace(/</g, '&lt;')
682
- .replace(/>/g, '&gt;')
683
- .replace(/"/g, '&quot;')
684
- .replace(/'/g, '&apos;')
685
- }
686
-
687
- /**
688
- * Escapes html tags and special symbols from all provided params which were returned from parseArgs().params.
689
- * This method performs an in-place operation on the params object.
690
- *
691
- * @param {any} params Parameters as provided from `parseArgs().params`.
692
- * May be either an array of strings or a string->any map.
693
- *
694
- * @returns The manipulated `params` object.
695
- */
696
- function escapeParams(params) {
697
- if(params != null) {
698
- Object.keys(params).forEach(function (key) {
699
- if(typeof(params[key]) == 'string') {
700
- params[key] = escapeHtml(params[key]);
701
- }
702
- });
703
- }
704
- return params
705
- }
706
-
707
- /* */
708
-
709
- function extend$1 (Vue) {
710
- if (!Vue.prototype.hasOwnProperty('$i18n')) {
711
- // $FlowFixMe
712
- Object.defineProperty(Vue.prototype, '$i18n', {
713
- get: function get () { return this._i18n }
714
- });
715
- }
716
-
717
- Vue.prototype.$t = function (key) {
718
- var values = [], len = arguments.length - 1;
719
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
720
-
721
- var i18n = this.$i18n;
722
- return i18n._t.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this ].concat( values ))
723
- };
724
-
725
- Vue.prototype.$tc = function (key, choice) {
726
- var values = [], len = arguments.length - 2;
727
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
728
-
729
- var i18n = this.$i18n;
730
- return i18n._tc.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this, choice ].concat( values ))
731
- };
732
-
733
- Vue.prototype.$te = function (key, locale) {
734
- var i18n = this.$i18n;
735
- return i18n._te(key, i18n.locale, i18n._getMessages(), locale)
736
- };
737
-
738
- Vue.prototype.$d = function (value) {
739
- var ref;
740
-
741
- var args = [], len = arguments.length - 1;
742
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
743
- return (ref = this.$i18n).d.apply(ref, [ value ].concat( args ))
744
- };
745
-
746
- Vue.prototype.$n = function (value) {
747
- var ref;
748
-
749
- var args = [], len = arguments.length - 1;
750
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
751
- return (ref = this.$i18n).n.apply(ref, [ value ].concat( args ))
752
- };
753
- }
754
-
755
- /* */
756
-
757
- /**
758
- * Mixin
759
- *
760
- * If `bridge` mode, empty mixin is returned,
761
- * else regulary mixin implementation is returned.
762
- */
763
- function defineMixin (bridge) {
764
- if ( bridge === void 0 ) bridge = false;
765
-
766
- function mounted () {
767
- if (this !== this.$root && this.$options.__INTLIFY_META__ && this.$el) {
768
- this.$el.setAttribute('data-intlify', this.$options.__INTLIFY_META__);
769
- }
770
- }
771
-
772
- return bridge
773
- ? { mounted: mounted } // delegate `vue-i18n-bridge` mixin implementation
774
- : { // regulary
775
- beforeCreate: function beforeCreate () {
776
- var options = this.$options;
777
- options.i18n = options.i18n || ((options.__i18nBridge || options.__i18n) ? {} : null);
778
-
779
- if (options.i18n) {
780
- if (options.i18n instanceof VueI18n) {
781
- // init locale messages via custom blocks
782
- if ((options.__i18nBridge || options.__i18n)) {
783
- try {
784
- var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};
785
- var _i18n = options.__i18nBridge || options.__i18n;
786
- _i18n.forEach(function (resource) {
787
- localeMessages = merge(localeMessages, JSON.parse(resource));
788
- });
789
- Object.keys(localeMessages).forEach(function (locale) {
790
- options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
791
- });
792
- } catch (e) {
793
- }
794
- }
795
- this._i18n = options.i18n;
796
- this._i18nWatcher = this._i18n.watchI18nData();
797
- } else if (isPlainObject(options.i18n)) {
798
- var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
799
- ? this.$root.$i18n
800
- : null;
801
- // component local i18n
802
- if (rootI18n) {
803
- options.i18n.root = this.$root;
804
- options.i18n.formatter = rootI18n.formatter;
805
- options.i18n.fallbackLocale = rootI18n.fallbackLocale;
806
- options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
807
- options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
808
- options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
809
- options.i18n.pluralizationRules = rootI18n.pluralizationRules;
810
- options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
811
- }
812
-
813
- // init locale messages via custom blocks
814
- if ((options.__i18nBridge || options.__i18n)) {
815
- try {
816
- var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};
817
- var _i18n$1 = options.__i18nBridge || options.__i18n;
818
- _i18n$1.forEach(function (resource) {
819
- localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
820
- });
821
- options.i18n.messages = localeMessages$1;
822
- } catch (e) {
823
- }
824
- }
825
-
826
- var ref = options.i18n;
827
- var sharedMessages = ref.sharedMessages;
828
- if (sharedMessages && isPlainObject(sharedMessages)) {
829
- options.i18n.messages = merge(options.i18n.messages, sharedMessages);
830
- }
831
-
832
- this._i18n = new VueI18n(options.i18n);
833
- this._i18nWatcher = this._i18n.watchI18nData();
834
-
835
- if (options.i18n.sync === undefined || !!options.i18n.sync) {
836
- this._localeWatcher = this.$i18n.watchLocale();
837
- }
838
-
839
- if (rootI18n) {
840
- rootI18n.onComponentInstanceCreated(this._i18n);
841
- }
842
- } else ;
843
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
844
- // root i18n
845
- this._i18n = this.$root.$i18n;
846
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
847
- // parent i18n
848
- this._i18n = options.parent.$i18n;
849
- }
850
- },
851
-
852
- beforeMount: function beforeMount () {
853
- var options = this.$options;
854
- options.i18n = options.i18n || ((options.__i18nBridge || options.__i18n) ? {} : null);
855
-
856
- if (options.i18n) {
857
- if (options.i18n instanceof VueI18n) {
858
- // init locale messages via custom blocks
859
- this._i18n.subscribeDataChanging(this);
860
- this._subscribing = true;
861
- } else if (isPlainObject(options.i18n)) {
862
- this._i18n.subscribeDataChanging(this);
863
- this._subscribing = true;
864
- } else ;
865
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
866
- this._i18n.subscribeDataChanging(this);
867
- this._subscribing = true;
868
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
869
- this._i18n.subscribeDataChanging(this);
870
- this._subscribing = true;
871
- }
872
- },
873
-
874
- mounted: mounted,
875
-
876
- beforeDestroy: function beforeDestroy () {
877
- if (!this._i18n) { return }
878
-
879
- var self = this;
880
- this.$nextTick(function () {
881
- if (self._subscribing) {
882
- self._i18n.unsubscribeDataChanging(self);
883
- delete self._subscribing;
884
- }
885
-
886
- if (self._i18nWatcher) {
887
- self._i18nWatcher();
888
- self._i18n.destroyVM();
889
- delete self._i18nWatcher;
890
- }
891
-
892
- if (self._localeWatcher) {
893
- self._localeWatcher();
894
- delete self._localeWatcher;
895
- }
896
- });
897
- }
898
- }
899
- }
900
-
901
- /* */
902
-
903
- var interpolationComponent = {
904
- name: 'i18n',
905
- functional: true,
906
- props: {
907
- tag: {
908
- type: [String, Boolean, Object],
909
- default: 'span'
910
- },
911
- path: {
912
- type: String,
913
- required: true
914
- },
915
- locale: {
916
- type: String
917
- },
918
- places: {
919
- type: [Array, Object]
920
- }
921
- },
922
- render: function render (h, ref) {
923
- var data = ref.data;
924
- var parent = ref.parent;
925
- var props = ref.props;
926
- var slots = ref.slots;
927
-
928
- var $i18n = parent.$i18n;
929
- if (!$i18n) {
930
- return
931
- }
932
-
933
- var path = props.path;
934
- var locale = props.locale;
935
- var places = props.places;
936
- var params = slots();
937
- var children = $i18n.i(
938
- path,
939
- locale,
940
- onlyHasDefaultPlace(params) || places
941
- ? useLegacyPlaces(params.default, places)
942
- : params
943
- );
944
-
945
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
946
- return tag ? h(tag, data, children) : children
947
- }
948
- };
949
-
950
- function onlyHasDefaultPlace (params) {
951
- var prop;
952
- for (prop in params) {
953
- if (prop !== 'default') { return false }
954
- }
955
- return Boolean(prop)
956
- }
957
-
958
- function useLegacyPlaces (children, places) {
959
- var params = places ? createParamsFromPlaces(places) : {};
960
-
961
- if (!children) { return params }
962
-
963
- // Filter empty text nodes
964
- children = children.filter(function (child) {
965
- return child.tag || child.text.trim() !== ''
966
- });
967
-
968
- var everyPlace = children.every(vnodeHasPlaceAttribute);
969
-
970
- return children.reduce(
971
- everyPlace ? assignChildPlace : assignChildIndex,
972
- params
973
- )
974
- }
975
-
976
- function createParamsFromPlaces (places) {
977
-
978
- return Array.isArray(places)
979
- ? places.reduce(assignChildIndex, {})
980
- : Object.assign({}, places)
981
- }
982
-
983
- function assignChildPlace (params, child) {
984
- if (child.data && child.data.attrs && child.data.attrs.place) {
985
- params[child.data.attrs.place] = child;
986
- }
987
- return params
988
- }
989
-
990
- function assignChildIndex (params, child, index) {
991
- params[index] = child;
992
- return params
993
- }
994
-
995
- function vnodeHasPlaceAttribute (vnode) {
996
- return Boolean(vnode.data && vnode.data.attrs && vnode.data.attrs.place)
997
- }
998
-
999
- /* */
1000
-
1001
- var numberComponent = {
1002
- name: 'i18n-n',
1003
- functional: true,
1004
- props: {
1005
- tag: {
1006
- type: [String, Boolean, Object],
1007
- default: 'span'
1008
- },
1009
- value: {
1010
- type: Number,
1011
- required: true
1012
- },
1013
- format: {
1014
- type: [String, Object]
1015
- },
1016
- locale: {
1017
- type: String
1018
- }
1019
- },
1020
- render: function render (h, ref) {
1021
- var props = ref.props;
1022
- var parent = ref.parent;
1023
- var data = ref.data;
1024
-
1025
- var i18n = parent.$i18n;
1026
-
1027
- if (!i18n) {
1028
- return null
1029
- }
1030
-
1031
- var key = null;
1032
- var options = null;
1033
-
1034
- if (isString(props.format)) {
1035
- key = props.format;
1036
- } else if (isObject(props.format)) {
1037
- if (props.format.key) {
1038
- key = props.format.key;
1039
- }
1040
-
1041
- // Filter out number format options only
1042
- options = Object.keys(props.format).reduce(function (acc, prop) {
1043
- var obj;
1044
-
1045
- if (includes(numberFormatKeys, prop)) {
1046
- return Object.assign({}, acc, ( obj = {}, obj[prop] = props.format[prop], obj ))
1047
- }
1048
- return acc
1049
- }, null);
1050
- }
1051
-
1052
- var locale = props.locale || i18n.locale;
1053
- var parts = i18n._ntp(props.value, locale, key, options);
1054
-
1055
- var values = parts.map(function (part, index) {
1056
- var obj;
1057
-
1058
- var slot = data.scopedSlots && data.scopedSlots[part.type];
1059
- return slot ? slot(( obj = {}, obj[part.type] = part.value, obj.index = index, obj.parts = parts, obj )) : part.value
1060
- });
1061
-
1062
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
1063
- return tag
1064
- ? h(tag, {
1065
- attrs: data.attrs,
1066
- 'class': data['class'],
1067
- staticClass: data.staticClass
1068
- }, values)
1069
- : values
1070
- }
1071
- };
1072
-
1073
- /* */
1074
-
1075
- function bind (el, binding, vnode) {
1076
- if (!assert(el, vnode)) { return }
1077
-
1078
- t(el, binding, vnode);
1079
- }
1080
-
1081
- function update (el, binding, vnode, oldVNode) {
1082
- if (!assert(el, vnode)) { return }
1083
-
1084
- var i18n = vnode.context.$i18n;
1085
- if (localeEqual(el, vnode) &&
1086
- (looseEqual(binding.value, binding.oldValue) &&
1087
- looseEqual(el._localeMessage, i18n.getLocaleMessage(i18n.locale)))) { return }
1088
-
1089
- t(el, binding, vnode);
1090
- }
1091
-
1092
- function unbind (el, binding, vnode, oldVNode) {
1093
- var vm = vnode.context;
1094
- if (!vm) {
1095
- warn('Vue instance does not exists in VNode context');
1096
- return
1097
- }
1098
-
1099
- var i18n = vnode.context.$i18n || {};
1100
- if (!binding.modifiers.preserve && !i18n.preserveDirectiveContent) {
1101
- el.textContent = '';
1102
- }
1103
- el._vt = undefined;
1104
- delete el['_vt'];
1105
- el._locale = undefined;
1106
- delete el['_locale'];
1107
- el._localeMessage = undefined;
1108
- delete el['_localeMessage'];
1109
- }
1110
-
1111
- function assert (el, vnode) {
1112
- var vm = vnode.context;
1113
- if (!vm) {
1114
- warn('Vue instance does not exists in VNode context');
1115
- return false
1116
- }
1117
-
1118
- if (!vm.$i18n) {
1119
- warn('VueI18n instance does not exists in Vue instance');
1120
- return false
1121
- }
1122
-
1123
- return true
1124
- }
1125
-
1126
- function localeEqual (el, vnode) {
1127
- var vm = vnode.context;
1128
- return el._locale === vm.$i18n.locale
1129
- }
1130
-
1131
- function t (el, binding, vnode) {
1132
- var ref$1, ref$2;
1133
-
1134
- var value = binding.value;
1135
-
1136
- var ref = parseValue(value);
1137
- var path = ref.path;
1138
- var locale = ref.locale;
1139
- var args = ref.args;
1140
- var choice = ref.choice;
1141
- if (!path && !locale && !args) {
1142
- warn('value type not supported');
1143
- return
1144
- }
1145
-
1146
- if (!path) {
1147
- warn('`path` is required in v-t directive');
1148
- return
1149
- }
1150
-
1151
- var vm = vnode.context;
1152
- if (choice != null) {
1153
- el._vt = el.textContent = (ref$1 = vm.$i18n).tc.apply(ref$1, [ path, choice ].concat( makeParams(locale, args) ));
1154
- } else {
1155
- el._vt = el.textContent = (ref$2 = vm.$i18n).t.apply(ref$2, [ path ].concat( makeParams(locale, args) ));
1156
- }
1157
- el._locale = vm.$i18n.locale;
1158
- el._localeMessage = vm.$i18n.getLocaleMessage(vm.$i18n.locale);
1159
- }
1160
-
1161
- function parseValue (value) {
1162
- var path;
1163
- var locale;
1164
- var args;
1165
- var choice;
1166
-
1167
- if (isString(value)) {
1168
- path = value;
1169
- } else if (isPlainObject(value)) {
1170
- path = value.path;
1171
- locale = value.locale;
1172
- args = value.args;
1173
- choice = value.choice;
1174
- }
1175
-
1176
- return { path: path, locale: locale, args: args, choice: choice }
1177
- }
1178
-
1179
- function makeParams (locale, args) {
1180
- var params = [];
1181
-
1182
- locale && params.push(locale);
1183
- if (args && (Array.isArray(args) || isPlainObject(args))) {
1184
- params.push(args);
1185
- }
1186
-
1187
- return params
1188
- }
1189
-
1190
- var Vue;
1191
-
1192
- function install$1 (_Vue, options) {
1193
- if ( options === void 0 ) options = { bridge: false };
1194
- install$1.installed = true;
1195
-
1196
- Vue = _Vue;
1197
-
1198
- (Vue.version && Number(Vue.version.split('.')[0])) || -1;
1199
-
1200
- extend$1(Vue);
1201
- Vue.mixin(defineMixin(options.bridge));
1202
- Vue.directive('t', { bind: bind, update: update, unbind: unbind });
1203
- Vue.component(interpolationComponent.name, interpolationComponent);
1204
- Vue.component(numberComponent.name, numberComponent);
1205
-
1206
- // use simple mergeStrategies to prevent i18n instance lose '__proto__'
1207
- var strats = Vue.config.optionMergeStrategies;
1208
- strats.i18n = function (parentVal, childVal) {
1209
- return childVal === undefined
1210
- ? parentVal
1211
- : childVal
1212
- };
1213
- }
1214
-
1215
- /* */
1216
-
1217
- var BaseFormatter = function BaseFormatter () {
1218
- this._caches = Object.create(null);
1219
- };
1220
-
1221
- BaseFormatter.prototype.interpolate = function interpolate (message, values) {
1222
- if (!values) {
1223
- return [message]
1224
- }
1225
- var tokens = this._caches[message];
1226
- if (!tokens) {
1227
- tokens = parse(message);
1228
- this._caches[message] = tokens;
1229
- }
1230
- return compile(tokens, values)
1231
- };
1232
-
1233
-
1234
-
1235
- var RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
1236
- var RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
1237
-
1238
- function parse (format) {
1239
- var tokens = [];
1240
- var position = 0;
1241
-
1242
- var text = '';
1243
- while (position < format.length) {
1244
- var char = format[position++];
1245
- if (char === '{') {
1246
- if (text) {
1247
- tokens.push({ type: 'text', value: text });
1248
- }
1249
-
1250
- text = '';
1251
- var sub = '';
1252
- char = format[position++];
1253
- while (char !== undefined && char !== '}') {
1254
- sub += char;
1255
- char = format[position++];
1256
- }
1257
- var isClosed = char === '}';
1258
-
1259
- var type = RE_TOKEN_LIST_VALUE.test(sub)
1260
- ? 'list'
1261
- : isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
1262
- ? 'named'
1263
- : 'unknown';
1264
- tokens.push({ value: sub, type: type });
1265
- } else if (char === '%') {
1266
- // when found rails i18n syntax, skip text capture
1267
- if (format[(position)] !== '{') {
1268
- text += char;
1269
- }
1270
- } else {
1271
- text += char;
1272
- }
1273
- }
1274
-
1275
- text && tokens.push({ type: 'text', value: text });
1276
-
1277
- return tokens
1278
- }
1279
-
1280
- function compile (tokens, values) {
1281
- var compiled = [];
1282
- var index = 0;
1283
-
1284
- var mode = Array.isArray(values)
1285
- ? 'list'
1286
- : isObject(values)
1287
- ? 'named'
1288
- : 'unknown';
1289
- if (mode === 'unknown') { return compiled }
1290
-
1291
- while (index < tokens.length) {
1292
- var token = tokens[index];
1293
- switch (token.type) {
1294
- case 'text':
1295
- compiled.push(token.value);
1296
- break
1297
- case 'list':
1298
- compiled.push(values[parseInt(token.value, 10)]);
1299
- break
1300
- case 'named':
1301
- if (mode === 'named') {
1302
- compiled.push((values)[token.value]);
1303
- }
1304
- break
1305
- }
1306
- index++;
1307
- }
1308
-
1309
- return compiled
1310
- }
1311
-
1312
- /* */
1313
-
1314
- /**
1315
- * Path parser
1316
- * - Inspired:
1317
- * Vue.js Path parser
1318
- */
1319
-
1320
- // actions
1321
- var APPEND = 0;
1322
- var PUSH = 1;
1323
- var INC_SUB_PATH_DEPTH = 2;
1324
- var PUSH_SUB_PATH = 3;
1325
-
1326
- // states
1327
- var BEFORE_PATH = 0;
1328
- var IN_PATH = 1;
1329
- var BEFORE_IDENT = 2;
1330
- var IN_IDENT = 3;
1331
- var IN_SUB_PATH = 4;
1332
- var IN_SINGLE_QUOTE = 5;
1333
- var IN_DOUBLE_QUOTE = 6;
1334
- var AFTER_PATH = 7;
1335
- var ERROR = 8;
1336
-
1337
- var pathStateMachine = [];
1338
-
1339
- pathStateMachine[BEFORE_PATH] = {
1340
- 'ws': [BEFORE_PATH],
1341
- 'ident': [IN_IDENT, APPEND],
1342
- '[': [IN_SUB_PATH],
1343
- 'eof': [AFTER_PATH]
1344
- };
1345
-
1346
- pathStateMachine[IN_PATH] = {
1347
- 'ws': [IN_PATH],
1348
- '.': [BEFORE_IDENT],
1349
- '[': [IN_SUB_PATH],
1350
- 'eof': [AFTER_PATH]
1351
- };
1352
-
1353
- pathStateMachine[BEFORE_IDENT] = {
1354
- 'ws': [BEFORE_IDENT],
1355
- 'ident': [IN_IDENT, APPEND],
1356
- '0': [IN_IDENT, APPEND],
1357
- 'number': [IN_IDENT, APPEND]
1358
- };
1359
-
1360
- pathStateMachine[IN_IDENT] = {
1361
- 'ident': [IN_IDENT, APPEND],
1362
- '0': [IN_IDENT, APPEND],
1363
- 'number': [IN_IDENT, APPEND],
1364
- 'ws': [IN_PATH, PUSH],
1365
- '.': [BEFORE_IDENT, PUSH],
1366
- '[': [IN_SUB_PATH, PUSH],
1367
- 'eof': [AFTER_PATH, PUSH]
1368
- };
1369
-
1370
- pathStateMachine[IN_SUB_PATH] = {
1371
- "'": [IN_SINGLE_QUOTE, APPEND],
1372
- '"': [IN_DOUBLE_QUOTE, APPEND],
1373
- '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],
1374
- ']': [IN_PATH, PUSH_SUB_PATH],
1375
- 'eof': ERROR,
1376
- 'else': [IN_SUB_PATH, APPEND]
1377
- };
1378
-
1379
- pathStateMachine[IN_SINGLE_QUOTE] = {
1380
- "'": [IN_SUB_PATH, APPEND],
1381
- 'eof': ERROR,
1382
- 'else': [IN_SINGLE_QUOTE, APPEND]
1383
- };
1384
-
1385
- pathStateMachine[IN_DOUBLE_QUOTE] = {
1386
- '"': [IN_SUB_PATH, APPEND],
1387
- 'eof': ERROR,
1388
- 'else': [IN_DOUBLE_QUOTE, APPEND]
1389
- };
1390
-
1391
- /**
1392
- * Check if an expression is a literal value.
1393
- */
1394
-
1395
- var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
1396
- function isLiteral (exp) {
1397
- return literalValueRE.test(exp)
1398
- }
1399
-
1400
- /**
1401
- * Strip quotes from a string
1402
- */
1403
-
1404
- function stripQuotes (str) {
1405
- var a = str.charCodeAt(0);
1406
- var b = str.charCodeAt(str.length - 1);
1407
- return a === b && (a === 0x22 || a === 0x27)
1408
- ? str.slice(1, -1)
1409
- : str
1410
- }
1411
-
1412
- /**
1413
- * Determine the type of a character in a keypath.
1414
- */
1415
-
1416
- function getPathCharType (ch) {
1417
- if (ch === undefined || ch === null) { return 'eof' }
1418
-
1419
- var code = ch.charCodeAt(0);
1420
-
1421
- switch (code) {
1422
- case 0x5B: // [
1423
- case 0x5D: // ]
1424
- case 0x2E: // .
1425
- case 0x22: // "
1426
- case 0x27: // '
1427
- return ch
1428
-
1429
- case 0x5F: // _
1430
- case 0x24: // $
1431
- case 0x2D: // -
1432
- return 'ident'
1433
-
1434
- case 0x09: // Tab
1435
- case 0x0A: // Newline
1436
- case 0x0D: // Return
1437
- case 0xA0: // No-break space
1438
- case 0xFEFF: // Byte Order Mark
1439
- case 0x2028: // Line Separator
1440
- case 0x2029: // Paragraph Separator
1441
- return 'ws'
1442
- }
1443
-
1444
- return 'ident'
1445
- }
1446
-
1447
- /**
1448
- * Format a subPath, return its plain form if it is
1449
- * a literal string or number. Otherwise prepend the
1450
- * dynamic indicator (*).
1451
- */
1452
-
1453
- function formatSubPath (path) {
1454
- var trimmed = path.trim();
1455
- // invalid leading 0
1456
- if (path.charAt(0) === '0' && isNaN(path)) { return false }
1457
-
1458
- return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed
1459
- }
1460
-
1461
- /**
1462
- * Parse a string path into an array of segments
1463
- */
1464
-
1465
- function parse$1 (path) {
1466
- var keys = [];
1467
- var index = -1;
1468
- var mode = BEFORE_PATH;
1469
- var subPathDepth = 0;
1470
- var c;
1471
- var key;
1472
- var newChar;
1473
- var type;
1474
- var transition;
1475
- var action;
1476
- var typeMap;
1477
- var actions = [];
1478
-
1479
- actions[PUSH] = function () {
1480
- if (key !== undefined) {
1481
- keys.push(key);
1482
- key = undefined;
1483
- }
1484
- };
1485
-
1486
- actions[APPEND] = function () {
1487
- if (key === undefined) {
1488
- key = newChar;
1489
- } else {
1490
- key += newChar;
1491
- }
1492
- };
1493
-
1494
- actions[INC_SUB_PATH_DEPTH] = function () {
1495
- actions[APPEND]();
1496
- subPathDepth++;
1497
- };
1498
-
1499
- actions[PUSH_SUB_PATH] = function () {
1500
- if (subPathDepth > 0) {
1501
- subPathDepth--;
1502
- mode = IN_SUB_PATH;
1503
- actions[APPEND]();
1504
- } else {
1505
- subPathDepth = 0;
1506
- if (key === undefined) { return false }
1507
- key = formatSubPath(key);
1508
- if (key === false) {
1509
- return false
1510
- } else {
1511
- actions[PUSH]();
1512
- }
1513
- }
1514
- };
1515
-
1516
- function maybeUnescapeQuote () {
1517
- var nextChar = path[index + 1];
1518
- if ((mode === IN_SINGLE_QUOTE && nextChar === "'") ||
1519
- (mode === IN_DOUBLE_QUOTE && nextChar === '"')) {
1520
- index++;
1521
- newChar = '\\' + nextChar;
1522
- actions[APPEND]();
1523
- return true
1524
- }
1525
- }
1526
-
1527
- while (mode !== null) {
1528
- index++;
1529
- c = path[index];
1530
-
1531
- if (c === '\\' && maybeUnescapeQuote()) {
1532
- continue
1533
- }
1534
-
1535
- type = getPathCharType(c);
1536
- typeMap = pathStateMachine[mode];
1537
- transition = typeMap[type] || typeMap['else'] || ERROR;
1538
-
1539
- if (transition === ERROR) {
1540
- return // parse error
1541
- }
1542
-
1543
- mode = transition[0];
1544
- action = actions[transition[1]];
1545
- if (action) {
1546
- newChar = transition[2];
1547
- newChar = newChar === undefined
1548
- ? c
1549
- : newChar;
1550
- if (action() === false) {
1551
- return
1552
- }
1553
- }
1554
-
1555
- if (mode === AFTER_PATH) {
1556
- return keys
1557
- }
1558
- }
1559
- }
1560
-
1561
-
1562
-
1563
-
1564
-
1565
- var I18nPath = function I18nPath () {
1566
- this._cache = Object.create(null);
1567
- };
1568
-
1569
- /**
1570
- * External parse that check for a cache hit first
1571
- */
1572
- I18nPath.prototype.parsePath = function parsePath (path) {
1573
- var hit = this._cache[path];
1574
- if (!hit) {
1575
- hit = parse$1(path);
1576
- if (hit) {
1577
- this._cache[path] = hit;
1578
- }
1579
- }
1580
- return hit || []
1581
- };
1582
-
1583
- /**
1584
- * Get path value from path string
1585
- */
1586
- I18nPath.prototype.getPathValue = function getPathValue (obj, path) {
1587
- if (!isObject(obj)) { return null }
1588
-
1589
- var paths = this.parsePath(path);
1590
- if (paths.length === 0) {
1591
- return null
1592
- } else {
1593
- var length = paths.length;
1594
- var last = obj;
1595
- var i = 0;
1596
- while (i < length) {
1597
- var value = last[paths[i]];
1598
- if (value === undefined || value === null) {
1599
- return null
1600
- }
1601
- last = value;
1602
- i++;
1603
- }
1604
-
1605
- return last
1606
- }
1607
- };
1608
-
1609
- /* */
1610
-
1611
-
1612
-
1613
- var htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/;
1614
- var linkKeyMatcher = /(?:@(?:\.[a-zA-Z]+)?:(?:[\w\-_|./]+|\([\w\-_:|./]+\)))/g;
1615
- var linkKeyPrefixMatcher = /^@(?:\.([a-zA-Z]+))?:/;
1616
- var bracketsMatcher = /[()]/g;
1617
- var defaultModifiers = {
1618
- 'upper': function (str) { return str.toLocaleUpperCase(); },
1619
- 'lower': function (str) { return str.toLocaleLowerCase(); },
1620
- 'capitalize': function (str) { return ("" + (str.charAt(0).toLocaleUpperCase()) + (str.substr(1))); }
1621
- };
1622
-
1623
- var defaultFormatter = new BaseFormatter();
1624
-
1625
- var VueI18n = function VueI18n (options) {
1626
- var this$1$1 = this;
1627
- if ( options === void 0 ) options = {};
1628
-
1629
- // Auto install if it is not done yet and `window` has `Vue`.
1630
- // To allow users to avoid auto-installation in some cases,
1631
- // this code should be placed here. See #290
1632
- /* istanbul ignore if */
1633
- if (!Vue && typeof window !== 'undefined' && window.Vue) {
1634
- install$1(window.Vue);
1635
- }
1636
-
1637
- var locale = options.locale || 'en-US';
1638
- var fallbackLocale = options.fallbackLocale === false
1639
- ? false
1640
- : options.fallbackLocale || 'en-US';
1641
- var messages = options.messages || {};
1642
- var dateTimeFormats = options.dateTimeFormats || options.datetimeFormats || {};
1643
- var numberFormats = options.numberFormats || {};
1644
-
1645
- this._vm = null;
1646
- this._formatter = options.formatter || defaultFormatter;
1647
- this._modifiers = options.modifiers || {};
1648
- this._missing = options.missing || null;
1649
- this._root = options.root || null;
1650
- this._sync = options.sync === undefined ? true : !!options.sync;
1651
- this._fallbackRoot = options.fallbackRoot === undefined
1652
- ? true
1653
- : !!options.fallbackRoot;
1654
- this._fallbackRootWithEmptyString = options.fallbackRootWithEmptyString === undefined
1655
- ? true
1656
- : !!options.fallbackRootWithEmptyString;
1657
- this._formatFallbackMessages = options.formatFallbackMessages === undefined
1658
- ? false
1659
- : !!options.formatFallbackMessages;
1660
- this._silentTranslationWarn = options.silentTranslationWarn === undefined
1661
- ? false
1662
- : options.silentTranslationWarn;
1663
- this._silentFallbackWarn = options.silentFallbackWarn === undefined
1664
- ? false
1665
- : !!options.silentFallbackWarn;
1666
- this._dateTimeFormatters = {};
1667
- this._numberFormatters = {};
1668
- this._path = new I18nPath();
1669
- this._dataListeners = new Set();
1670
- this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
1671
- this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
1672
- ? false
1673
- : !!options.preserveDirectiveContent;
1674
- this.pluralizationRules = options.pluralizationRules || {};
1675
- this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';
1676
- this._postTranslation = options.postTranslation || null;
1677
- this._escapeParameterHtml = options.escapeParameterHtml || false;
1678
-
1679
- if ('__VUE_I18N_BRIDGE__' in options) {
1680
- this.__VUE_I18N_BRIDGE__ = options.__VUE_I18N_BRIDGE__;
1681
- }
1682
-
1683
- /**
1684
- * @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
1685
- * @param choicesLength {number} an overall amount of available choices
1686
- * @returns a final choice index
1687
- */
1688
- this.getChoiceIndex = function (choice, choicesLength) {
1689
- var thisPrototype = Object.getPrototypeOf(this$1$1);
1690
- if (thisPrototype && thisPrototype.getChoiceIndex) {
1691
- var prototypeGetChoiceIndex = (thisPrototype.getChoiceIndex);
1692
- return (prototypeGetChoiceIndex).call(this$1$1, choice, choicesLength)
1693
- }
1694
-
1695
- // Default (old) getChoiceIndex implementation - english-compatible
1696
- var defaultImpl = function (_choice, _choicesLength) {
1697
- _choice = Math.abs(_choice);
1698
-
1699
- if (_choicesLength === 2) {
1700
- return _choice
1701
- ? _choice > 1
1702
- ? 1
1703
- : 0
1704
- : 1
1705
- }
1706
-
1707
- return _choice ? Math.min(_choice, 2) : 0
1708
- };
1709
-
1710
- if (this$1$1.locale in this$1$1.pluralizationRules) {
1711
- return this$1$1.pluralizationRules[this$1$1.locale].apply(this$1$1, [choice, choicesLength])
1712
- } else {
1713
- return defaultImpl(choice, choicesLength)
1714
- }
1715
- };
1716
-
1717
-
1718
- this._exist = function (message, key) {
1719
- if (!message || !key) { return false }
1720
- if (!isNull(this$1$1._path.getPathValue(message, key))) { return true }
1721
- // fallback for flat key
1722
- if (message[key]) { return true }
1723
- return false
1724
- };
1725
-
1726
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1727
- Object.keys(messages).forEach(function (locale) {
1728
- this$1$1._checkLocaleMessage(locale, this$1$1._warnHtmlInMessage, messages[locale]);
1729
- });
1730
- }
1731
-
1732
- this._initVM({
1733
- locale: locale,
1734
- fallbackLocale: fallbackLocale,
1735
- messages: messages,
1736
- dateTimeFormats: dateTimeFormats,
1737
- numberFormats: numberFormats
1738
- });
1739
- };
1740
-
1741
- var prototypeAccessors = { vm: { configurable: true },messages: { configurable: true },dateTimeFormats: { configurable: true },numberFormats: { configurable: true },availableLocales: { configurable: true },locale: { configurable: true },fallbackLocale: { configurable: true },formatFallbackMessages: { configurable: true },missing: { configurable: true },formatter: { configurable: true },silentTranslationWarn: { configurable: true },silentFallbackWarn: { configurable: true },preserveDirectiveContent: { configurable: true },warnHtmlInMessage: { configurable: true },postTranslation: { configurable: true },sync: { configurable: true } };
1742
-
1743
- VueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage (locale, level, message) {
1744
- var paths = [];
1745
-
1746
- var fn = function (level, locale, message, paths) {
1747
- if (isPlainObject(message)) {
1748
- Object.keys(message).forEach(function (key) {
1749
- var val = message[key];
1750
- if (isPlainObject(val)) {
1751
- paths.push(key);
1752
- paths.push('.');
1753
- fn(level, locale, val, paths);
1754
- paths.pop();
1755
- paths.pop();
1756
- } else {
1757
- paths.push(key);
1758
- fn(level, locale, val, paths);
1759
- paths.pop();
1760
- }
1761
- });
1762
- } else if (isArray(message)) {
1763
- message.forEach(function (item, index) {
1764
- if (isPlainObject(item)) {
1765
- paths.push(("[" + index + "]"));
1766
- paths.push('.');
1767
- fn(level, locale, item, paths);
1768
- paths.pop();
1769
- paths.pop();
1770
- } else {
1771
- paths.push(("[" + index + "]"));
1772
- fn(level, locale, item, paths);
1773
- paths.pop();
1774
- }
1775
- });
1776
- } else if (isString(message)) {
1777
- var ret = htmlTagMatcher.test(message);
1778
- if (ret) {
1779
- var msg = "Detected HTML in message '" + message + "' of keypath '" + (paths.join('')) + "' at '" + locale + "'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp";
1780
- if (level === 'warn') {
1781
- warn(msg);
1782
- } else if (level === 'error') {
1783
- error(msg);
1784
- }
1785
- }
1786
- }
1787
- };
1788
-
1789
- fn(level, locale, message, paths);
1790
- };
1791
-
1792
- VueI18n.prototype._initVM = function _initVM (data) {
1793
- var silent = Vue.config.silent;
1794
- Vue.config.silent = true;
1795
- this._vm = new Vue({ data: data, __VUE18N__INSTANCE__: true });
1796
- Vue.config.silent = silent;
1797
- };
1798
-
1799
- VueI18n.prototype.destroyVM = function destroyVM () {
1800
- this._vm.$destroy();
1801
- };
1802
-
1803
- VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
1804
- this._dataListeners.add(vm);
1805
- };
1806
-
1807
- VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
1808
- remove(this._dataListeners, vm);
1809
- };
1810
-
1811
- VueI18n.prototype.watchI18nData = function watchI18nData () {
1812
- var this$1$1 = this;
1813
- return this._vm.$watch('$data', function () {
1814
- var listeners = arrayFrom(this$1$1._dataListeners);
1815
- var i = listeners.length;
1816
- while(i--) {
1817
- Vue.nextTick(function () {
1818
- listeners[i] && listeners[i].$forceUpdate();
1819
- });
1820
- }
1821
- }, { deep: true })
1822
- };
1823
-
1824
- VueI18n.prototype.watchLocale = function watchLocale (composer) {
1825
- if (!composer) {
1826
- /* istanbul ignore if */
1827
- if (!this._sync || !this._root) { return null }
1828
- var target = this._vm;
1829
- return this._root.$i18n.vm.$watch('locale', function (val) {
1830
- target.$set(target, 'locale', val);
1831
- target.$forceUpdate();
1832
- }, { immediate: true })
1833
- } else {
1834
- // deal with vue-i18n-bridge
1835
- if (!this.__VUE_I18N_BRIDGE__) { return null }
1836
- var self = this;
1837
- var target$1 = this._vm;
1838
- return this.vm.$watch('locale', function (val) {
1839
- target$1.$set(target$1, 'locale', val);
1840
- if (self.__VUE_I18N_BRIDGE__ && composer) {
1841
- composer.locale.value = val;
1842
- }
1843
- target$1.$forceUpdate();
1844
- }, { immediate: true })
1845
- }
1846
- };
1847
-
1848
- VueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated (newI18n) {
1849
- if (this._componentInstanceCreatedListener) {
1850
- this._componentInstanceCreatedListener(newI18n, this);
1851
- }
1852
- };
1853
-
1854
- prototypeAccessors.vm.get = function () { return this._vm };
1855
-
1856
- prototypeAccessors.messages.get = function () { return looseClone(this._getMessages()) };
1857
- prototypeAccessors.dateTimeFormats.get = function () { return looseClone(this._getDateTimeFormats()) };
1858
- prototypeAccessors.numberFormats.get = function () { return looseClone(this._getNumberFormats()) };
1859
- prototypeAccessors.availableLocales.get = function () { return Object.keys(this.messages).sort() };
1860
-
1861
- prototypeAccessors.locale.get = function () { return this._vm.locale };
1862
- prototypeAccessors.locale.set = function (locale) {
1863
- this._vm.$set(this._vm, 'locale', locale);
1864
- };
1865
-
1866
- prototypeAccessors.fallbackLocale.get = function () { return this._vm.fallbackLocale };
1867
- prototypeAccessors.fallbackLocale.set = function (locale) {
1868
- this._localeChainCache = {};
1869
- this._vm.$set(this._vm, 'fallbackLocale', locale);
1870
- };
1871
-
1872
- prototypeAccessors.formatFallbackMessages.get = function () { return this._formatFallbackMessages };
1873
- prototypeAccessors.formatFallbackMessages.set = function (fallback) { this._formatFallbackMessages = fallback; };
1874
-
1875
- prototypeAccessors.missing.get = function () { return this._missing };
1876
- prototypeAccessors.missing.set = function (handler) { this._missing = handler; };
1877
-
1878
- prototypeAccessors.formatter.get = function () { return this._formatter };
1879
- prototypeAccessors.formatter.set = function (formatter) { this._formatter = formatter; };
1880
-
1881
- prototypeAccessors.silentTranslationWarn.get = function () { return this._silentTranslationWarn };
1882
- prototypeAccessors.silentTranslationWarn.set = function (silent) { this._silentTranslationWarn = silent; };
1883
-
1884
- prototypeAccessors.silentFallbackWarn.get = function () { return this._silentFallbackWarn };
1885
- prototypeAccessors.silentFallbackWarn.set = function (silent) { this._silentFallbackWarn = silent; };
1886
-
1887
- prototypeAccessors.preserveDirectiveContent.get = function () { return this._preserveDirectiveContent };
1888
- prototypeAccessors.preserveDirectiveContent.set = function (preserve) { this._preserveDirectiveContent = preserve; };
1889
-
1890
- prototypeAccessors.warnHtmlInMessage.get = function () { return this._warnHtmlInMessage };
1891
- prototypeAccessors.warnHtmlInMessage.set = function (level) {
1892
- var this$1$1 = this;
1893
-
1894
- var orgLevel = this._warnHtmlInMessage;
1895
- this._warnHtmlInMessage = level;
1896
- if (orgLevel !== level && (level === 'warn' || level === 'error')) {
1897
- var messages = this._getMessages();
1898
- Object.keys(messages).forEach(function (locale) {
1899
- this$1$1._checkLocaleMessage(locale, this$1$1._warnHtmlInMessage, messages[locale]);
1900
- });
1901
- }
1902
- };
1903
-
1904
- prototypeAccessors.postTranslation.get = function () { return this._postTranslation };
1905
- prototypeAccessors.postTranslation.set = function (handler) { this._postTranslation = handler; };
1906
-
1907
- prototypeAccessors.sync.get = function () { return this._sync };
1908
- prototypeAccessors.sync.set = function (val) { this._sync = val; };
1909
-
1910
- VueI18n.prototype._getMessages = function _getMessages () { return this._vm.messages };
1911
- VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
1912
- VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };
1913
-
1914
- VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
1915
- if (!isNull(result)) { return result }
1916
- if (this._missing) {
1917
- var missingRet = this._missing.apply(null, [locale, key, vm, values]);
1918
- if (isString(missingRet)) {
1919
- return missingRet
1920
- }
1921
- }
1922
-
1923
- if (this._formatFallbackMessages) {
1924
- var parsedArgs = parseArgs.apply(void 0, values);
1925
- return this._render(key, interpolateMode, parsedArgs.params, key)
1926
- } else {
1927
- return key
1928
- }
1929
- };
1930
-
1931
- VueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {
1932
- return (this._fallbackRootWithEmptyString? !val : isNull(val)) && !isNull(this._root) && this._fallbackRoot
1933
- };
1934
-
1935
- VueI18n.prototype._isSilentFallbackWarn = function _isSilentFallbackWarn (key) {
1936
- return this._silentFallbackWarn instanceof RegExp
1937
- ? this._silentFallbackWarn.test(key)
1938
- : this._silentFallbackWarn
1939
- };
1940
-
1941
- VueI18n.prototype._isSilentFallback = function _isSilentFallback (locale, key) {
1942
- return this._isSilentFallbackWarn(key) && (this._isFallbackRoot() || locale !== this.fallbackLocale)
1943
- };
1944
-
1945
- VueI18n.prototype._isSilentTranslationWarn = function _isSilentTranslationWarn (key) {
1946
- return this._silentTranslationWarn instanceof RegExp
1947
- ? this._silentTranslationWarn.test(key)
1948
- : this._silentTranslationWarn
1949
- };
1950
-
1951
- VueI18n.prototype._interpolate = function _interpolate (
1952
- locale,
1953
- message,
1954
- key,
1955
- host,
1956
- interpolateMode,
1957
- values,
1958
- visitedLinkStack
1959
- ) {
1960
- if (!message) { return null }
1961
-
1962
- var pathRet = this._path.getPathValue(message, key);
1963
- if (isArray(pathRet) || isPlainObject(pathRet)) { return pathRet }
1964
-
1965
- var ret;
1966
- if (isNull(pathRet)) {
1967
- /* istanbul ignore else */
1968
- if (isPlainObject(message)) {
1969
- ret = message[key];
1970
- if (!(isString(ret) || isFunction(ret))) {
1971
- return null
1972
- }
1973
- } else {
1974
- return null
1975
- }
1976
- } else {
1977
- /* istanbul ignore else */
1978
- if (isString(pathRet) || isFunction(pathRet)) {
1979
- ret = pathRet;
1980
- } else {
1981
- return null
1982
- }
1983
- }
1984
-
1985
- // Check for the existence of links within the translated string
1986
- if (isString(ret) && (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0)) {
1987
- ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack);
1988
- }
1989
-
1990
- return this._render(ret, interpolateMode, values, key)
1991
- };
1992
-
1993
- VueI18n.prototype._link = function _link (
1994
- locale,
1995
- message,
1996
- str,
1997
- host,
1998
- interpolateMode,
1999
- values,
2000
- visitedLinkStack
2001
- ) {
2002
- var ret = str;
2003
-
2004
- // Match all the links within the local
2005
- // We are going to replace each of
2006
- // them with its translation
2007
- var matches = ret.match(linkKeyMatcher);
2008
-
2009
- // eslint-disable-next-line no-autofix/prefer-const
2010
- for (var idx in matches) {
2011
- // ie compatible: filter custom array
2012
- // prototype method
2013
- if (!matches.hasOwnProperty(idx)) {
2014
- continue
2015
- }
2016
- var link = matches[idx];
2017
- var linkKeyPrefixMatches = link.match(linkKeyPrefixMatcher);
2018
- var linkPrefix = linkKeyPrefixMatches[0];
2019
- var formatterName = linkKeyPrefixMatches[1];
2020
-
2021
- // Remove the leading @:, @.case: and the brackets
2022
- var linkPlaceholder = link.replace(linkPrefix, '').replace(bracketsMatcher, '');
2023
-
2024
- if (includes(visitedLinkStack, linkPlaceholder)) {
2025
- return ret
2026
- }
2027
- visitedLinkStack.push(linkPlaceholder);
2028
-
2029
- // Translate the link
2030
- var translated = this._interpolate(
2031
- locale, message, linkPlaceholder, host,
2032
- interpolateMode === 'raw' ? 'string' : interpolateMode,
2033
- interpolateMode === 'raw' ? undefined : values,
2034
- visitedLinkStack
2035
- );
2036
-
2037
- if (this._isFallbackRoot(translated)) {
2038
- /* istanbul ignore if */
2039
- if (!this._root) { throw Error('unexpected error') }
2040
- var root = this._root.$i18n;
2041
- translated = root._translate(
2042
- root._getMessages(), root.locale, root.fallbackLocale,
2043
- linkPlaceholder, host, interpolateMode, values
2044
- );
2045
- }
2046
- translated = this._warnDefault(
2047
- locale, linkPlaceholder, translated, host,
2048
- isArray(values) ? values : [values],
2049
- interpolateMode
2050
- );
2051
-
2052
- if (this._modifiers.hasOwnProperty(formatterName)) {
2053
- translated = this._modifiers[formatterName](translated);
2054
- } else if (defaultModifiers.hasOwnProperty(formatterName)) {
2055
- translated = defaultModifiers[formatterName](translated);
2056
- }
2057
-
2058
- visitedLinkStack.pop();
2059
-
2060
- // Replace the link with the translated
2061
- ret = !translated ? ret : ret.replace(link, translated);
2062
- }
2063
-
2064
- return ret
2065
- };
2066
-
2067
- VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
2068
- var this$1$1 = this;
2069
-
2070
- var _list = isArray(values) ? values : [];
2071
- var _named = isObject(values) ? values : {};
2072
- var list = function (index) { return _list[index]; };
2073
- var named = function (key) { return _named[key]; };
2074
- var messages = this._getMessages();
2075
- var locale = this.locale;
2076
-
2077
- return {
2078
- list: list,
2079
- named: named,
2080
- values: values,
2081
- formatter: formatter,
2082
- path: path,
2083
- messages: messages,
2084
- locale: locale,
2085
- linked: function (linkedKey) { return this$1$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
2086
- }
2087
- };
2088
-
2089
- VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
2090
- if (isFunction(message)) {
2091
- return message(
2092
- this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
2093
- )
2094
- }
2095
-
2096
- var ret = this._formatter.interpolate(message, values, path);
2097
-
2098
- // If the custom formatter refuses to work - apply the default one
2099
- if (!ret) {
2100
- ret = defaultFormatter.interpolate(message, values, path);
2101
- }
2102
-
2103
- // if interpolateMode is **not** 'string' ('row'),
2104
- // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter
2105
- return interpolateMode === 'string' && !isString(ret) ? ret.join('') : ret
2106
- };
2107
-
2108
- VueI18n.prototype._appendItemToChain = function _appendItemToChain (chain, item, blocks) {
2109
- var follow = false;
2110
- if (!includes(chain, item)) {
2111
- follow = true;
2112
- if (item) {
2113
- follow = item[item.length - 1] !== '!';
2114
- item = item.replace(/!/g, '');
2115
- chain.push(item);
2116
- if (blocks && blocks[item]) {
2117
- follow = blocks[item];
2118
- }
2119
- }
2120
- }
2121
- return follow
2122
- };
2123
-
2124
- VueI18n.prototype._appendLocaleToChain = function _appendLocaleToChain (chain, locale, blocks) {
2125
- var follow;
2126
- var tokens = locale.split('-');
2127
- do {
2128
- var item = tokens.join('-');
2129
- follow = this._appendItemToChain(chain, item, blocks);
2130
- tokens.splice(-1, 1);
2131
- } while (tokens.length && (follow === true))
2132
- return follow
2133
- };
2134
-
2135
- VueI18n.prototype._appendBlockToChain = function _appendBlockToChain (chain, block, blocks) {
2136
- var follow = true;
2137
- for (var i = 0; (i < block.length) && (isBoolean(follow)); i++) {
2138
- var locale = block[i];
2139
- if (isString(locale)) {
2140
- follow = this._appendLocaleToChain(chain, locale, blocks);
2141
- }
2142
- }
2143
- return follow
2144
- };
2145
-
2146
- VueI18n.prototype._getLocaleChain = function _getLocaleChain (start, fallbackLocale) {
2147
- if (start === '') { return [] }
2148
-
2149
- if (!this._localeChainCache) {
2150
- this._localeChainCache = {};
2151
- }
2152
-
2153
- var chain = this._localeChainCache[start];
2154
- if (!chain) {
2155
- if (!fallbackLocale) {
2156
- fallbackLocale = this.fallbackLocale;
2157
- }
2158
- chain = [];
2159
-
2160
- // first block defined by start
2161
- var block = [start];
2162
-
2163
- // while any intervening block found
2164
- while (isArray(block)) {
2165
- block = this._appendBlockToChain(
2166
- chain,
2167
- block,
2168
- fallbackLocale
2169
- );
2170
- }
2171
-
2172
- // last block defined by default
2173
- var defaults;
2174
- if (isArray(fallbackLocale)) {
2175
- defaults = fallbackLocale;
2176
- } else if (isObject(fallbackLocale)) {
2177
- /* $FlowFixMe */
2178
- if (fallbackLocale['default']) {
2179
- defaults = fallbackLocale['default'];
2180
- } else {
2181
- defaults = null;
2182
- }
2183
- } else {
2184
- defaults = fallbackLocale;
2185
- }
2186
-
2187
- // convert defaults to array
2188
- if (isString(defaults)) {
2189
- block = [defaults];
2190
- } else {
2191
- block = defaults;
2192
- }
2193
- if (block) {
2194
- this._appendBlockToChain(
2195
- chain,
2196
- block,
2197
- null
2198
- );
2199
- }
2200
- this._localeChainCache[start] = chain;
2201
- }
2202
- return chain
2203
- };
2204
-
2205
- VueI18n.prototype._translate = function _translate (
2206
- messages,
2207
- locale,
2208
- fallback,
2209
- key,
2210
- host,
2211
- interpolateMode,
2212
- args
2213
- ) {
2214
- var chain = this._getLocaleChain(locale, fallback);
2215
- var res;
2216
- for (var i = 0; i < chain.length; i++) {
2217
- var step = chain[i];
2218
- res =
2219
- this._interpolate(step, messages[step], key, host, interpolateMode, args, [key]);
2220
- if (!isNull(res)) {
2221
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
2222
- warn(("Fall back to translate the keypath '" + key + "' with '" + step + "' locale."));
2223
- }
2224
- return res
2225
- }
2226
- }
2227
- return null
2228
- };
2229
-
2230
- VueI18n.prototype._t = function _t (key, _locale, messages, host) {
2231
- var ref;
2232
-
2233
- var values = [], len = arguments.length - 4;
2234
- while ( len-- > 0 ) values[ len ] = arguments[ len + 4 ];
2235
- if (!key) { return '' }
2236
-
2237
- var parsedArgs = parseArgs.apply(void 0, values);
2238
- if(this._escapeParameterHtml) {
2239
- parsedArgs.params = escapeParams(parsedArgs.params);
2240
- }
2241
-
2242
- var locale = parsedArgs.locale || _locale;
2243
-
2244
- var ret = this._translate(
2245
- messages, locale, this.fallbackLocale, key,
2246
- host, 'string', parsedArgs.params
2247
- );
2248
- if (this._isFallbackRoot(ret)) {
2249
- /* istanbul ignore if */
2250
- if (!this._root) { throw Error('unexpected error') }
2251
- return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
2252
- } else {
2253
- ret = this._warnDefault(locale, key, ret, host, values, 'string');
2254
- if (this._postTranslation && ret !== null && ret !== undefined) {
2255
- ret = this._postTranslation(ret, key);
2256
- }
2257
- return ret
2258
- }
2259
- };
2260
-
2261
- VueI18n.prototype.t = function t (key) {
2262
- var ref;
2263
-
2264
- var values = [], len = arguments.length - 1;
2265
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
2266
- return (ref = this)._t.apply(ref, [ key, this.locale, this._getMessages(), null ].concat( values ))
2267
- };
2268
-
2269
- VueI18n.prototype._i = function _i (key, locale, messages, host, values) {
2270
- var ret =
2271
- this._translate(messages, locale, this.fallbackLocale, key, host, 'raw', values);
2272
- if (this._isFallbackRoot(ret)) {
2273
- if (!this._root) { throw Error('unexpected error') }
2274
- return this._root.$i18n.i(key, locale, values)
2275
- } else {
2276
- return this._warnDefault(locale, key, ret, host, [values], 'raw')
2277
- }
2278
- };
2279
-
2280
- VueI18n.prototype.i = function i (key, locale, values) {
2281
- /* istanbul ignore if */
2282
- if (!key) { return '' }
2283
-
2284
- if (!isString(locale)) {
2285
- locale = this.locale;
2286
- }
2287
-
2288
- return this._i(key, locale, this._getMessages(), null, values)
2289
- };
2290
-
2291
- VueI18n.prototype._tc = function _tc (
2292
- key,
2293
- _locale,
2294
- messages,
2295
- host,
2296
- choice
2297
- ) {
2298
- var ref;
2299
-
2300
- var values = [], len = arguments.length - 5;
2301
- while ( len-- > 0 ) values[ len ] = arguments[ len + 5 ];
2302
- if (!key) { return '' }
2303
- if (choice === undefined) {
2304
- choice = 1;
2305
- }
2306
-
2307
- var predefined = { 'count': choice, 'n': choice };
2308
- var parsedArgs = parseArgs.apply(void 0, values);
2309
- parsedArgs.params = Object.assign(predefined, parsedArgs.params);
2310
- values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params];
2311
- return this.fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice)
2312
- };
2313
-
2314
- VueI18n.prototype.fetchChoice = function fetchChoice (message, choice) {
2315
- /* istanbul ignore if */
2316
- if (!message || !isString(message)) { return null }
2317
- var choices = message.split('|');
2318
-
2319
- choice = this.getChoiceIndex(choice, choices.length);
2320
- if (!choices[choice]) { return message }
2321
- return choices[choice].trim()
2322
- };
2323
-
2324
- VueI18n.prototype.tc = function tc (key, choice) {
2325
- var ref;
2326
-
2327
- var values = [], len = arguments.length - 2;
2328
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
2329
- return (ref = this)._tc.apply(ref, [ key, this.locale, this._getMessages(), null, choice ].concat( values ))
2330
- };
2331
-
2332
- VueI18n.prototype._te = function _te (key, locale, messages) {
2333
- var args = [], len = arguments.length - 3;
2334
- while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ];
2335
-
2336
- var _locale = parseArgs.apply(void 0, args).locale || locale;
2337
- return this._exist(messages[_locale], key)
2338
- };
2339
-
2340
- VueI18n.prototype.te = function te (key, locale) {
2341
- return this._te(key, this.locale, this._getMessages(), locale)
2342
- };
2343
-
2344
- VueI18n.prototype.getLocaleMessage = function getLocaleMessage (locale) {
2345
- return looseClone(this._vm.messages[locale] || {})
2346
- };
2347
-
2348
- VueI18n.prototype.setLocaleMessage = function setLocaleMessage (locale, message) {
2349
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
2350
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
2351
- }
2352
- this._vm.$set(this._vm.messages, locale, message);
2353
- };
2354
-
2355
- VueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, message) {
2356
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
2357
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
2358
- }
2359
- this._vm.$set(this._vm.messages, locale, merge(
2360
- typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
2361
- ? Object.assign({}, this._vm.messages[locale])
2362
- : {},
2363
- message
2364
- ));
2365
- };
2366
-
2367
- VueI18n.prototype.getDateTimeFormat = function getDateTimeFormat (locale) {
2368
- return looseClone(this._vm.dateTimeFormats[locale] || {})
2369
- };
2370
-
2371
- VueI18n.prototype.setDateTimeFormat = function setDateTimeFormat (locale, format) {
2372
- this._vm.$set(this._vm.dateTimeFormats, locale, format);
2373
- this._clearDateTimeFormat(locale, format);
2374
- };
2375
-
2376
- VueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, format) {
2377
- this._vm.$set(this._vm.dateTimeFormats, locale, merge(this._vm.dateTimeFormats[locale] || {}, format));
2378
- this._clearDateTimeFormat(locale, format);
2379
- };
2380
-
2381
- VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
2382
- // eslint-disable-next-line no-autofix/prefer-const
2383
- for (var key in format) {
2384
- var id = locale + "__" + key;
2385
-
2386
- if (!this._dateTimeFormatters.hasOwnProperty(id)) {
2387
- continue
2388
- }
2389
-
2390
- delete this._dateTimeFormatters[id];
2391
- }
2392
- };
2393
-
2394
- VueI18n.prototype._localizeDateTime = function _localizeDateTime (
2395
- value,
2396
- locale,
2397
- fallback,
2398
- dateTimeFormats,
2399
- key,
2400
- options
2401
- ) {
2402
- var _locale = locale;
2403
- var formats = dateTimeFormats[_locale];
2404
-
2405
- var chain = this._getLocaleChain(locale, fallback);
2406
- for (var i = 0; i < chain.length; i++) {
2407
- var current = _locale;
2408
- var step = chain[i];
2409
- formats = dateTimeFormats[step];
2410
- _locale = step;
2411
- // fallback locale
2412
- if (isNull(formats) || isNull(formats[key])) {
2413
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
2414
- warn(("Fall back to '" + step + "' datetime formats from '" + current + "' datetime formats."));
2415
- }
2416
- } else {
2417
- break
2418
- }
2419
- }
2420
-
2421
- if (isNull(formats) || isNull(formats[key])) {
2422
- return null
2423
- } else {
2424
- var format = formats[key];
2425
-
2426
- var formatter;
2427
- if (options) {
2428
- formatter = new Intl.DateTimeFormat(_locale, Object.assign({}, format, options));
2429
- } else {
2430
- var id = _locale + "__" + key;
2431
- formatter = this._dateTimeFormatters[id];
2432
- if (!formatter) {
2433
- formatter = this._dateTimeFormatters[id] = new Intl.DateTimeFormat(_locale, format);
2434
- }
2435
- }
2436
-
2437
- return formatter.format(value)
2438
- }
2439
- };
2440
-
2441
- VueI18n.prototype._d = function _d (value, locale, key, options) {
2442
-
2443
- if (!key) {
2444
- var dtf = !options ? new Intl.DateTimeFormat(locale) : new Intl.DateTimeFormat(locale, options);
2445
- return dtf.format(value)
2446
- }
2447
-
2448
- var ret =
2449
- this._localizeDateTime(value, locale, this.fallbackLocale, this._getDateTimeFormats(), key, options);
2450
- if (this._isFallbackRoot(ret)) {
2451
- /* istanbul ignore if */
2452
- if (!this._root) { throw Error('unexpected error') }
2453
- return this._root.$i18n.d(value, key, locale)
2454
- } else {
2455
- return ret || ''
2456
- }
2457
- };
2458
-
2459
- VueI18n.prototype.d = function d (value) {
2460
- var args = [], len = arguments.length - 1;
2461
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2462
-
2463
- var locale = this.locale;
2464
- var key = null;
2465
- var options = null;
2466
-
2467
- if (args.length === 1) {
2468
- if (isString(args[0])) {
2469
- key = args[0];
2470
- } else if (isObject(args[0])) {
2471
- if (args[0].locale) {
2472
- locale = args[0].locale;
2473
- }
2474
- if (args[0].key) {
2475
- key = args[0].key;
2476
- }
2477
- }
2478
-
2479
- options = Object.keys(args[0]).reduce(function (acc, key) {
2480
- var obj;
2481
-
2482
- if (includes(dateTimeFormatKeys, key)) {
2483
- return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))
2484
- }
2485
- return acc
2486
- }, null);
2487
-
2488
- } else if (args.length === 2) {
2489
- if (isString(args[0])) {
2490
- key = args[0];
2491
- }
2492
- if (isString(args[1])) {
2493
- locale = args[1];
2494
- }
2495
- }
2496
-
2497
- return this._d(value, locale, key, options)
2498
- };
2499
-
2500
- VueI18n.prototype.getNumberFormat = function getNumberFormat (locale) {
2501
- return looseClone(this._vm.numberFormats[locale] || {})
2502
- };
2503
-
2504
- VueI18n.prototype.setNumberFormat = function setNumberFormat (locale, format) {
2505
- this._vm.$set(this._vm.numberFormats, locale, format);
2506
- this._clearNumberFormat(locale, format);
2507
- };
2508
-
2509
- VueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format) {
2510
- this._vm.$set(this._vm.numberFormats, locale, merge(this._vm.numberFormats[locale] || {}, format));
2511
- this._clearNumberFormat(locale, format);
2512
- };
2513
-
2514
- VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
2515
- // eslint-disable-next-line no-autofix/prefer-const
2516
- for (var key in format) {
2517
- var id = locale + "__" + key;
2518
-
2519
- if (!this._numberFormatters.hasOwnProperty(id)) {
2520
- continue
2521
- }
2522
-
2523
- delete this._numberFormatters[id];
2524
- }
2525
- };
2526
-
2527
- VueI18n.prototype._getNumberFormatter = function _getNumberFormatter (
2528
- value,
2529
- locale,
2530
- fallback,
2531
- numberFormats,
2532
- key,
2533
- options
2534
- ) {
2535
- var _locale = locale;
2536
- var formats = numberFormats[_locale];
2537
-
2538
- var chain = this._getLocaleChain(locale, fallback);
2539
- for (var i = 0; i < chain.length; i++) {
2540
- var current = _locale;
2541
- var step = chain[i];
2542
- formats = numberFormats[step];
2543
- _locale = step;
2544
- // fallback locale
2545
- if (isNull(formats) || isNull(formats[key])) {
2546
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
2547
- warn(("Fall back to '" + step + "' number formats from '" + current + "' number formats."));
2548
- }
2549
- } else {
2550
- break
2551
- }
2552
- }
2553
-
2554
- if (isNull(formats) || isNull(formats[key])) {
2555
- return null
2556
- } else {
2557
- var format = formats[key];
2558
-
2559
- var formatter;
2560
- if (options) {
2561
- // If options specified - create one time number formatter
2562
- formatter = new Intl.NumberFormat(_locale, Object.assign({}, format, options));
2563
- } else {
2564
- var id = _locale + "__" + key;
2565
- formatter = this._numberFormatters[id];
2566
- if (!formatter) {
2567
- formatter = this._numberFormatters[id] = new Intl.NumberFormat(_locale, format);
2568
- }
2569
- }
2570
- return formatter
2571
- }
2572
- };
2573
-
2574
- VueI18n.prototype._n = function _n (value, locale, key, options) {
2575
- /* istanbul ignore if */
2576
- if (!VueI18n.availabilities.numberFormat) {
2577
- return ''
2578
- }
2579
-
2580
- if (!key) {
2581
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2582
- return nf.format(value)
2583
- }
2584
-
2585
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2586
- var ret = formatter && formatter.format(value);
2587
- if (this._isFallbackRoot(ret)) {
2588
- /* istanbul ignore if */
2589
- if (!this._root) { throw Error('unexpected error') }
2590
- return this._root.$i18n.n(value, Object.assign({}, { key: key, locale: locale }, options))
2591
- } else {
2592
- return ret || ''
2593
- }
2594
- };
2595
-
2596
- VueI18n.prototype.n = function n (value) {
2597
- var args = [], len = arguments.length - 1;
2598
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2599
-
2600
- var locale = this.locale;
2601
- var key = null;
2602
- var options = null;
2603
-
2604
- if (args.length === 1) {
2605
- if (isString(args[0])) {
2606
- key = args[0];
2607
- } else if (isObject(args[0])) {
2608
- if (args[0].locale) {
2609
- locale = args[0].locale;
2610
- }
2611
- if (args[0].key) {
2612
- key = args[0].key;
2613
- }
2614
-
2615
- // Filter out number format options only
2616
- options = Object.keys(args[0]).reduce(function (acc, key) {
2617
- var obj;
2618
-
2619
- if (includes(numberFormatKeys, key)) {
2620
- return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))
2621
- }
2622
- return acc
2623
- }, null);
2624
- }
2625
- } else if (args.length === 2) {
2626
- if (isString(args[0])) {
2627
- key = args[0];
2628
- }
2629
- if (isString(args[1])) {
2630
- locale = args[1];
2631
- }
2632
- }
2633
-
2634
- return this._n(value, locale, key, options)
2635
- };
2636
-
2637
- VueI18n.prototype._ntp = function _ntp (value, locale, key, options) {
2638
- /* istanbul ignore if */
2639
- if (!VueI18n.availabilities.numberFormat) {
2640
- return []
2641
- }
2642
-
2643
- if (!key) {
2644
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2645
- return nf.formatToParts(value)
2646
- }
2647
-
2648
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2649
- var ret = formatter && formatter.formatToParts(value);
2650
- if (this._isFallbackRoot(ret)) {
2651
- /* istanbul ignore if */
2652
- if (!this._root) { throw Error('unexpected error') }
2653
- return this._root.$i18n._ntp(value, locale, key, options)
2654
- } else {
2655
- return ret || []
2656
- }
2657
- };
2658
-
2659
- Object.defineProperties( VueI18n.prototype, prototypeAccessors );
2660
-
2661
- var availabilities;
2662
- // $FlowFixMe
2663
- Object.defineProperty(VueI18n, 'availabilities', {
2664
- get: function get () {
2665
- if (!availabilities) {
2666
- var intlDefined = typeof Intl !== 'undefined';
2667
- availabilities = {
2668
- dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
2669
- numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
2670
- };
2671
- }
2672
-
2673
- return availabilities
2674
- }
2675
- });
2676
-
2677
- VueI18n.install = install$1;
2678
- VueI18n.version = '8.28.2';
2679
-
2680
- var VueI18n$1 = VueI18n;
2681
-
2682
- var validate$1 = {
2683
- required: "Поле \"{field}\" обязательно",
2684
- min: "Минимальное значение для этого поля {min}"
2685
- };
2686
- var Ru = {
2687
- validate: validate$1
2688
- };
2689
-
2690
- var validate = {
2691
- required: "\"{field}\" жолы міндетті",
2692
- min: "Бұл жол үшін ең кіші мән {min}"
2693
- };
2694
- var Kz = {
2695
- validate: validate
2696
- };
2697
-
2698
- const locale = localStorage.getItem('lang') ? localStorage.getItem('lang') : 'Ru';
2699
- Vue$1.use(VueI18n$1);
2700
- const i18n = new VueI18n$1({
2701
- locale: locale,
2702
- fallbackLocale: 'Ru',
2703
- messages: {
2704
- Ru,
2705
- Kz
2706
- }
2707
- });
2708
-
2709
468
  //
2710
469
  //
2711
470
  //
@@ -8656,14 +6415,10 @@ var script$3 = {
8656
6415
  var _f$input$propsData;
8657
6416
  let feedback = '';
8658
6417
  if (f.required && this.isValueEmpty(f.name)) {
8659
- feedback += i18n.t('validate.required', {
8660
- field: this.getDisplayField(f)
8661
- });
6418
+ feedback += this.getDisplayField(f);
8662
6419
  }
8663
6420
  if (f.type === 'integer' && this.isValueLessThanMin(f.name, f.input.propsData.min)) {
8664
- feedback += `\n${i18n.t('validate.min', {
8665
- min: f.input.propsData.min
8666
- })}`;
6421
+ feedback += f.input.propsData.min;
8667
6422
  }
8668
6423
  // TODO: Костыль так как на бэке нету типа memo
8669
6424
  if (f.input.type === 'b-form-textarea' && this.isValueLessThanMax(f.name, (_f$input$propsData = f.input.propsData) === null || _f$input$propsData === void 0 ? void 0 : _f$input$propsData.max)) {
@@ -8671,10 +6426,10 @@ var script$3 = {
8671
6426
  feedback += `\nМаксимальное значение для этого поля ${(_f$input$propsData2 = f.input.propsData) === null || _f$input$propsData2 === void 0 ? void 0 : _f$input$propsData2.max}`;
8672
6427
  }
8673
6428
  if (feedback) {
8674
- Vue$1.set(this.validationState, f.name, false);
8675
- Vue$1.set(this.validationState, `${f.name}__feedback`, feedback);
6429
+ Vue.set(this.validationState, f.name, false);
6430
+ Vue.set(this.validationState, `${f.name}__feedback`, feedback);
8676
6431
  } else {
8677
- Vue$1.set(this.validationState, f.name, null);
6432
+ Vue.set(this.validationState, f.name, null);
8678
6433
  }
8679
6434
  this.onEventFired('validate', {
8680
6435
  validationState: this.validationState,
@@ -10004,7 +7759,7 @@ var __vue_render__ = function () {
10004
7759
  return [_c('rb-icon', {
10005
7760
  staticClass: "cursor-pointer rb-row-drag-handle",
10006
7761
  attrs: {
10007
- "icon": "icon-search"
7762
+ "icon": _vm.iconDrag
10008
7763
  }
10009
7764
  }), _vm._v(" "), _c('rb-text', {
10010
7765
  staticClass: "flex-fill",
@@ -10170,7 +7925,6 @@ var components = /*#__PURE__*/Object.freeze({
10170
7925
  __proto__: null,
10171
7926
  UtFormConfig: UtFormConfig,
10172
7927
  UtFormConstructor: UtFormConstructor,
10173
- i18n: i18n,
10174
7928
  DocTemplateSectionModal: DocTemplateSectionModal,
10175
7929
  DocTemplateFacetList: DocTemplateFacetList,
10176
7930
  DocTemplateFieldSidebar: DocTemplateFieldSidebar,
@@ -10188,4 +7942,4 @@ const install = function installRbDocumentFormConstructor(Vue) {
10188
7942
  });
10189
7943
  };
10190
7944
 
10191
- export { DocForm, __vue_component__$1 as DocTemplateConstructor, DocTemplateFacetList, DocTemplateFieldSidebar, DocTemplateSectionModal, FieldRuleFormModal, UtFormConfig, UtFormConstructor, install as default, i18n };
7945
+ export { DocForm, __vue_component__$1 as DocTemplateConstructor, DocTemplateFacetList, DocTemplateFieldSidebar, DocTemplateSectionModal, FieldRuleFormModal, UtFormConfig, UtFormConstructor, install as default };