ilib-tools-common 1.21.0 → 1.21.2

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.
package/lib/Resource.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=exports.VALID_STATES=void 0;exports.isValidState=isValidState;function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/*
2
2
  * Resource.js - super class that represents a resource
3
3
  *
4
- * Copyright © 2022-2025 JEDLSoft
4
+ * Copyright © 2022-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -80,6 +80,7 @@ var contentAfterX=state.substring(2);if(contentAfterX.trim().length>0){return tr
80
80
  * @param {string} [props.comment] the comment (translator's note) of this resource
81
81
  * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false
82
82
  * @param {string} [props.datatype] the type of file that this resource came from
83
+ * @param {string} [props.sourceHash] the hash value of a source string
83
84
  * @param {string} [props.flavor] the "flavor" of this string, if any. (Android)
84
85
  * @param {Location} [props.location] the location in the file given in pathName where this this resource
85
86
  * is located
@@ -106,7 +107,7 @@ var contentAfterX=state.substring(2);if(contentAfterX.trim().length>0){return tr
106
107
  */_defineProperty(this,"resfile",void 0);if(this.constructor===Resource){throw new Error("Cannot instantiate abstract class Resource!")}this.autoKey=false;if(props){this.project=props.project;this.context=props.context||undefined;// avoid the empty string
107
108
  this.sourceLocale=props.sourceLocale||props.locale;this.targetLocale=props.targetLocale;this.reskey=props.key||props.reskey;this.pathName=props.pathName;this.autoKey=typeof props.autoKey==="boolean"?props.autoKey:false;this.state=props.state||undefined;this.id=props.id;// the database id
108
109
  this.formatted=props.formatted;// for Android layout resources
109
- this.comment=props.comment;this.origin=props.origin||"source";this.dnt=props.dnt;this.datatype=props.datatype;this.sourceHash=props.sourceHash;this.localize=typeof props.localize==="boolean"?props.localize:true;// some files have resources we do not want to localize/translate
110
+ this.comment=props.comment;this.origin=props.origin||"source";this.dnt=props.dnt;this.datatype=props.datatype;this.sourceHash=props.sourceHash||undefined;this.localize=typeof props.localize==="boolean"?props.localize:true;// some files have resources we do not want to localize/translate
110
111
  this.flavor=props.flavor;this.index=props.index;this.location=props.location;// optional location of the transunits in the xml file
111
112
  this.resfile=props.resfile;// optional resource file path
112
113
  this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pathName||"";this.dirty=false}/**
@@ -177,6 +178,14 @@ this.metadata=props.metadata||undefined}this.instances=[];this.pathName=this.pat
177
178
  *
178
179
  * @returns {string} the state of this resource
179
180
  */},{key:"getState",value:function getState(){return this.state}/**
181
+ * Sets the hash value for the source of this resource.
182
+ *
183
+ * @param {string} hashValue the hash value to set for this resource.
184
+ */},{key:"setSourceHash",value:function setSourceHash(hashValue){if(hashValue!==undefined&&typeof hashValue!=="string"){throw new TypeError("hashValue must be a string")}this.sourceHash=hashValue;this.dirty=true}/**
185
+ * Returns the hash value for the source of this resource.
186
+ *
187
+ * @returns {string|undefined} the hash value of this resource.
188
+ */},{key:"getSourceHash",value:function getSourceHash(){return this.sourceHash}/**
180
189
  * Set the project of this resource. This is a string that gives the
181
190
  * id of the project for this resource.
182
191
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Resource.js","names":["validStates","VALID_STATES","exports","Object","keys","sort","isValidState","state","length","startsWith","contentAfterX","substring","trim","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","metadata","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getMetadata","setMetadata","data","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","concat","join","getPath","getComment","setComment","getDNT","setDNT","flag","TypeError","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n // XLIFF 2.0 standard states\n // https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html\n \"initial\": true,\n \"translated\": true,\n \"reviewed\": true,\n \"final\": true,\n\n // XLIFF 1.2 standard states\n // from https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html\n \"new\": true,\n \"needs-translation\": true,\n \"needs-adaptation\": true,\n \"needs-l10n\": true,\n \"needs-review-translation\": true,\n \"needs-review-adaptation\": true,\n \"needs-review-l10n\": true,\n \"signed-off\": true,\n\n // Additional common states used in practice\n \"needs-review\": true,\n \"fuzzy\": true,\n \"accepted\": true,\n \"rejected\": true,\n \"approved\": true,\n \"needs-approval\": true\n};\n\n/**\n * Array of all valid state names that can be used with Resource objects.\n * This array is sorted alphabetically and includes states from:\n * - XLIFF 2.0 standard states\n * - XLIFF 1.2 standard states\n * - Additional common states used in practice\n *\n * Custom states with \"x-\" prefix are also valid but not included in this array.\n *\n * @example\n * // Check if a state is valid\n * if (VALID_STATES.includes(state)) {\n * console.log('Valid state');\n * }\n *\n * @type {string[]}\n * @since 1.19.0\n */\nexport const VALID_STATES = Object.keys(validStates).sort();\n\n/**\n * Check if a state is valid according to XLIFF 1.2 or 2.0 specification\n * or if the state is used with ilib projects.\n *\n * @param {string} state the state to validate\n * @returns {boolean} true if the state is valid, false otherwise\n * @since 1.19.0\n */\nfunction isValidState(state) {\n // Must be a string\n if (typeof state !== 'string') {\n return false;\n }\n\n // Empty string is invalid\n if (state.length === 0) {\n return false;\n }\n\n // Check predefined states first\n if (validStates[state]) {\n return true;\n }\n\n // Custom states must start with \"x-\" and have content after the hyphen\n if (state.startsWith('x-')) {\n // Must have non-whitespace content after \"x-\"\n const contentAfterX = state.substring(2);\n if (contentAfterX.trim().length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\nexport { isValidState };\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n * @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.\n * This can be any arbitrary object of any depth, as long as the values of properties are all static.\n * It is up to the parsers to parse this and serializers to serialize this appropriately.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n this.metadata = props.metadata || undefined;\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Get the metadata of this resource.\n *\n * @returns {Object|undefined} the metadata of this resource.\n */\n getMetadata() {\n return this.metadata;\n }\n\n /**\n * Set the metadata of this resource.\n * @param {Object|undefined} data the metadata of this resource.\n */\n setMetadata(data) {\n this.metadata = data;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n * @throws {Error} if the state is invalid\n */\n setState(state) {\n if (!isValidState(state)) {\n throw new Error(`Attempt to set an invalid state on a resource: \"${state}\". Valid states are: ${VALID_STATES.join(', ')}, or custom states starting with \"x-\"`);\n }\n this.state = state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"y3CAAA;AACA;AACA;AACA;AACA;AACA;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AI,IAAI,CAAI,CACtC,MAAO,CAAAD,KAAI,CAACC,IAAI,CAAC,GAAKP,QAAQ,CAACO,IAAI,CACvC,CAAC,CACL,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAAtE,GAAA,gBAAAkB,KAAA,CAMA,SAAAqD,YAAYA,CAAA,CAAG,CACX,MAAO,KAAI,CAACxD,SAChB,CAEA;AACJ;AACA,OAFI,GAAAf,GAAA,WAAAkB,KAAA,CAGA,SAAAsD,OAAOA,CAAA,CAAG,CACN,MAAO,KAAI,CAACxD,KAChB,CAEA;AACJ;AACA;AACA;AACA,OAJI,GAAAhB,GAAA,cAAAkB,KAAA,CAKA,SAAAuD,UAAUA,CAAA,CAAG,CACT,IAAI,CAACzD,KAAK,CAAG,KACjB,CAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OARI,GAAAhB,GAAA,eAAAkB,KAAA,CASA,SAAAwD,WAAWA,CAAA,CAAG,KAAAC,cAAA,CACV,OAAAA,cAAA,CAAO,IAAI,CAAC/D,QAAQ,UAAA+D,cAAA,iBAAbA,cAAA,CAAeD,WAAW,CAAC,CACtC,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAA1E,GAAA,WAAAkB,KAAA,CAMA,SAAA0D,OAAOA,CAAA,CAAG,CACN,KAAM,IAAI,CAAArF,KAAK,CAAC,2BAA2B,CAC/C,CAEA;AACJ;AACA;AACA;AACA;AACA,OALI,GAAAS,GAAA,gBAAAkB,KAAA,CAMA,SAAA2D,YAAYA,CAAA,CAAG,CACX,KAAM,IAAI,CAAAtF,KAAK,CAAC,gCAAgC,CACpD,CAAC,WAAAuF,QAAA,CAAAxG,OAAA,YAGUY,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"Resource.js","names":["validStates","VALID_STATES","exports","Object","keys","sort","isValidState","state","length","startsWith","contentAfterX","substring","trim","translationImportant","Resource","props","_classCallCheck","_defineProperty","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","resfile","metadata","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getMetadata","setMetadata","data","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setSourceHash","hashValue","TypeError","getSourceHash","setProject","setState","concat","join","getPath","getComment","setComment","getDNT","setDNT","flag","getId","getOrigin","getLocalize","getFlavor","getResFile","same","other","i","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","hashKey","cleanHashKey","_default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2026 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst validStates = {\n // XLIFF 2.0 standard states\n // https://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html\n \"initial\": true,\n \"translated\": true,\n \"reviewed\": true,\n \"final\": true,\n\n // XLIFF 1.2 standard states\n // from https://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html\n \"new\": true,\n \"needs-translation\": true,\n \"needs-adaptation\": true,\n \"needs-l10n\": true,\n \"needs-review-translation\": true,\n \"needs-review-adaptation\": true,\n \"needs-review-l10n\": true,\n \"signed-off\": true,\n\n // Additional common states used in practice\n \"needs-review\": true,\n \"fuzzy\": true,\n \"accepted\": true,\n \"rejected\": true,\n \"approved\": true,\n \"needs-approval\": true\n};\n\n/**\n * Array of all valid state names that can be used with Resource objects.\n * This array is sorted alphabetically and includes states from:\n * - XLIFF 2.0 standard states\n * - XLIFF 1.2 standard states\n * - Additional common states used in practice\n *\n * Custom states with \"x-\" prefix are also valid but not included in this array.\n *\n * @example\n * // Check if a state is valid\n * if (VALID_STATES.includes(state)) {\n * console.log('Valid state');\n * }\n *\n * @type {string[]}\n * @since 1.19.0\n */\nexport const VALID_STATES = Object.keys(validStates).sort();\n\n/**\n * Check if a state is valid according to XLIFF 1.2 or 2.0 specification\n * or if the state is used with ilib projects.\n *\n * @param {string} state the state to validate\n * @returns {boolean} true if the state is valid, false otherwise\n * @since 1.19.0\n */\nfunction isValidState(state) {\n // Must be a string\n if (typeof state !== 'string') {\n return false;\n }\n\n // Empty string is invalid\n if (state.length === 0) {\n return false;\n }\n\n // Check predefined states first\n if (validStates[state]) {\n return true;\n }\n\n // Custom states must start with \"x-\" and have content after the hyphen\n if (state.startsWith('x-')) {\n // Must have non-whitespace content after \"x-\"\n const contentAfterX = state.substring(2);\n if (contentAfterX.trim().length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\nexport { isValidState };\n\nconst translationImportant = [\n \"context\",\n \"datatype\",\n \"dnt\",\n \"flavor\",\n \"project\",\n \"reskey\",\n \"resType\",\n \"sourceLocale\",\n \"targetLocale\"\n];\n\n\n/**\n * @class Represents a resource from a resource file or\n * extracted from the code.\n * @abstract\n */\nclass Resource {\n /**\n * The type of this resource instance.\n * @type {String | undefined}\n */\n resType;\n\n /**\n * The source string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n source;\n\n /**\n * The target string or strings for the resource.\n * @type {String|Array.<String>|Object}\n */\n target;\n\n /**\n * The resource file that this resource was loaded from.\n * @type {string|undefined}\n */\n resfile;\n\n /**\n * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n * @param {string} [props.project] the project that this resource is in\n * @param {string} [props.context] The context for this resource,\n * such as \"landscape mode\", or \"7200dp\", which differentiates it\n * from the base resource that has no special context. The default\n * if this property is not specified is undefined, meaning no\n * context.\n * @param {string} [props.sourceLocale] the locale of the source resource.\n * @param {string} [props.targetLocale] the locale of the target resource.\n * @param {string} [props.key] the unique key of this string, which should include the context\n * of the string\n * @param {string} [props.pathName] pathName to the file where the string was extracted from\n * @param {boolean} [props.autoKey] true if the key was generated based on the source text\n * @param {string} [props.state] current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * @param {string} [props.id] the id of the current resource\n * @param {string} [props.comment] the comment (translator's note) of this resource\n * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false\n * @param {string} [props.datatype] the type of file that this resource came from\n * @param {string} [props.sourceHash] the hash value of a source string\n * @param {string} [props.flavor] the \"flavor\" of this string, if any. (Android)\n * @param {Location} [props.location] the location in the file given in pathName where this this resource\n * is located\n * @param {string | undefined} [props.resfile] if this resource was extracted from a resource file, this\n * is the path to the resource file that contains this resource. This is different from the pathName\n * property, which is the path to the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android string.xml files or xliff files.\n * Otherwise, the property is undefined.\n * @param {Object|undefined} [props.metadata] the metadata of the resource or undefined for no metadata.\n * This can be any arbitrary object of any depth, as long as the values of properties are all static.\n * It is up to the parsers to parse this and serializers to serialize this appropriately.\n */\n constructor(props) {\n if (this.constructor === Resource) {\n throw new Error(\"Cannot instantiate abstract class Resource!\");\n }\n\n this.autoKey = false;\n\n if (props) {\n this.project = props.project;\n this.context = props.context || undefined; // avoid the empty string\n this.sourceLocale = props.sourceLocale || props.locale;\n this.targetLocale = props.targetLocale;\n this.reskey = props.key || props.reskey;\n this.pathName = props.pathName;\n this.autoKey = typeof(props.autoKey) === \"boolean\" ? props.autoKey : false;\n this.state = props.state || undefined;\n this.id = props.id; // the database id\n this.formatted = props.formatted; // for Android layout resources\n this.comment = props.comment;\n this.origin = props.origin || \"source\";\n this.dnt = props.dnt;\n this.datatype = props.datatype;\n this.sourceHash = props.sourceHash || undefined;\n this.localize = typeof(props.localize) === \"boolean\" ? props.localize : true; // some files have resources we do not want to localize/translate\n this.flavor = props.flavor;\n this.index = props.index;\n this.location = props.location; // optional location of the transunits in the xml file\n this.resfile = props.resfile; // optional resource file path\n this.metadata = props.metadata || undefined;\n }\n\n this.instances = [];\n this.pathName = this.pathName || \"\";\n this.dirty = false;\n }\n\n /**\n * Return the project that this resource was found in.\n *\n * @returns {string} the project of this resource\n */\n getProject() {\n return this.project;\n }\n\n /**\n * Return the unique key of this resource.\n *\n * @returns {string} the unique key of this resource\n */\n getKey() {\n return this.reskey;\n }\n\n /**\n * Return the source string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object} the source string or\n * strings of this resource\n */\n getSource() {\n return this.source;\n }\n\n /**\n * Return the target string or strings for this resource.\n *\n * @returns {String|Array.<String>|Object|undefined} the source string or\n * strings of this resource\n */\n getTarget() {\n return this.target;\n }\n\n /**\n * Return the resource type of this resource. This is one of\n * string, array, or plural.\n *\n * @returns {string} the resource type of this resource\n */\n getType() {\n return this.resType || \"string\";\n }\n\n /**\n * Return the data type of this resource.\n *\n * @returns {string} the data type of this resource\n */\n getDataType() {\n return this.datatype;\n }\n\n /**\n * Return true if the key of this resource was automatically generated,\n * and false if it was an explicit key.\n *\n * @returns {boolean} true if the key of this string was auto generated,\n * false otherwise\n */\n getAutoKey() {\n return this.autoKey;\n }\n\n /**\n * Return the context of this resource, or undefined if there\n * is no context.\n * @returns {String|undefined} the context of this resource, or undefined if there\n * is no context.\n */\n getContext() {\n return this.context;\n }\n\n /**\n * Get the metadata of this resource.\n *\n * @returns {Object|undefined} the metadata of this resource.\n */\n getMetadata() {\n return this.metadata;\n }\n\n /**\n * Set the metadata of this resource.\n * @param {Object|undefined} data the metadata of this resource.\n */\n setMetadata(data) {\n this.metadata = data;\n }\n\n /**\n * Return the source locale of this resource, or undefined if there\n * is no context or the locale is the same as the project's source locale.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getSourceLocale() {\n return this.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source locale of this resource.\n * @param {string} locale the source locale of this resource\n */\n setSourceLocale(locale) {\n this.sourceLocale = locale || this.sourceLocale;\n this.dirty = true;\n }\n\n /**\n * Return the target locale of this resource, or undefined if the resource\n * is a source-only resource.\n * @returns {String|undefined} the locale of this resource, or undefined if there\n * is no locale.\n */\n getTargetLocale() {\n return this.targetLocale;\n }\n\n /**\n * Set the target locale of this resource.\n * @param {string} locale the target locale of this resource\n */\n setTargetLocale(locale) {\n this.targetLocale = locale || this.targetLocale;\n this.dirty = true;\n }\n\n /**\n * Return the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @returns {string} the state of this resource\n */\n getState() {\n return this.state;\n }\n\n /**\n * Sets the hash value for the source of this resource.\n *\n * @param {string} hashValue the hash value to set for this resource.\n */\n setSourceHash(hashValue) {\n if (hashValue !== undefined && typeof hashValue !== 'string') {\n throw new TypeError('hashValue must be a string');\n }\n this.sourceHash = hashValue;\n this.dirty = true;\n }\n\n /**\n * Returns the hash value for the source of this resource.\n *\n * @returns {string|undefined} the hash value of this resource.\n */\n getSourceHash() {\n return this.sourceHash;\n }\n\n /**\n * Set the project of this resource. This is a string that gives the\n * id of the project for this resource.\n *\n * @param {string} project the project name to set for this resource\n */\n setProject(project) {\n this.project = project;\n this.dirty = true;\n }\n\n /**\n * Set the state of this resource. This is a string that gives the\n * stage of life of this resource. Currently, it can be one of \"new\",\n * \"translated\", or \"accepted\".\n *\n * @param {string} state the state of this resource\n * @throws {Error} if the state is invalid\n */\n setState(state) {\n if (!isValidState(state)) {\n throw new Error(`Attempt to set an invalid state on a resource: \"${state}\". Valid states are: ${VALID_STATES.join(', ')}, or custom states starting with \"x-\"`);\n }\n this.state = state;\n this.dirty = true;\n }\n\n /**\n * Return the original path to the file from which this resource was\n * originally extracted.\n *\n * @returns {string} the path to the file containing this resource\n */\n getPath() {\n return this.pathName;\n }\n\n /**\n * Return the translator's comment for this resource if there is\n * one, or undefined if not.\n *\n * @returns {String|undefined} the translator's comment for this resource\n * if the engineer put one in the code\n */\n getComment() {\n return this.comment;\n }\n\n /**\n * Set the translator's comment for this resource.\n *\n * @param {String|undefined} comment the translator's comment to set. Use\n * undefined to clear the comment\n */\n setComment(comment) {\n this.comment = comment;\n this.dirty = true;\n }\n\n /**\n * Get the \"do not translate\" flag for this resource.\n *\n * @returns {boolean} true means that the current resource should not\n * be translated, and false means it will be translated.\n */\n getDNT() {\n return typeof(this.dnt) === 'boolean' ? this.dnt : false;\n }\n\n /**\n * Set the \"do not translate\" flag for this resource.\n *\n * @param {boolean} flag set the dnt flag to this value\n */\n setDNT(flag) {\n if (typeof(flag) !== 'boolean') {\n throw new TypeError('value must be boolean');\n }\n this.dnt = flag;\n this.dirty = true;\n }\n\n /**\n * Return the database id if this resource has previously been saved in the\n * database.\n *\n * @returns {number|undefined} the database id if this resource has previously\n * been saved in the database, or undefined if it is has not\n */\n getId() {\n return this.id;\n }\n\n /**\n * Return the origin of this resource. The origin may be either the string\n * \"source\" or \"target\". Source origin resources are ones that are extracted\n * from the source code, whereas target ones are translations from the\n * translators.\n *\n * @returns {string} the origin of this resource\n */\n getOrigin() {\n return this.origin;\n }\n\n /**\n * Return the localize flag of this resource.\n * This flag indicates whether we should look up a translation for this resource.\n * When false, we should simply substitute the source back\n *\n * @returns {Boolean} the localize flag of this resource\n */\n getLocalize() {\n return this.localize;\n }\n\n /**\n * Return the name of the flavor for this resource, or undefined\n * for the \"main\" or default flavor.\n *\n * @return {String|undefined} the name of the flavor for this\n * resource or undefined for the main or default flavor\n */\n getFlavor() {\n return this.flavor;\n }\n\n /**\n * Return the path to the resource file that contains this resource.\n * This is different from the pathName property, which is the path to\n * the source file that this resource was extracted from. This property\n * is only used for resources from resource files, such as Android\n * string.xml files or xliff files. Otherwise, the property is undefined.\n *\n * @returns {string|undefined} the path to the resource file that contains\n * this resource, or undefined if this resource was not extracted from\n * a resource file\n */\n getResFile() {\n return this.resfile;\n }\n\n /**\n * Return true if the other resource represents the same resource as\n * the current one. The project, context, locale, key, flavor, and type must\n * match. Other fields such as the pathName, state, and comment fields are\n * ignored as minor variations.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n same(other) {\n if (!other) return false;\n\n const props = [\"project\", \"context\", \"sourceLocale\", \"targetLocale\", \"reskey\", \"resType\", \"flavor\"];\n for (let i = 0; i < props.length; i++) {\n if (this[props[i]] !== other[props[i]]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Escape text for writing to a database in a SQL command. This puts single\n * quotes around the string, and makes sure that all single quotes within\n * the string are escaped.\n *\n * @param {Object} str the item to escape\n * @returns {string} the escaped string\n */\n escapeText(str) {\n switch (typeof(str)) {\n case \"string\":\n // unescape first, then re-escape to make everything consistent\n return \"'\" + str.replace(/\\\\'/g, \"'\").replace(/'/g, \"\\\\'\") + \"'\";\n case \"undefined\":\n return \"NULL\";\n case \"boolean\":\n return str ? \"TRUE\" : \"FALSE\";\n default:\n if (str === null) {\n return \"NULL\";\n }\n return str.toString();\n }\n }\n\n /**\n * Add an instance of the same resource to the list of\n * instances. If the given resource matches the\n * current instance in all properties that affect the\n * possible translation, and differs from the current\n * instance by some property that does not affect\n * its translation, it will be added as an instance of\n * the same string. The following properties affect the\n * translation:\n *\n * <ul>\n * <li>context</li>\n * <li>datatype</li>\n * <li>dnt</li>\n * <li>flavor</li>\n * <li>project</li>\n * <li>reskey</li>\n * <li>resType</li>\n * <li>source</li>\n * <li>sourceHash</li>\n * <li>sourceArray</li>\n * <li>sourceLocale</li>\n * <li>targetLocale</li>\n * </ul>\n *\n * Differences in other properties, such as \"comment\" or\n * \"origin\" are considered instances of the same resource.\n *\n * If this method is given a resource that differs from\n * the current one by one of the above translation affecting\n * properties, it is not added to the list of instances. This\n * can be checked easily by calling the isInstance() method.\n *\n * @param {Resource} resource an instance of the current resource to\n * record\n * @returns {boolean} true if the instance was added, and\n * and false otherwise\n */\n addInstance(resource) {\n if (!this.isInstance(resource)) {\n return false;\n }\n const unique = this !== resource && this.instances.every(res => {\n return res !== resource;\n });\n if (!unique) {\n return false;\n }\n this.instances.push(resource);\n this.dirty = true;\n return true;\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource. This method returns true if all properties which\n * affect the possible translation match between the given and\n * the current resource.\n *\n * @param {Resource} resource a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (typeof(resource) !== 'object' || !(resource instanceof Resource)) {\n return false;\n }\n\n return translationImportant.every(prop => {\n return this[prop] === resource[prop];\n });\n }\n\n /**\n * Return the list of instances of the current resource.\n *\n * @returns {Array.<Resource>} the list of instances of\n * the current resource\n */\n getInstances() {\n return this.instances;\n }\n\n /**\n * Return true if this instance has been modified since its creation, and false otherwise.\n */\n isDirty() {\n return this.dirty\n }\n\n /**\n * Clear the dirty flag. This is used for example when the Resource was\n * written to disk and the modifications are already recorded, allowing\n * new modifications later.\n */\n clearDirty() {\n this.dirty = false;\n }\n\n /**\n * Return the location of the resource instance in the original file where it was read\n * from. This is usually an object containing a line and a char property which gives the\n * line number and character within that line where the representation of the resource\n * instance starts.\n *\n * @returns {Location|undefined} the location information, or undefined if no location\n * information is available\n */\n getLocation() {\n return this.location?.getLocation();\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @abstract\n * @returns {string} a unique hash key for this resource\n */\n hashKey() {\n throw new Error(\"hashKey() not implemented\");\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @abstract\n * @returns {string} a unique hash key for this resource with a cleaned string\n */\n cleanHashKey() {\n throw new Error(\"cleanHashKey() not implemented\");\n }\n}\n\nexport default Resource;\n"],"mappings":"y3CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB;AACA;AACA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A;AACA,OALI,GAAAS,GAAA,gBAAAkB,KAAA,CAMA,SAAA8D,YAAYA,CAAA,CAAG,CACX,KAAM,IAAI,CAAAzF,KAAK,CAAC,gCAAgC,CACpD,CAAC,WAAA0F,QAAA,CAAA3G,OAAA,YAGUY,QAAQ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _Resource2=_interopRequireDefault(require("./Resource.js"));var _utils=require("./utils.js");var _log4jsApi=_interopRequireDefault(require("@log4js-node/log4js-api"));function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t)}:p}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},_get.apply(null,arguments)}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}/*
2
2
  * ResourceString.js - represents an string in a resource file
3
3
  *
4
- * Copyright © 2022-2023 JEDLSoft
4
+ * Copyright © 2022-2023, 2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -64,29 +64,30 @@
64
64
  * @param {String} datatype the datatype of the string
65
65
  * @param {String} flavor the flavor of the string
66
66
  * @param {String} context the context of the string
67
+ * @param {String} sourceHash the sourceHash of the string
67
68
  * @static
68
69
  * @return {String} a hash key
69
70
  */},{key:"hashKey",value:/**
70
71
  * Return the a hash key that uniquely identifies this resource.
71
72
  *
72
73
  * @return {String} a unique hash key for this resource
73
- */function hashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
74
+ */function hashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
74
75
  * Return the a hash key that uniquely identifies the translation of
75
76
  * this resource to the given locale.
76
77
  *
77
78
  * @param {String} locale a locale spec of the desired translation
78
79
  * @return {String} a unique hash key for this resource
79
- */},{key:"hashKeyForTranslation",value:function hashKeyForTranslation(locale){return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
80
+ */},{key:"hashKeyForTranslation",value:function hashKeyForTranslation(locale){return ResourceString.hashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
80
81
  * Return the a hash key that uniquely identifies this resource, but cleaned
81
82
  *
82
83
  * @return {String} a unique hash key for this resource, but cleaned
83
- */},{key:"cleanHashKey",value:function cleanHashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
84
+ */},{key:"cleanHashKey",value:function cleanHashKey(){var locale=this.targetLocale||this.getSourceLocale();return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
84
85
  * Return the a hash key that uniquely identifies the translation of
85
86
  * this resource to the given locale, but cleaned
86
87
  *
87
88
  * @param {String} locale a locale spec of the desired translation
88
89
  * @return {String} a unique hash key for this resource's string
89
- */},{key:"cleanHashKeyForTranslation",value:function cleanHashKeyForTranslation(locale){return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context)}/**
90
+ */},{key:"cleanHashKeyForTranslation",value:function cleanHashKeyForTranslation(locale){return ResourceString.cleanHashKey(this.project,locale,this.reskey,this.datatype,this.flavor,this.context,this.sourceHash)}/**
90
91
  * Check if the given resource is an instance of the current
91
92
  * resource.
92
93
  *
@@ -95,7 +96,7 @@
95
96
  * @returns {boolean} true if this is an instance of
96
97
  * the current resource, false otherwise.
97
98
  */},{key:"isInstance",value:function isInstance(resource){if(!_superPropGet(ResourceString,"isInstance",this,3)([resource])){return false}// now check the properties specific to this resource subclass
98
- return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.source)}}],[{key:"hashKey",value:function hashKey(project,locale,reskey,datatype,flavor,context){var key=["rs",project,locale,reskey,datatype,flavor,context].join("_");logger.trace("Hashkey is "+key);return key}/**
99
+ return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.source)}}],[{key:"hashKey",value:function hashKey(project,locale,reskey,datatype,flavor,context,sourceHash){var key=["rs",project,locale,reskey,datatype,flavor,context,sourceHash].join("_");logger.trace("Hashkey is "+key);return key}/**
99
100
  * Calculate a resource key string for this class of resource given the
100
101
  * parameters.
101
102
  *
@@ -105,9 +106,10 @@ return(0,_utils.cleanString)(this.source)===(0,_utils.cleanString)(resource.sour
105
106
  * @param {String} datatype the datatype of the string
106
107
  * @param {String} flavor the flavor of the string
107
108
  * @param {String} context the context of the string
109
+ * @param {String} sourceHash the sourceHash of the string
108
110
  * @static
109
111
  * @return {String} a hash key
110
- */},{key:"cleanHashKey",value:function cleanHashKey(project,locale,reskey,datatype,flavor,context){var cleaned=reskey&&reskey.replace(/\s+/g," ").trim()||"";var key=["rs",project,locale,cleaned,datatype,flavor,context].join("_");logger.trace("CleanHashkey is "+key);return key}}])}(_Resource2["default"]);/**
112
+ */},{key:"cleanHashKey",value:function cleanHashKey(project,locale,reskey,datatype,flavor,context,sourceHash){var cleaned=reskey&&reskey.replace(/\s+/g," ").trim()||"";var key=["rs",project,locale,cleaned,datatype,flavor,context,sourceHash].join("_");logger.trace("CleanHashkey is "+key);return key}}])}(_Resource2["default"]);/**
111
113
  * The class of this kind of string resource.
112
114
  *
113
115
  * @static
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceString.js","names":["_Resource2","_interopRequireDefault","require","_utils","_log4jsApi","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","_superPropGet","p","_get","get","bind","_superPropBase","getOwnPropertyDescriptor","arguments","value","hasOwnProperty","setPrototypeOf","getPrototypeOf","__proto__","_inherits","create","_setPrototypeOf","logger","log4js","getLogger","ResourceString","_Resource","props","_this","source","text","target","origin","datatype","resType","resClass","sourceLocale","project","setSource","str","dirty","setTarget","size","clone","overrides","equals","other","same","hashKey","locale","targetLocale","getSourceLocale","reskey","flavor","context","hashKeyForTranslation","cleanHashKey","cleanHashKeyForTranslation","isInstance","resource","cleanString","join","trace","cleaned","replace","trim","Resource","_default","exports","module","default"],"sources":["../src/ResourceString.js"],"sourcesContent":["/*\n * ResourceString.js - represents an string in a resource file\n *\n * Copyright © 2022-2023 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Resource from \"./Resource.js\";\nimport { cleanString } from \"./utils.js\";\nimport log4js from \"@log4js-node/log4js-api\";\n\nconst logger = log4js.getLogger(\"tools-common.ResourceString\");\n\n/**\n * Represents a string resource from a resource file or\n * extracted from the code.\n */\nclass ResourceString extends Resource {\n /**\n * Construct a new ResourceString instance. The props may contain any\n * of properties from the Resource constructor and additionally,\n * these properties:\n *\n * <ul>\n * <li>source {String} - the source string associated with this key\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n */\n constructor(props) {\n super(props);\n\n if (props) {\n this.source = typeof(props.source) === 'string' ? props.source : props.text;\n this.target = props.target;\n }\n\n this.origin = this.origin || \"source\";\n this.datatype = this.datatype || \"plaintext\";\n this.resType = ResourceString.resClass;\n this.sourceLocale = this.sourceLocale || this.project && this.project.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source string written in the source\n * locale of this resource string.\n *\n * @param {String} str the source string\n */\n setSource(str) {\n if (typeof(str) !== 'string') return;\n this.source = str;\n this.dirty = true;\n }\n\n /**\n * Set the target string of this resource.\n *\n * @param {String} str the target string\n */\n setTarget(str) {\n if (typeof(str) !== 'string') return;\n this.target = str;\n this.dirty = true;\n }\n\n /**\n * Return the number of strings in this resource.\n *\n * @returns {number} the number of strings in this resource\n */\n size() {\n return 1;\n }\n\n /**\n * Clone this resource and override the properties with the given ones.\n *\n * @params {Object|undefined} overrides optional properties to override in\n * the cloned object\n * @returns {ResourceArray} a clone of this resource\n */\n clone(overrides) {\n const r = new ResourceString(this);\n if (overrides) {\n for (let p in overrides) {\n r[p] = overrides[p];\n }\n }\n return r;\n }\n\n /**\n * Return true if the other resource contains the exact same resource as\n * the current one. All fields must match.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n equals(other) {\n if (!other || !this.same(other)) return false;\n\n return this.source === other.source;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, locale, reskey, datatype, flavor, context) {\n const key = [\"rs\", project, locale, reskey, datatype, flavor, context].join(\"_\");\n logger.trace(\"Hashkey is \" + key);\n return key;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @static\n * @return {String} a hash key\n */\n static cleanHashKey(project, locale, reskey, datatype, flavor, context) {\n const cleaned = reskey && reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const key = [\"rs\", project, locale, cleaned, datatype, flavor, context].join(\"_\");\n logger.trace(\"CleanHashkey is \" + key);\n return key;\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @return {String} a unique hash key for this resource\n */\n hashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale.\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource\n */\n hashKeyForTranslation(locale) {\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but cleaned\n *\n * @return {String} a unique hash key for this resource, but cleaned\n */\n cleanHashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale, but cleaned\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource's string\n */\n cleanHashKeyForTranslation(locale) {\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource.\n *\n * @override\n * @param {Resource} a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (!super.isInstance(resource)) {\n return false;\n }\n\n // now check the properties specific to this resource subclass\n return cleanString(this.source) === cleanString(resource.source);\n }\n}\n\n/**\n * The class of this kind of string resource.\n *\n * @static\n * @const\n */\nResourceString.resClass = \"string\";\n\n\nexport default ResourceString;\n"],"mappings":"kXAmBA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,mBACA,IAAAC,MAAA,CAAAD,OAAA,eACA,IAAAE,UAAA,CAAAH,sBAAA,CAAAC,OAAA,6BAA6C,SAAAD,uBAAAI,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAN,CAAA,CAAAO,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAD,CAAA,CAAAE,MAAA,CAAAD,CAAA,QAAAE,CAAA,CAAAH,CAAA,CAAAC,CAAA,EAAAE,CAAA,CAAAC,UAAA,CAAAD,CAAA,CAAAC,UAAA,KAAAD,CAAA,CAAAE,YAAA,cAAAF,CAAA,GAAAA,CAAA,CAAAG,QAAA,KAAAC,MAAA,CAAAC,cAAA,CAAAf,CAAA,CAAAgB,cAAA,CAAAN,CAAA,CAAAO,GAAA,EAAAP,CAAA,YAAAQ,aAAAlB,CAAA,CAAAO,CAAA,CAAAC,CAAA,SAAAD,CAAA,EAAAD,iBAAA,CAAAN,CAAA,CAAAmB,SAAA,CAAAZ,CAAA,EAAAC,CAAA,EAAAF,iBAAA,CAAAN,CAAA,CAAAQ,CAAA,EAAAM,MAAA,CAAAC,cAAA,CAAAf,CAAA,cAAAa,QAAA,MAAAb,CAAA,UAAAgB,eAAAR,CAAA,MAAAY,CAAA,CAAAC,YAAA,CAAAb,CAAA,2BAAAc,OAAA,CAAAF,CAAA,EAAAA,CAAA,CAAAA,CAAA,aAAAC,aAAAb,CAAA,CAAAD,CAAA,eAAAe,OAA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,EAAI,EAAE,CAClE,GAAM,CAAAlF,GAAG,CAAG,CAAC,IAAI,CAAEsD,OAAO,CAAEY,MAAM,CAAEc,OAAO,CAAE9B,QAAQ,CAAEoB,MAAM,CAAEC,OAAO,CAAC,CAACO,IAAI,CAAC,GAAG,CAAC,CACjFvC,MAAM,CAACwC,KAAK,CAAC,kBAAkB,CAAG/E,GAAG,CAAC,CACtC,MAAO,CAAAA,GACX,CAAC,KA9HwBmF,qBAAQ,EA6LrC;AACA;AACA;AACA;AACA;AACA,GACAzC,cAAc,CAACU,QAAQ,CAAG,QAAQ,CAAC,IAAAgC,QAAA,CAAAC,OAAA,YAGpB3C,cAAc,CAAA4C,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"ResourceString.js","names":["_Resource2","_interopRequireDefault","require","_utils","_log4jsApi","e","__esModule","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","o","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","prototype","i","_toPrimitive","_typeof","Symbol","toPrimitive","call","String","Number","_callSuper","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","_assertThisInitialized","ReferenceError","Boolean","valueOf","_superPropGet","p","_get","get","bind","_superPropBase","getOwnPropertyDescriptor","arguments","value","hasOwnProperty","setPrototypeOf","getPrototypeOf","__proto__","_inherits","create","_setPrototypeOf","logger","log4js","getLogger","ResourceString","_Resource","props","_this","source","text","target","origin","datatype","resType","resClass","sourceLocale","project","setSource","str","dirty","setTarget","size","clone","overrides","equals","other","same","hashKey","locale","targetLocale","getSourceLocale","reskey","flavor","context","sourceHash","hashKeyForTranslation","cleanHashKey","cleanHashKeyForTranslation","isInstance","resource","cleanString","join","trace","cleaned","replace","trim","Resource","_default","exports","module","default"],"sources":["../src/ResourceString.js"],"sourcesContent":["/*\n * ResourceString.js - represents an string in a resource file\n *\n * Copyright © 2022-2023, 2026 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Resource from \"./Resource.js\";\nimport { cleanString } from \"./utils.js\";\nimport log4js from \"@log4js-node/log4js-api\";\n\nconst logger = log4js.getLogger(\"tools-common.ResourceString\");\n\n/**\n * Represents a string resource from a resource file or\n * extracted from the code.\n */\nclass ResourceString extends Resource {\n /**\n * Construct a new ResourceString instance. The props may contain any\n * of properties from the Resource constructor and additionally,\n * these properties:\n *\n * <ul>\n * <li>source {String} - the source string associated with this key\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\n */\n constructor(props) {\n super(props);\n\n if (props) {\n this.source = typeof(props.source) === 'string' ? props.source : props.text;\n this.target = props.target;\n }\n\n this.origin = this.origin || \"source\";\n this.datatype = this.datatype || \"plaintext\";\n this.resType = ResourceString.resClass;\n this.sourceLocale = this.sourceLocale || this.project && this.project.sourceLocale || \"en-US\";\n }\n\n /**\n * Set the source string written in the source\n * locale of this resource string.\n *\n * @param {String} str the source string\n */\n setSource(str) {\n if (typeof(str) !== 'string') return;\n this.source = str;\n this.dirty = true;\n }\n\n /**\n * Set the target string of this resource.\n *\n * @param {String} str the target string\n */\n setTarget(str) {\n if (typeof(str) !== 'string') return;\n this.target = str;\n this.dirty = true;\n }\n\n /**\n * Return the number of strings in this resource.\n *\n * @returns {number} the number of strings in this resource\n */\n size() {\n return 1;\n }\n\n /**\n * Clone this resource and override the properties with the given ones.\n *\n * @params {Object|undefined} overrides optional properties to override in\n * the cloned object\n * @returns {ResourceArray} a clone of this resource\n */\n clone(overrides) {\n const r = new ResourceString(this);\n if (overrides) {\n for (let p in overrides) {\n r[p] = overrides[p];\n }\n }\n return r;\n }\n\n /**\n * Return true if the other resource contains the exact same resource as\n * the current one. All fields must match.\n *\n * @param {Resource} other another resource to test against the current one\n * @returns {boolean} true if these represent the same resource, false otherwise\n */\n equals(other) {\n if (!other || !this.same(other)) return false;\n\n return this.source === other.source;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @param {String} sourceHash the sourceHash of the string\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {\n const key = [\"rs\", project, locale, reskey, datatype, flavor, context, sourceHash].join(\"_\");\n logger.trace(\"Hashkey is \" + key);\n return key;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @param {String} project the project of the string\n * @param {String} locale the locale of the string\n * @param {String} reskey the key of the string\n * @param {String} datatype the datatype of the string\n * @param {String} flavor the flavor of the string\n * @param {String} context the context of the string\n * @param {String} sourceHash the sourceHash of the string\n * @static\n * @return {String} a hash key\n */\n static cleanHashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {\n const cleaned = reskey && reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const key = [\"rs\", project, locale, cleaned, datatype, flavor, context, sourceHash].join(\"_\");\n logger.trace(\"CleanHashkey is \" + key);\n return key;\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource.\n *\n * @return {String} a unique hash key for this resource\n */\n hashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale.\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource\n */\n hashKeyForTranslation(locale) {\n return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but cleaned\n *\n * @return {String} a unique hash key for this resource, but cleaned\n */\n cleanHashKey() {\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Return the a hash key that uniquely identifies the translation of\n * this resource to the given locale, but cleaned\n *\n * @param {String} locale a locale spec of the desired translation\n * @return {String} a unique hash key for this resource's string\n */\n cleanHashKeyForTranslation(locale) {\n return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);\n }\n\n /**\n * Check if the given resource is an instance of the current\n * resource.\n *\n * @override\n * @param {Resource} a resource to check\n * @returns {boolean} true if this is an instance of\n * the current resource, false otherwise.\n */\n isInstance(resource) {\n if (!super.isInstance(resource)) {\n return false;\n }\n\n // now check the properties specific to this resource subclass\n return cleanString(this.source) === cleanString(resource.source);\n }\n}\n\n/**\n * The class of this kind of string resource.\n *\n * @static\n * @const\n */\nResourceString.resClass = \"string\";\n\n\nexport default ResourceString;\n"],"mappings":"kXAmBA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,mBACA,IAAAC,MAAA,CAAAD,OAAA,eACA,IAAAE,UAAA,CAAAH,sBAAA,CAAAC,OAAA,6BAA6C,SAAAD,uBAAAI,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAN,CAAA,CAAAO,CAAA,UAAAC,CAAA,GAAAA,CAAA,CAAAD,CAAA,CAAAE,MAAA,CAAAD,CAAA,QAAAE,CAAA,CAAAH,CAAA,CAAAC,CAAA,EAAAE,CAAA,CAAAC,UAAA,CAAAD,CAAA,CAAAC,UAAA,KAAAD,C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exports,"__esModule",{value:true});exports["default"]=void 0;var _ilibXliff=require("ilib-xliff");var _log4jsApi=_interopRequireDefault(require("@log4js-node/log4js-api"));var _ResourceString=_interopRequireDefault(require("./ResourceString.js"));var _ResourceArray=_interopRequireDefault(require("./ResourceArray.js"));var _ResourcePlural=_interopRequireDefault(require("./ResourcePlural.js"));var _TranslationSet=_interopRequireDefault(require("./TranslationSet.js"));var _Location=_interopRequireDefault(require("./Location.js"));var _utils=require("./utils.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}/*
2
- * Xliff.js - convert an Xliff file into a set of resources and vice versa
2
+ * ResourceXliff.js - convert an ResourceXliff file into a set of resources and vice versa
3
3
  *
4
- * Copyright © 2022-2023, 2025 JEDLSoft
4
+ * Copyright © 2022-2023, 2025-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -49,14 +49,14 @@ return res.comment}}json.pluralForm=form;json.pluralFormOther=res.getKey();retur
49
49
  * @param {Resource} res the resource to convert
50
50
  * @returns {Array.<TranslationUnit>} an array of translation units
51
51
  * that represent the resource
52
- */return _createClass(ResourceXliff,[{key:"convertResource",value:function convertResource(res){var units=[],tu;try{switch(res.resType){case"string":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),sourceLocale:res.getSourceLocale(),source:res.getSource(),targetLocale:res.getTargetLocale(),target:res.getTarget(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation(),metadata:res.metadata});units.push(tu);break;case"array":var sarr=res.getSource();var tarr=res.getTarget();tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation()});for(var j=0;j<sarr.length;j++){// only output array items that have a translation
53
- if(sarr[j]){var newtu=tu.clone();newtu.source=sarr[j];newtu.ordinal=j;if(tarr&&j<tarr.length&&tarr[j]){newtu.target=tarr[j]}newtu.ordinal=j;units.push(newtu)}else if(tarr[j]){logger.warn("Translated array "+res.getKey()+" has no source string at index "+j+". Cannot translate. Resource is: "+JSON.stringify(res,undefined,4))}}break;case"plural":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,location:res.getLocation(),translate:!res.getDNT()});var sp=res.getSource();var tp=res.getTarget();if(!tp||(0,_utils.isEmpty)(tp)){for(var p in sp){var _newtu=tu.clone();_newtu.source=sp[p];_newtu.quantity=p;_newtu.comment=generatePluralComment(res,sp,p);units.push(_newtu)}}else{for(var _p in tp){var _newtu2=tu.clone();_newtu2.source=sp[_p]||sp.other;_newtu2.target=tp[_p];_newtu2.quantity=_p;_newtu2.comment=generatePluralComment(res,sp,_p);units.push(_newtu2)}}break}}catch(e){logger.warn(e);logger.warn(JSON.stringify(res));logger.warn("Skipping that resource.")}return units}/**
52
+ */return _createClass(ResourceXliff,[{key:"convertResource",value:function convertResource(res){var units=[],tu;try{switch(res.resType){case"string":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),sourceLocale:res.getSourceLocale(),source:res.getSource(),targetLocale:res.getTargetLocale(),target:res.getTarget(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation(),metadata:res.metadata,autoKey:res.getAutoKey()});units.push(tu);break;case"array":var sarr=res.getSource();var tarr=res.getTarget();tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,comment:res.comment,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,translate:!res.getDNT(),location:res.getLocation(),autoKey:res.getAutoKey()});for(var j=0;j<sarr.length;j++){// only output array items that have a translation
53
+ if(sarr[j]){var newtu=tu.clone();newtu.source=sarr[j];newtu.ordinal=j;if(tarr&&j<tarr.length&&tarr[j]){newtu.target=tarr[j]}newtu.ordinal=j;units.push(newtu)}else if(tarr[j]){logger.warn("Translated array "+res.getKey()+" has no source string at index "+j+". Cannot translate. Resource is: "+JSON.stringify(res,undefined,4))}}break;case"plural":tu=new _ilibXliff.TranslationUnit({project:res.project,key:res.getKey(),file:res.getPath(),source:" ",sourceLocale:res.getSourceLocale(),targetLocale:res.getTargetLocale(),state:res.getState(),id:res.getId(),translated:true,context:res.context,resType:res.resType,datatype:res.datatype,flavor:res.getFlavor?res.getFlavor():undefined,location:res.getLocation(),translate:!res.getDNT(),autoKey:res.getAutoKey()});var sp=res.getSource();var tp=res.getTarget();if(!tp||(0,_utils.isEmpty)(tp)){for(var p in sp){var _newtu=tu.clone();_newtu.source=sp[p];_newtu.quantity=p;_newtu.comment=generatePluralComment(res,sp,p);units.push(_newtu)}}else{for(var _p in tp){var _newtu2=tu.clone();_newtu2.source=sp[_p]||sp.other;_newtu2.target=tp[_p];_newtu2.quantity=_p;_newtu2.comment=generatePluralComment(res,sp,_p);units.push(_newtu2)}}break}}catch(e){logger.warn(e);logger.warn(JSON.stringify(res));logger.warn("Skipping that resource.")}return units}/**
54
54
  * Convert a translation unit to a new loctool resource.
55
55
  *
56
56
  * @private
57
57
  * @param {TranslationUnit} tu the translation to convert
58
58
  * @return {Resource} the corresponding resource
59
- */},{key:"convertTransUnit",value:function convertTransUnit(tu){var res;switch(tu.resType){default:res=new _ResourceString["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:tu.source,targetLocale:tu.targetLocale,context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile,metadata:tu.metadata});if(tu.target){res.setTarget(tu.target)}break;case"array":var arr=[];arr[tu.ordinal]=tu.source;res=new _ResourceArray["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:arr,targetLocale:tu.targetLocale,target:[],context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetItem(tu.ordinal,tu.target)}break;case"plural":var strings={};strings[tu.quantity]=tu.source;res=new _ResourcePlural["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:strings,targetLocale:tu.targetLocale,target:{},context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetPlural(tu.quantity,tu.target)}break}if(typeof tu.translate==="boolean"){res.setDNT(!tu.translate)}return res}},{key:"getPath",value:function getPath(){return this.path}},{key:"setPath",value:function setPath(newPath){this.path=newPath}/**
59
+ */},{key:"convertTransUnit",value:function convertTransUnit(tu){var res;switch(tu.resType){default:res=new _ResourceString["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:tu.source,targetLocale:tu.targetLocale,context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile,metadata:tu.metadata,sourceHash:tu.sourceHash,autoKey:tu.autoKey});if(tu.target){res.setTarget(tu.target)}break;case"array":var arr=[];arr[tu.ordinal]=tu.source;res=new _ResourceArray["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:arr,targetLocale:tu.targetLocale,target:[],context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetItem(tu.ordinal,tu.target)}break;case"plural":var strings={};strings[tu.quantity]=tu.source;res=new _ResourcePlural["default"]({pathName:tu.file,project:tu.project,id:tu.id,key:tu.key,sourceLocale:tu.sourceLocale,source:strings,targetLocale:tu.targetLocale,target:{},context:tu.context,comment:tu.comment,resType:tu.resType,datatype:tu.datatype,state:tu.state,flavor:tu.flavor,location:new _Location["default"](tu.location),resfile:tu.resfile});if(tu.target){res.addTargetPlural(tu.quantity,tu.target)}break}if(typeof tu.translate==="boolean"){res.setDNT(!tu.translate)}return res}},{key:"getPath",value:function getPath(){return this.path}},{key:"setPath",value:function setPath(newPath){this.path=newPath}/**
60
60
  * Parse the given xml and convert it into a set of resources.
61
61
  *
62
62
  * @param {string} xml the contents of the xliff file to parse
@@ -1 +1 @@
1
- {"version":3,"file":"ResourceXliff.js","names":["_ilibXliff","require","_log4jsApi","_interopRequireDefault","_ResourceString","_ResourceArray","_ResourcePlural","_TranslationSet","_Location","_utils","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","i","_toPrimitive","toPrimitive","call","String","Number","logger","log4js","getLogger","generatePluralComment","res","sourcePlurals","form","json","comment","JSON","parse","pluralForm","pluralFormOther","getKey","stringify","ResourceXliff","options","_options$xliff","_this","copyright","path","sourceLocale","project","allowDups","style","version","xliff","Xliff","ts","TranslationSet","getTranslationUnits","translationUnits","forEach","tu","add","convertTransUnit","value","convertResource","units","resType","TranslationUnit","file","getPath","getSourceLocale","source","getSource","targetLocale","getTargetLocale","target","getTarget","state","getState","id","getId","translated","context","datatype","flavor","getFlavor","undefined","translate","getDNT","location","getLocation","metadata","push","sarr","tarr","j","newtu","clone","ordinal","warn","sp","tp","isEmpty","p","quantity","other","ResourceString","pathName","Location","resfile","setTarget","arr","ResourceArray","addTargetItem","strings","ResourcePlural","addTargetPlural","setDNT","setPath","newPath","xml","tuList","deserialize","get","hashKey","addSourceItem","addSourcePlural","getResources","criteria","getAll","getBy","addResource","getText","size","resources","initialLength","instances","getInstances","concat","sort","left","right","index","clear","addTranslationUnits","serialize","getLines","getVersion","_default","exports","module","default"],"sources":["../src/ResourceXliff.js"],"sourcesContent":["/*\n * Xliff.js - convert an Xliff file into a set of resources and vice versa\n *\n * Copyright © 2022-2023, 2025 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Xliff, TranslationUnit } from 'ilib-xliff';\nimport log4js from \"@log4js-node/log4js-api\";\n\nimport ResourceString from './ResourceString.js';\nimport ResourceArray from './ResourceArray.js';\nimport ResourcePlural from './ResourcePlural.js';\nimport TranslationSet from './TranslationSet.js';\nimport Location from './Location.js';\nimport { isEmpty } from './utils.js';\n\nconst logger = log4js.getLogger(\"tools-common.ResourceXliff\");\n\nfunction generatePluralComment(res, sourcePlurals, form) {\n var json = {};\n\n if (res.comment) {\n try {\n // see if its json already. If so, we'll add to it\n json = JSON.parse(res.comment);\n } catch (e) {\n // not json, so just return it as is\n return res.comment;\n }\n }\n\n json.pluralForm = form;\n json.pluralFormOther = res.getKey();\n\n return JSON.stringify(json);\n}\n\n/**\n * @class a class that represents resources as an xliff file.\n */\nclass ResourceXliff {\n /**\n * Construct a new resource xliff instance. Operation of the instance\n * is controlled via the options. The options may be undefined, which represents a new,\n * clean Xliff instance.\n *\n * @constructor\n * @param {Object|undefined} options options to\n * initialize the file, or undefined for a new empty file\n * @param {string} [options.path] the path to the xliff file on disk\n * @param {string} [options.tool-id] the id of the tool that saved this xliff file\n * @param {string} [options.tool-name] the full name of the tool that saved this xliff file\n * @param {string} [options.tool-version] the version of the tool that save this xliff file\n * @param {string} [options.tool-company] the name of the company that made this tool\n * @param {string} [options.copyright] a copyright notice that you would like included into the xliff file\n * @param {string} [options.sourceLocale] specify the default source locale if a resource doesn't have a locale itself\n * @param {string} [options.allowDups] allow duplicate resources in the xliff. By default, dups are\n * filtered out. This option allows you to have trans-units that represent instances of the\n * same resource in the file with different metadata. For example, two instances of a\n * resource may have different comments which may both be useful to translators or\n * two instances of the same resource may have been extracted from different source files.\n * @param {string} [options.version] The version of xliff that will be produced by this instance. This\n * may be either \"1.2\" or \"2.0\"\n * @param {Xliff} [options.xliff] The xliff instance to use for this resource xliff instance.\n */\n constructor(options) {\n if (options) {\n this[\"tool-id\"] = options[\"tool-id\"];\n this[\"tool-name\"] = options[\"tool-name\"];\n this[\"tool-version\"] = options[\"tool-version\"];\n this[\"tool-company\"] = options[\"tool-company\"];\n this.copyright = options.copyright;\n this.path = options.path;\n this.sourceLocale = options.sourceLocale || \"en-US\";\n this.project = options.project;\n this.allowDups = options.allowDups;\n this.style = options.style || \"standard\";\n if (typeof(options.version) !== 'undefined') {\n this.version = options.version;\n }\n }\n this.sourceLocale = this.sourceLocale || \"en-US\";\n this.xliff = options?.xliff ?? new Xliff(options);\n this.ts = new TranslationSet(this.sourceLocale);\n\n if (this.xliff.getTranslationUnits().length) {\n const translationUnits = this.xliff.getTranslationUnits();\n translationUnits.forEach(tu => {\n this.ts.add(this.convertTransUnit(tu));\n });\n }\n }\n\n /**\n * Convert a resource into one or more translation units.\n *\n * @private\n * @param {Resource} res the resource to convert\n * @returns {Array.<TranslationUnit>} an array of translation units\n * that represent the resource\n */\n convertResource(res) {\n let units = [], tu;\n\n try {\n switch (res.resType) {\n case \"string\":\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n sourceLocale: res.getSourceLocale(),\n source: res.getSource(),\n targetLocale: res.getTargetLocale(),\n target: res.getTarget(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n comment: res.comment,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n translate: !res.getDNT(),\n location: res.getLocation(),\n metadata: res.metadata\n });\n units.push(tu);\n break;\n\n case \"array\":\n const sarr = res.getSource();\n let tarr = res.getTarget();\n\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n source: \" \",\n sourceLocale: res.getSourceLocale(),\n targetLocale: res.getTargetLocale(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n comment: res.comment,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n translate: !res.getDNT(),\n location: res.getLocation()\n });\n\n for (let j = 0; j < sarr.length; j++) {\n // only output array items that have a translation\n if (sarr[j]) {\n const newtu = tu.clone();\n newtu.source = sarr[j];\n newtu.ordinal = j;\n\n if (tarr && j < tarr.length && tarr[j]) {\n newtu.target = tarr[j];\n }\n\n newtu.ordinal = j;\n units.push(newtu);\n } else if (tarr[j]) {\n logger.warn(\"Translated array \" + res.getKey() + \" has no source string at index \" + j + \". Cannot translate. Resource is: \" + JSON.stringify(res, undefined, 4));\n }\n }\n break;\n\n case \"plural\":\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n source: \" \",\n sourceLocale: res.getSourceLocale(),\n targetLocale: res.getTargetLocale(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n location: res.getLocation(),\n translate: !res.getDNT()\n });\n\n const sp = res.getSource();\n const tp = res.getTarget();\n\n if (!tp || isEmpty(tp)) {\n for (let p in sp) {\n const newtu = tu.clone();\n newtu.source = sp[p];\n newtu.quantity = p;\n newtu.comment = generatePluralComment(res, sp, p);\n units.push(newtu);\n }\n } else {\n for (let p in tp) {\n const newtu = tu.clone();\n newtu.source = sp[p] || sp.other;\n newtu.target = tp[p];\n newtu.quantity = p;\n newtu.comment = generatePluralComment(res, sp, p);\n units.push(newtu);\n }\n }\n break;\n }\n } catch (e) {\n logger.warn(e);\n logger.warn(JSON.stringify(res));\n logger.warn(\"Skipping that resource.\");\n }\n\n return units;\n }\n\n /**\n * Convert a translation unit to a new loctool resource.\n *\n * @private\n * @param {TranslationUnit} tu the translation to convert\n * @return {Resource} the corresponding resource\n */\n convertTransUnit(tu) {\n let res;\n\n switch (tu.resType) {\n default:\n res = new ResourceString({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: tu.source,\n targetLocale: tu.targetLocale,\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile,\n metadata: tu.metadata\n });\n\n if (tu.target) {\n res.setTarget(tu.target);\n }\n break;\n\n case \"array\":\n var arr = [];\n arr[tu.ordinal] = tu.source;\n res = new ResourceArray({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: arr,\n targetLocale: tu.targetLocale,\n target: [],\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile\n });\n\n if (tu.target) {\n res.addTargetItem(tu.ordinal, tu.target);\n }\n break;\n\n case \"plural\":\n var strings = {};\n strings[tu.quantity] = tu.source;\n res = new ResourcePlural({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: strings,\n targetLocale: tu.targetLocale,\n target: {},\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile\n });\n\n if (tu.target) {\n res.addTargetPlural(tu.quantity, tu.target);\n }\n break;\n }\n\n if (typeof(tu.translate) === \"boolean\") {\n res.setDNT(!tu.translate);\n }\n\n return res;\n }\n\n getPath() {\n return this.path;\n }\n\n setPath(newPath) {\n this.path = newPath;\n }\n\n /**\n * Parse the given xml and convert it into a set of resources.\n *\n * @param {string} xml the contents of the xliff file to parse\n * @returns {TranslationSet} the translation set that represents\n * the resources in the xliff file\n */\n parse(xml) {\n const tuList = this.xliff.deserialize(xml, this.path);\n let res;\n\n if (tuList) {\n for (var j = 0; j < tuList.length; j++) {\n const tu = tuList[j];\n\n switch (tu.resType) {\n default:\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n break;\n\n case \"array\":\n res = this.ts.get(ResourceArray.hashKey(tu.project, tu.context, tu.targetLocale || tu.sourceLocale, tu.key));\n if (res) {\n // if it already exists, amend the existing resource instead of creating a new one\n res.addSourceItem(tu.ordinal, tu.source);\n if (tu.target) {\n res.addTargetItem(tu.ordinal, tu.target);\n }\n } else {\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n }\n break;\n\n case \"plural\":\n res = this.ts.get(ResourcePlural.hashKey(tu.project, tu.context, tu.targetLocale || tu.sourceLocale, tu.key));\n if (res) {\n // if it already exists, amend the existing resource instead of creating a new one\n res.addSourcePlural(tu.quantity, tu.source);\n if (tu.target) {\n res.addTargetPlural(tu.quantity, tu.target);\n }\n } else {\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n }\n break;\n }\n }\n }\n\n return this.ts;\n }\n\n getResources(criteria) {\n if (!criteria) return this.ts.getAll();\n return this.ts.getBy(criteria);\n }\n\n addResource(res) {\n if (!res) return;\n\n if (res.getTargetLocale() === this.sourceLocale || res.getTargetLocale() === \"en\") {\n // don't add this one... cannot translate TO the source locale!\n return;\n }\n\n this.ts.add(res);\n }\n\n getText() {\n let units = [];\n\n if (this.ts.size() > 0) {\n // first convert the resources into translation units\n let resources = this.ts.getAll();\n\n if (this.allowDups) {\n // only look at the initial set of resources\n const initialLength = resources.length;\n for (let i = 0; i < initialLength; i++) {\n const res = resources[i];\n const instances = res.getInstances();\n if (instances && instances.length) {\n resources = resources.concat(instances);\n resources[i].instances = undefined;\n }\n }\n }\n resources.sort(function(left, right) {\n if (typeof(left.index) === 'number' && typeof(right.index) === 'number') {\n return left.index - right.index;\n }\n if (typeof(left.id) === 'number' && typeof(right.id) === 'number') {\n return left.id - right.id;\n }\n // no ids and no indexes? Well, then don't rearrange\n return 0;\n });\n\n // now add the translations\n for (var i = 0; i < resources.length; i++) {\n var res = resources[i];\n if (res.getTargetLocale() !== this.sourceLocale) {\n units = units.concat(this.convertResource(res));\n }\n }\n }\n\n // start with no translation units in it\n this.xliff.clear();\n this.xliff.addTranslationUnits(units);\n\n return this.xliff.serialize(true);\n }\n\n /**\n * Return the number of lines in the xml representation of this file.\n *\n * @returns {Number} the number of lines in the xml\n */\n getLines() {\n return this.xliff.getLines();\n }\n\n /**\n * Return the number of resources in this resource xliff file.\n * @returns {Number} the number of resources in this file\n */\n size() {\n return this.ts.size();\n }\n\n /**\n * Get the version number of this file. Currently, it only supports\n * xliff v1.2 and v2.0.\n * @returns {String} the version number of the file\n */\n getVersion() {\n return this.version;\n }\n}\n\nexport default ResourceXliff;\n"],"mappings":"gGAmBA,IAAAA,UAAA,CAAAC,OAAA,eACA,IAAAC,UAAA,CAAAC,sBAAA,CAAAF,OAAA,6BAEA,IAAAG,eAAA,CAAAD,sBAAA,CAAAF,OAAA,yBACA,IAAAI,cAAA,CAAAF,sBAAA,CAAAF,OAAA,wBACA,IAAAK,eAAA,CAAAH,sBAAA,CAAAF,OAAA,yBACA,IAAAM,eAAA,CAAAJ,sBAAA,CAAAF,OAAA,yBACA,IAAAO,SAAA,CAAAL,sBAAA,CAAAF,OAAA,mBACA,IAAAQ,MAAA,CAAAR,OAAA,eAAqC,SAAAE,uBAAAO,CAAA,SAAAA,CAAA,EAAAA,CAAA,CAAAC,UAAA,CAAAD,CAAA,YAAAA,CAAA,WAAAE,QAAAC,CAAA,mCAAAD,OAAA,oBAAAE,MAAA,mBAAAA,MAAA,CAAAC,QAAA,UAAAF,CAAA,gBAAAA,CAAA,WAAAA,CAAA,SAAAA,CAAA,qBAAAC,MAAA,EAAAD,CAAA,CAAAG,WAAA,GAAAF,MAAA,EAAAD,CAAA,GAAAC,MAAA,CAAAG,SAAA,iBAAAJ,CAAA,EAAAD,OAAA,CAAAC,CAAA,WAAAK,gBAAAC,CAAA,CAAAC,CAAA,OAAAD,CAAA,YAAAC,CAAA,YAAAC,SAAA,+CAAAC,kBAAAZ,CAAA,CAAAa,CAAA,UAAAC,CAA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AEA;AACJ;AACA;AACA;AACA,OAJI,GAAA9H,GAAA,YAAA4C,KAAA,CAKA,SAAAmF,QAAQA,CAAA,CAAG,CACP,MAAO,KAAI,CAAC7F,KAAK,CAAC6F,QAAQ,CAAC,CAC/B,CAEA;AACJ;AACA;AACA,OAHI,GAAA/H,GAAA,QAAA4C,KAAA,CAIA,SAAAsE,IAAIA,CAAA,CAAG,CACH,MAAO,KAAI,CAAC9E,EAAE,CAAC8E,IAAI,CAAC,CACxB,CAEA;AACJ;AACA;AACA;AACA,OAJI,GAAAlH,GAAA,cAAA4C,KAAA,CAKA,SAAAoF,UAAUA,CAAA,CAAG,CACT,MAAO,KAAI,CAAC/F,OAChB,CAAC,WAAAgG,QAAA,CAAAC,OAAA,YAGU3G,aAAa,CAAA4G,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"ResourceXliff.js","names":["_ilibXliff","require","_log4jsApi","_interopRequireDefault","_ResourceString","_ResourceArray","_ResourcePlural","_TranslationSet","_Location","_utils","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_classCallCheck","a","n","TypeError","_defineProperties","r","t","length","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","i","_toPrimitive","toPrimitive","call","String","Number","logger","log4js","getLogger","generatePluralComment","res","sourcePlurals","form","json","comment","JSON","parse","pluralForm","pluralFormOther","getKey","stringify","ResourceXliff","options","_options$xliff","_this","copyright","path","sourceLocale","project","allowDups","style","version","xliff","Xliff","ts","TranslationSet","getTranslationUnits","translationUnits","forEach","tu","add","convertTransUnit","value","convertResource","units","resType","TranslationUnit","file","getPath","getSourceLocale","source","getSource","targetLocale","getTargetLocale","target","getTarget","state","getState","id","getId","translated","context","datatype","flavor","getFlavor","undefined","translate","getDNT","location","getLocation","metadata","autoKey","getAutoKey","push","sarr","tarr","j","newtu","clone","ordinal","warn","sp","tp","isEmpty","p","quantity","other","ResourceString","pathName","Location","resfile","sourceHash","setTarget","arr","ResourceArray","addTargetItem","strings","ResourcePlural","addTargetPlural","setDNT","setPath","newPath","xml","tuList","deserialize","get","hashKey","addSourceItem","addSourcePlural","getResources","criteria","getAll","getBy","addResource","getText","size","resources","initialLength","instances","getInstances","concat","sort","left","right","index","clear","addTranslationUnits","serialize","getLines","getVersion","_default","exports","module","default"],"sources":["../src/ResourceXliff.js"],"sourcesContent":["/*\n * ResourceXliff.js - convert an ResourceXliff file into a set of resources and vice versa\n *\n * Copyright © 2022-2023, 2025-2026 JEDLSoft\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Xliff, TranslationUnit } from 'ilib-xliff';\nimport log4js from \"@log4js-node/log4js-api\";\n\nimport ResourceString from './ResourceString.js';\nimport ResourceArray from './ResourceArray.js';\nimport ResourcePlural from './ResourcePlural.js';\nimport TranslationSet from './TranslationSet.js';\nimport Location from './Location.js';\nimport { isEmpty } from './utils.js';\n\nconst logger = log4js.getLogger(\"tools-common.ResourceXliff\");\n\nfunction generatePluralComment(res, sourcePlurals, form) {\n var json = {};\n\n if (res.comment) {\n try {\n // see if its json already. If so, we'll add to it\n json = JSON.parse(res.comment);\n } catch (e) {\n // not json, so just return it as is\n return res.comment;\n }\n }\n\n json.pluralForm = form;\n json.pluralFormOther = res.getKey();\n\n return JSON.stringify(json);\n}\n\n/**\n * @class a class that represents resources as an xliff file.\n */\nclass ResourceXliff {\n /**\n * Construct a new resource xliff instance. Operation of the instance\n * is controlled via the options. The options may be undefined, which represents a new,\n * clean Xliff instance.\n *\n * @constructor\n * @param {Object|undefined} options options to\n * initialize the file, or undefined for a new empty file\n * @param {string} [options.path] the path to the xliff file on disk\n * @param {string} [options.tool-id] the id of the tool that saved this xliff file\n * @param {string} [options.tool-name] the full name of the tool that saved this xliff file\n * @param {string} [options.tool-version] the version of the tool that save this xliff file\n * @param {string} [options.tool-company] the name of the company that made this tool\n * @param {string} [options.copyright] a copyright notice that you would like included into the xliff file\n * @param {string} [options.sourceLocale] specify the default source locale if a resource doesn't have a locale itself\n * @param {string} [options.allowDups] allow duplicate resources in the xliff. By default, dups are\n * filtered out. This option allows you to have trans-units that represent instances of the\n * same resource in the file with different metadata. For example, two instances of a\n * resource may have different comments which may both be useful to translators or\n * two instances of the same resource may have been extracted from different source files.\n * @param {string} [options.version] The version of xliff that will be produced by this instance. This\n * may be either \"1.2\" or \"2.0\"\n * @param {Xliff} [options.xliff] The xliff instance to use for this resource xliff instance.\n */\n constructor(options) {\n if (options) {\n this[\"tool-id\"] = options[\"tool-id\"];\n this[\"tool-name\"] = options[\"tool-name\"];\n this[\"tool-version\"] = options[\"tool-version\"];\n this[\"tool-company\"] = options[\"tool-company\"];\n this.copyright = options.copyright;\n this.path = options.path;\n this.sourceLocale = options.sourceLocale || \"en-US\";\n this.project = options.project;\n this.allowDups = options.allowDups;\n this.style = options.style || \"standard\";\n if (typeof(options.version) !== 'undefined') {\n this.version = options.version;\n }\n }\n this.sourceLocale = this.sourceLocale || \"en-US\";\n this.xliff = options?.xliff ?? new Xliff(options);\n this.ts = new TranslationSet(this.sourceLocale);\n\n if (this.xliff.getTranslationUnits().length) {\n const translationUnits = this.xliff.getTranslationUnits();\n translationUnits.forEach(tu => {\n this.ts.add(this.convertTransUnit(tu));\n });\n }\n }\n\n /**\n * Convert a resource into one or more translation units.\n *\n * @private\n * @param {Resource} res the resource to convert\n * @returns {Array.<TranslationUnit>} an array of translation units\n * that represent the resource\n */\n convertResource(res) {\n let units = [], tu;\n\n try {\n switch (res.resType) {\n case \"string\":\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n sourceLocale: res.getSourceLocale(),\n source: res.getSource(),\n targetLocale: res.getTargetLocale(),\n target: res.getTarget(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n comment: res.comment,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n translate: !res.getDNT(),\n location: res.getLocation(),\n metadata: res.metadata,\n autoKey: res.getAutoKey()\n });\n units.push(tu);\n break;\n\n case \"array\":\n const sarr = res.getSource();\n let tarr = res.getTarget();\n\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n source: \" \",\n sourceLocale: res.getSourceLocale(),\n targetLocale: res.getTargetLocale(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n comment: res.comment,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n translate: !res.getDNT(),\n location: res.getLocation(),\n autoKey: res.getAutoKey()\n });\n\n for (let j = 0; j < sarr.length; j++) {\n // only output array items that have a translation\n if (sarr[j]) {\n const newtu = tu.clone();\n newtu.source = sarr[j];\n newtu.ordinal = j;\n\n if (tarr && j < tarr.length && tarr[j]) {\n newtu.target = tarr[j];\n }\n\n newtu.ordinal = j;\n units.push(newtu);\n } else if (tarr[j]) {\n logger.warn(\"Translated array \" + res.getKey() + \" has no source string at index \" + j + \". Cannot translate. Resource is: \" + JSON.stringify(res, undefined, 4));\n }\n }\n break;\n\n case \"plural\":\n tu = new TranslationUnit({\n project: res.project,\n key: res.getKey(),\n file: res.getPath(),\n source: \" \",\n sourceLocale: res.getSourceLocale(),\n targetLocale: res.getTargetLocale(),\n state: res.getState(),\n id: res.getId(),\n translated: true,\n context: res.context,\n resType: res.resType,\n datatype: res.datatype,\n flavor: res.getFlavor ? res.getFlavor() : undefined,\n location: res.getLocation(),\n translate: !res.getDNT(),\n autoKey: res.getAutoKey()\n });\n\n const sp = res.getSource();\n const tp = res.getTarget();\n\n if (!tp || isEmpty(tp)) {\n for (let p in sp) {\n const newtu = tu.clone();\n newtu.source = sp[p];\n newtu.quantity = p;\n newtu.comment = generatePluralComment(res, sp, p);\n units.push(newtu);\n }\n } else {\n for (let p in tp) {\n const newtu = tu.clone();\n newtu.source = sp[p] || sp.other;\n newtu.target = tp[p];\n newtu.quantity = p;\n newtu.comment = generatePluralComment(res, sp, p);\n units.push(newtu);\n }\n }\n break;\n }\n } catch (e) {\n logger.warn(e);\n logger.warn(JSON.stringify(res));\n logger.warn(\"Skipping that resource.\");\n }\n\n return units;\n }\n\n /**\n * Convert a translation unit to a new loctool resource.\n *\n * @private\n * @param {TranslationUnit} tu the translation to convert\n * @return {Resource} the corresponding resource\n */\n convertTransUnit(tu) {\n let res;\n\n switch (tu.resType) {\n default:\n res = new ResourceString({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: tu.source,\n targetLocale: tu.targetLocale,\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile,\n metadata: tu.metadata,\n sourceHash: tu.sourceHash,\n autoKey: tu.autoKey\n });\n\n if (tu.target) {\n res.setTarget(tu.target);\n }\n break;\n\n case \"array\":\n var arr = [];\n arr[tu.ordinal] = tu.source;\n res = new ResourceArray({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: arr,\n targetLocale: tu.targetLocale,\n target: [],\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile\n });\n\n if (tu.target) {\n res.addTargetItem(tu.ordinal, tu.target);\n }\n break;\n\n case \"plural\":\n var strings = {};\n strings[tu.quantity] = tu.source;\n res = new ResourcePlural({\n pathName: tu.file,\n project: tu.project,\n id: tu.id,\n key: tu.key,\n sourceLocale: tu.sourceLocale,\n source: strings,\n targetLocale: tu.targetLocale,\n target: {},\n context: tu.context,\n comment: tu.comment,\n resType: tu.resType,\n datatype: tu.datatype,\n state: tu.state,\n flavor: tu.flavor,\n location: new Location(tu.location),\n resfile: tu.resfile\n });\n\n if (tu.target) {\n res.addTargetPlural(tu.quantity, tu.target);\n }\n break;\n }\n\n if (typeof(tu.translate) === \"boolean\") {\n res.setDNT(!tu.translate);\n }\n\n return res;\n }\n\n getPath() {\n return this.path;\n }\n\n setPath(newPath) {\n this.path = newPath;\n }\n\n /**\n * Parse the given xml and convert it into a set of resources.\n *\n * @param {string} xml the contents of the xliff file to parse\n * @returns {TranslationSet} the translation set that represents\n * the resources in the xliff file\n */\n parse(xml) {\n const tuList = this.xliff.deserialize(xml, this.path);\n let res;\n\n if (tuList) {\n for (var j = 0; j < tuList.length; j++) {\n const tu = tuList[j];\n\n switch (tu.resType) {\n default:\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n break;\n\n case \"array\":\n res = this.ts.get(ResourceArray.hashKey(tu.project, tu.context, tu.targetLocale || tu.sourceLocale, tu.key));\n if (res) {\n // if it already exists, amend the existing resource instead of creating a new one\n res.addSourceItem(tu.ordinal, tu.source);\n if (tu.target) {\n res.addTargetItem(tu.ordinal, tu.target);\n }\n } else {\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n }\n break;\n\n case \"plural\":\n res = this.ts.get(ResourcePlural.hashKey(tu.project, tu.context, tu.targetLocale || tu.sourceLocale, tu.key));\n if (res) {\n // if it already exists, amend the existing resource instead of creating a new one\n res.addSourcePlural(tu.quantity, tu.source);\n if (tu.target) {\n res.addTargetPlural(tu.quantity, tu.target);\n }\n } else {\n res = this.convertTransUnit(tu);\n this.ts.add(res);\n }\n break;\n }\n }\n }\n\n return this.ts;\n }\n\n getResources(criteria) {\n if (!criteria) return this.ts.getAll();\n return this.ts.getBy(criteria);\n }\n\n addResource(res) {\n if (!res) return;\n\n if (res.getTargetLocale() === this.sourceLocale || res.getTargetLocale() === \"en\") {\n // don't add this one... cannot translate TO the source locale!\n return;\n }\n\n this.ts.add(res);\n }\n\n getText() {\n let units = [];\n\n if (this.ts.size() > 0) {\n // first convert the resources into translation units\n let resources = this.ts.getAll();\n\n if (this.allowDups) {\n // only look at the initial set of resources\n const initialLength = resources.length;\n for (let i = 0; i < initialLength; i++) {\n const res = resources[i];\n const instances = res.getInstances();\n if (instances && instances.length) {\n resources = resources.concat(instances);\n resources[i].instances = undefined;\n }\n }\n }\n resources.sort(function(left, right) {\n if (typeof(left.index) === 'number' && typeof(right.index) === 'number') {\n return left.index - right.index;\n }\n if (typeof(left.id) === 'number' && typeof(right.id) === 'number') {\n return left.id - right.id;\n }\n // no ids and no indexes? Well, then don't rearrange\n return 0;\n });\n\n // now add the translations\n for (var i = 0; i < resources.length; i++) {\n var res = resources[i];\n if (res.getTargetLocale() !== this.sourceLocale) {\n units = units.concat(this.convertResource(res));\n }\n }\n }\n\n // start with no translation units in it\n this.xliff.clear();\n this.xliff.addTranslationUnits(units);\n\n return this.xliff.serialize(true);\n }\n\n /**\n * Return the number of lines in the xml representation of this file.\n *\n * @returns {Number} the number of lines in the xml\n */\n getLines() {\n return this.xliff.getLines();\n }\n\n /**\n * Return the number of resources in this resource xliff file.\n * @returns {Number} the number of resources in this file\n */\n size() {\n return this.ts.size();\n }\n\n /**\n * Get the version number of this file. Currently, it only supports\n * xliff v1.2 and v2.0.\n * @returns {String} the version number of the file\n */\n getVersion() {\n return this.version;\n }\n}\n\nexport default ResourceXliff;\n"],"mappings":"gGAmBA,IAAAA,UAAA,CAAAC,OAAA,eACA,IAAAC,UAAA,CAAAC,sBAAA,CAAAF,OAAA,6BAEA,IAAAG,eAAA,CAAAD,sBAAA,CAAAF,OAAA,yBACA,IAAAI,cAAA,CAAAF,sBAAA,CAAAF,OAAA,wBACA,IAAAK,eAAA,CAAAH,sBAAA,CAAAF,OAAA,yBACA,IAAAM,eAAA,CAAAJ,sBAAA,CAAAF,OAAA,yBACA,IAAAO,SA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QAAA,CAAAC,OAAA,YAGU9G,aAAa,CAAA+G,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilib-tools-common",
3
- "version": "1.21.0",
3
+ "version": "1.21.2",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./src/index.js",
6
6
  "exports": {
@@ -78,13 +78,14 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "@log4js-node/log4js-api": "^1.0.2",
81
- "ilib-xliff-webos": "^1.0.5",
81
+ "ilib-xliff-webos": "^1.0.11",
82
82
  "intl-messageformat": "^10.7.11",
83
83
  "micromatch": "^4.0.8",
84
84
  "ilib-ctype": "^1.3.0",
85
85
  "ilib-istring": "^1.1.1",
86
- "ilib-locale": "^1.3.0",
87
- "ilib-xliff": "^1.4.1"
86
+ "ilib-locale": "^1.4.0",
87
+ "ilib-xliff": "^1.4.1",
88
+ "ilib-common": "^1.1.6"
88
89
  },
89
90
  "scripts": {
90
91
  "build": "pnpm build:data ; pnpm build:prod",
package/src/Resource.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Resource.js - super class that represents a resource
3
3
  *
4
- * Copyright © 2022-2025 JEDLSoft
4
+ * Copyright © 2022-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -173,6 +173,7 @@ class Resource {
173
173
  * @param {string} [props.comment] the comment (translator's note) of this resource
174
174
  * @param {boolean} [props.dnt] Do not translate this resource when this is set to true. Default: false
175
175
  * @param {string} [props.datatype] the type of file that this resource came from
176
+ * @param {string} [props.sourceHash] the hash value of a source string
176
177
  * @param {string} [props.flavor] the "flavor" of this string, if any. (Android)
177
178
  * @param {Location} [props.location] the location in the file given in pathName where this this resource
178
179
  * is located
@@ -207,7 +208,7 @@ class Resource {
207
208
  this.origin = props.origin || "source";
208
209
  this.dnt = props.dnt;
209
210
  this.datatype = props.datatype;
210
- this.sourceHash = props.sourceHash;
211
+ this.sourceHash = props.sourceHash || undefined;
211
212
  this.localize = typeof(props.localize) === "boolean" ? props.localize : true; // some files have resources we do not want to localize/translate
212
213
  this.flavor = props.flavor;
213
214
  this.index = props.index;
@@ -365,6 +366,28 @@ class Resource {
365
366
  return this.state;
366
367
  }
367
368
 
369
+ /**
370
+ * Sets the hash value for the source of this resource.
371
+ *
372
+ * @param {string} hashValue the hash value to set for this resource.
373
+ */
374
+ setSourceHash(hashValue) {
375
+ if (hashValue !== undefined && typeof hashValue !== 'string') {
376
+ throw new TypeError('hashValue must be a string');
377
+ }
378
+ this.sourceHash = hashValue;
379
+ this.dirty = true;
380
+ }
381
+
382
+ /**
383
+ * Returns the hash value for the source of this resource.
384
+ *
385
+ * @returns {string|undefined} the hash value of this resource.
386
+ */
387
+ getSourceHash() {
388
+ return this.sourceHash;
389
+ }
390
+
368
391
  /**
369
392
  * Set the project of this resource. This is a string that gives the
370
393
  * id of the project for this resource.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * ResourceString.js - represents an string in a resource file
3
3
  *
4
- * Copyright © 2022-2023 JEDLSoft
4
+ * Copyright © 2022-2023, 2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -126,11 +126,12 @@ class ResourceString extends Resource {
126
126
  * @param {String} datatype the datatype of the string
127
127
  * @param {String} flavor the flavor of the string
128
128
  * @param {String} context the context of the string
129
+ * @param {String} sourceHash the sourceHash of the string
129
130
  * @static
130
131
  * @return {String} a hash key
131
132
  */
132
- static hashKey(project, locale, reskey, datatype, flavor, context) {
133
- const key = ["rs", project, locale, reskey, datatype, flavor, context].join("_");
133
+ static hashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {
134
+ const key = ["rs", project, locale, reskey, datatype, flavor, context, sourceHash].join("_");
134
135
  logger.trace("Hashkey is " + key);
135
136
  return key;
136
137
  }
@@ -145,12 +146,13 @@ class ResourceString extends Resource {
145
146
  * @param {String} datatype the datatype of the string
146
147
  * @param {String} flavor the flavor of the string
147
148
  * @param {String} context the context of the string
149
+ * @param {String} sourceHash the sourceHash of the string
148
150
  * @static
149
151
  * @return {String} a hash key
150
152
  */
151
- static cleanHashKey(project, locale, reskey, datatype, flavor, context) {
153
+ static cleanHashKey(project, locale, reskey, datatype, flavor, context, sourceHash) {
152
154
  const cleaned = reskey && reskey.replace(/\s+/g, " ").trim() || "";
153
- const key = ["rs", project, locale, cleaned, datatype, flavor, context].join("_");
155
+ const key = ["rs", project, locale, cleaned, datatype, flavor, context, sourceHash].join("_");
154
156
  logger.trace("CleanHashkey is " + key);
155
157
  return key;
156
158
  }
@@ -162,7 +164,7 @@ class ResourceString extends Resource {
162
164
  */
163
165
  hashKey() {
164
166
  const locale = this.targetLocale || this.getSourceLocale();
165
- return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);
167
+ return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);
166
168
  }
167
169
 
168
170
  /**
@@ -173,7 +175,7 @@ class ResourceString extends Resource {
173
175
  * @return {String} a unique hash key for this resource
174
176
  */
175
177
  hashKeyForTranslation(locale) {
176
- return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);
178
+ return ResourceString.hashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);
177
179
  }
178
180
 
179
181
  /**
@@ -183,7 +185,7 @@ class ResourceString extends Resource {
183
185
  */
184
186
  cleanHashKey() {
185
187
  const locale = this.targetLocale || this.getSourceLocale();
186
- return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);
188
+ return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);
187
189
  }
188
190
 
189
191
  /**
@@ -194,7 +196,7 @@ class ResourceString extends Resource {
194
196
  * @return {String} a unique hash key for this resource's string
195
197
  */
196
198
  cleanHashKeyForTranslation(locale) {
197
- return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context);
199
+ return ResourceString.cleanHashKey(this.project, locale, this.reskey, this.datatype, this.flavor, this.context, this.sourceHash);
198
200
  }
199
201
 
200
202
  /**
@@ -1,7 +1,7 @@
1
1
  /*
2
- * Xliff.js - convert an Xliff file into a set of resources and vice versa
2
+ * ResourceXliff.js - convert an ResourceXliff file into a set of resources and vice versa
3
3
  *
4
- * Copyright © 2022-2023, 2025 JEDLSoft
4
+ * Copyright © 2022-2023, 2025-2026 JEDLSoft
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -136,7 +136,8 @@ class ResourceXliff {
136
136
  flavor: res.getFlavor ? res.getFlavor() : undefined,
137
137
  translate: !res.getDNT(),
138
138
  location: res.getLocation(),
139
- metadata: res.metadata
139
+ metadata: res.metadata,
140
+ autoKey: res.getAutoKey()
140
141
  });
141
142
  units.push(tu);
142
143
  break;
@@ -161,7 +162,8 @@ class ResourceXliff {
161
162
  datatype: res.datatype,
162
163
  flavor: res.getFlavor ? res.getFlavor() : undefined,
163
164
  translate: !res.getDNT(),
164
- location: res.getLocation()
165
+ location: res.getLocation(),
166
+ autoKey: res.getAutoKey()
165
167
  });
166
168
 
167
169
  for (let j = 0; j < sarr.length; j++) {
@@ -199,7 +201,8 @@ class ResourceXliff {
199
201
  datatype: res.datatype,
200
202
  flavor: res.getFlavor ? res.getFlavor() : undefined,
201
203
  location: res.getLocation(),
202
- translate: !res.getDNT()
204
+ translate: !res.getDNT(),
205
+ autoKey: res.getAutoKey()
203
206
  });
204
207
 
205
208
  const sp = res.getSource();
@@ -262,7 +265,9 @@ class ResourceXliff {
262
265
  flavor: tu.flavor,
263
266
  location: new Location(tu.location),
264
267
  resfile: tu.resfile,
265
- metadata: tu.metadata
268
+ metadata: tu.metadata,
269
+ sourceHash: tu.sourceHash,
270
+ autoKey: tu.autoKey
266
271
  });
267
272
 
268
273
  if (tu.target) {