generaltranslation
Version:
A language toolkit for AI developers
3 lines (2 loc) • 5.8 kB
JavaScript
;var r=require("fast-json-stable-stringify"),e=require("crypto-js"),t=["singular","plural","dual","zero","one","two","few","many","other"];var n=new(function(){function r(){this.cache=new Map}return r.prototype._generateKey=function(r,e,t){void 0===t&&(t={});var n=Array.isArray(e)?e.join(","):e,i=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(r,":").concat(n,":").concat(i)},r.prototype.get=function(r,e,t){void 0===t&&(t={});var n=this._generateKey(r,e,t);if(!this.cache.has(n)){var i=new Intl[r](e,t);this.cache.set(n,i)}return this.cache.get(n)},r}());var i={variable:"v",number:"n",datetime:"d",currency:"c"};var o=function(){return o=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r},o.apply(this,arguments)};function a(r){return"object"==typeof r&&null!=r&&"key"in r}function u(r){return"object"==typeof r&&null!=r&&"k"in r}function l(r){return"string"==typeof r||(!!a(r)||function(r){return"object"==typeof r&&null!=r&&"type"in r&&"props"in r}(r))}function s(r){return"string"==typeof r||(Array.isArray(r)?!r.some(function(r){return!l(r)}):l(r))}function c(r){return"string"==typeof r?r:a(r)?y(r):d(r)}function p(r){return"string"==typeof r?r:Array.isArray(r)?r.map(c):c(r)}function d(r){var e;if("string"==typeof r)return r;var t=void 0;null!=r.type&&(t=r.type);var n=void 0;return null!=(null===(e=r.props)||void 0===e?void 0:e.children)&&(n=p(r.props.children)),o(o(o({},t&&{t:t}),n&&{c:n}),{d:b(r.props["data-_gt"]),i:r.props["data-_gt"].id})}function f(r){return"branch"===r?"b":"p"}function v(r){switch(r){case"number":return"n";case"variable":default:return"v";case"datetime":return"d";case"currency":return"c"}}function y(r){var e=void 0;null!=r.variable&&(e=v(r.variable));var t=void 0;return null!=r.id&&(t=r.id),o(o({k:r.key},e&&{v:e}),t&&{i:t})}function b(r){var e,t=void 0;return r.branches&&(t=Object.fromEntries(Object.entries(r.branches).map(function(r){return[r[0],p(r[1])]}))),r.transformation&&(e=f(r.transformation)),o(o({},t&&{b:t}),e&&{t:e})}function h(r){return"string"==typeof r?r:u(r)?w(r):x(r)}function g(r){return s(r)||"string"==typeof r?r:Array.isArray(r)?r.map(h):h(r)}function x(r){var e=r.t,t=void 0;return null!=r.c&&(t=g(r.c)),{type:e,props:{children:t,"data-_gt":j(r.d||{},r.i)}}}function m(r){return"b"===r?"branch":"plural"}function O(r){switch(r){case"n":return"number";case"v":default:return"variable";case"d":return"datetime";case"c":return"currency"}}function w(r){var e=void 0;null!=r.v&&(e=O(r.v));var t=void 0;return null!=r.i&&(t=r.i),o(o({key:r.k},e&&{variable:e}),t&&{id:t})}function j(r,e){var t=void 0;null!=r.t&&(t=m(r.t));var n=void 0;return null!=r.b&&(n=Object.fromEntries(Object.entries(r.b).map(function(r){return[r[0],g(r[1])]}))),o(o({id:e},t&&{transformation:t}),n&&{branches:n})}function A(r){return e.SHA256(r).toString(e.enc.Hex)}"function"==typeof SuppressedError&&SuppressedError;var k=function(r){var e,t,n,i;if(r&&"object"==typeof r){if("props"in r){var a={},u=null===(e=null==r?void 0:r.props)||void 0===e?void 0:e["data-_gt"];return(null==u?void 0:u.branches)&&(a.branches=Object.fromEntries(Object.entries(u.branches).map(function(r){return[r[0],J(r[1])]}))),(null===(t=null==r?void 0:r.props)||void 0===t?void 0:t.children)&&(a.children=J(r.props.children)),(null===(i=null===(n=null==r?void 0:r.props)||void 0===n?void 0:n["data-_gt"])||void 0===i?void 0:i.transformation)&&(a.transformation=r.props["data-_gt"].transformation),a}if("key"in r)return o({key:r.key},r.variable&&{variable:r.variable})}return r};function J(r){return Array.isArray(r)?r.map(k):k(r)}exports.defaultBaseUrl="https://api2.gtx.dev",exports.defaultCacheUrl="https://cdn.gtx.dev",exports.defaultRuntimeApiUrl="https://runtime2.gtx.dev",exports.getNewBranchType=f,exports.getNewGTProp=b,exports.getNewJsxChild=c,exports.getNewJsxChildren=p,exports.getNewJsxElement=d,exports.getNewVariableObject=y,exports.getNewVariableType=v,exports.getOldBranchType=m,exports.getOldGTProp=j,exports.getOldJsxChild=h,exports.getOldJsxChildren=g,exports.getOldJsxElement=x,exports.getOldVariableObject=w,exports.getOldVariableType=O,exports.getPluralForm=function(r,e,i){void 0===e&&(e=t),void 0===i&&(i=["en"]);var o=n.get("PluralRules",i).select(r),a=Math.abs(r);if(0===a&&e.includes("zero"))return"zero";if(1===a){if(e.includes("singular"))return"singular";if(e.includes("one"))return"one"}if("one"===o&&e.includes("singular"))return"singular";if(2===a){if(e.includes("dual"))return"dual";if(e.includes("two"))return"two"}return"two"===o&&e.includes("dual")?"dual":e.includes(o)?o:"two"===o&&e.includes("dual")?"dual":"two"===o&&e.includes("plural")?"plural":"two"===o&&e.includes("other")?"other":"few"===o&&e.includes("plural")?"plural":"few"===o&&e.includes("other")?"other":"many"===o&&e.includes("plural")?"plural":"many"===o&&e.includes("other")?"other":"other"===o&&e.includes("plural")?"plural":""},exports.isAcceptedPluralForm=function(r){return t.includes(r)},exports.isNewVariableObject=u,exports.isOldJsxChildren=s,exports.isOldVariableObject=a,exports.isVariable=function(r){var e=r;if(e&&"object"==typeof e&&"string"==typeof e.k){var t=Object.keys(e);if(1===t.length)return!0;if(2===t.length){if("number"==typeof e.i)return!0;if("string"==typeof e.v)return!0}if(3===t.length&&"string"==typeof e.v&&"number"==typeof e.i)return!0}return!1},exports.libraryDefaultLocale="en",exports.minifyVariableType=function(r){return i[r]},exports.oldHashJsxChildren=function(e,t){var n=e.source,i=e.context,a=e.id,u=e.dataFormat;return void 0===t&&(t=A),t(r(o(o(o({source:J(n)},a&&{id:a}),i&&{context:i}),u&&{dataFormat:u})))},exports.oldHashString=A,exports.pluralForms=t;
//# sourceMappingURL=internal.cjs.min.cjs.map