-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vueI18nTranslationParser.min.js
1 lines (1 loc) · 1.64 KB
/
vueI18nTranslationParser.min.js
1
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.vueI18nTranslationParser=e.vueI18nTranslationParser||{})}(this,function(e){"use strict";function t(e){var t=f.parse("<dummyI18nTag>"+e+"</dummyI18nTag>",{ignoreCollapse:!0});return n(t),t[0].children||[]}function n(e){function t(e){e&&e.forEach(function(e){if("text"===e.type&&(e.content.indexOf("{")>-1||e.content.indexOf("${")>-1||e.content.indexOf("@:")>-1)){var n=e.content.split(a),r=n.length>1?e.content.split(a).reduce(function(e,t,n){if(n%2==0)e.push({type:"text",content:t});else if(0===t.indexOf("{")){var r=t.substring(1,t.length-1);e.push({type:"format",raw:t,prefix:"{",suffix:"}",content:r,variable:r.trim()})}else if(0===t.indexOf("%{")){var i=t.substring(2,t.length-1);e.push({type:"format",raw:t,prefix:"%{",suffix:"}",content:i,variable:i.trim()})}else if(0===t.indexOf("@:")){var f=t.substring(2,t.length);e.push({type:"link",raw:t,prefix:"@:",suffix:"",content:f,variable:f.trim()})}return e},[]):[];e.children=r}e.children&&t(e.children)})}return t(e),e}function r(e){var t=[{type:"tag",name:"dummyI18nTag",voidElement:!1,attrs:void 0,children:e}],n=s.stringify(t);return n.substring(14,n.length-15)}function i(e){function t(e){e&&e.forEach(function(e){"tag"===e.type&&n.tags++,"format"===e.type&&n.format++,"link"===e.type&&n.link++,e.children&&t(e.children)})}var n={format:0,link:0,tags:0};return t(e),n}var f=require("html-parse-stringify2"),a=new RegExp("({[^}]+}|\\%{[^}]+}|@:[^ ]+)","g"),s=require("html-parse-stringify2");e.parse=t,e.stringify=r,e.astStats=i,Object.defineProperty(e,"__esModule",{value:!0})});