ilib-tools-common 1.11.0 → 1.12.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/README.md +1 -92
- package/lib/Location.js +2 -2
- package/lib/Location.js.map +1 -1
- package/lib/Resource.js +10 -1
- package/lib/Resource.js.map +1 -1
- package/lib/ResourceArray.js +2 -2
- package/lib/ResourceArray.js.map +1 -1
- package/lib/ResourcePlural.js +2 -2
- package/lib/ResourcePlural.js.map +1 -1
- package/lib/ResourceString.js +2 -2
- package/lib/ResourceString.js.map +1 -1
- package/lib/ResourceXliff.js +4 -4
- package/lib/ResourceXliff.js.map +1 -1
- package/lib/TranslationSet.js +1 -1
- package/lib/TranslationSet.js.map +1 -1
- package/lib/TranslationUnit.js +3 -2
- package/lib/TranslationUnit.js.map +1 -1
- package/lib/TranslationVariant.js +2 -2
- package/lib/TranslationVariant.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils.js +2 -2
- package/lib/utils.js.map +1 -1
- package/package.json +92 -101
- package/src/Resource.js +23 -0
- package/src/ResourceXliff.js +8 -1
- package/src/TranslationUnit.js +3 -2
- package/docs/Location.html +0 -470
- package/docs/Location.js.html +0 -130
- package/docs/Resource.html +0 -3920
- package/docs/Resource.js.html +0 -569
- package/docs/ResourceArray.html +0 -6462
- package/docs/ResourceArray.js.html +0 -478
- package/docs/ResourcePlural.html +0 -6817
- package/docs/ResourcePlural.js.html +0 -477
- package/docs/ResourceString.html +0 -5869
- package/docs/ResourceString.js.html +0 -302
- package/docs/ResourceXliff.html +0 -601
- package/docs/ResourceXliff.js.html +0 -539
- package/docs/TranslationSet.html +0 -2691
- package/docs/TranslationSet.js.html +0 -471
- package/docs/TranslationUnit.html +0 -1187
- package/docs/TranslationUnit.js.html +0 -256
- package/docs/TranslationVariant.html +0 -363
- package/docs/TranslationVariant.js.html +0 -122
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/global.html +0 -1858
- package/docs/ilibToolsCommon.md +0 -0
- package/docs/index.html +0 -84
- package/docs/scripts/collapse.js +0 -39
- package/docs/scripts/commonNav.js +0 -28
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/nav.js +0 -12
- package/docs/scripts/polyfill.js +0 -4
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -99
- package/docs/styles/jsdoc.css +0 -776
- package/docs/styles/prettify.css +0 -80
- package/docs/utils.js.html +0 -607
package/README.md
CHANGED
|
@@ -21,95 +21,4 @@ limitations under the License.
|
|
|
21
21
|
|
|
22
22
|
## Release Notes
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
- added location information to the TranslationUnit and Resource constructors
|
|
27
|
-
plus a Location class to keep track of the location in the source file
|
|
28
|
-
where the resources come from.
|
|
29
|
-
|
|
30
|
-
### v1.10.0
|
|
31
|
-
|
|
32
|
-
- now ships with commonjs code as well as modern ESM in the same package
|
|
33
|
-
- updated dependencies
|
|
34
|
-
|
|
35
|
-
### v1.9.1
|
|
36
|
-
|
|
37
|
-
- forgot to export the HTML data in the previous version from the main entry point
|
|
38
|
-
|
|
39
|
-
### v1.9.0
|
|
40
|
-
|
|
41
|
-
- added data about HTML in the Utils
|
|
42
|
-
- nonBreakingTags - a hash of all HTML tags that do not break a string
|
|
43
|
-
- selfClosingTags - a hash of all HTML tags that are commonly self-closing
|
|
44
|
-
- ignoreTags - a hash of HTML tags where the content is ignored, such as <script>
|
|
45
|
-
- localizableAttributes - a hash of all tags that contain attributes which
|
|
46
|
-
have localizable values
|
|
47
|
-
|
|
48
|
-
### v1.8.1
|
|
49
|
-
|
|
50
|
-
- update dependencies
|
|
51
|
-
- fixed a bug where the ResourceXliff.getVersion() call was documented to
|
|
52
|
-
return a string, but it came out as a floating point number instead. Made
|
|
53
|
-
it return the string properly.
|
|
54
|
-
- converted all unit tests to jest
|
|
55
|
-
|
|
56
|
-
### v1.8.0
|
|
57
|
-
|
|
58
|
-
- added parsePath() utility function which takes a template and a path
|
|
59
|
-
and returns an object that maps each template parameter to a part of
|
|
60
|
-
that path
|
|
61
|
-
- getLocaleFromPath() is now re-implemented to use this
|
|
62
|
-
function to find the locale parts of a path
|
|
63
|
-
|
|
64
|
-
### v1.7.0
|
|
65
|
-
|
|
66
|
-
- added getLines() method to tell how many lines there are in the xml file
|
|
67
|
-
- added support for location information of the start of each resource
|
|
68
|
-
in the original file where the resource instances were read from
|
|
69
|
-
- supports line and character within the line
|
|
70
|
-
|
|
71
|
-
### v1.6.0
|
|
72
|
-
|
|
73
|
-
- Added isDirty() method to the Resource class so we can see whether or
|
|
74
|
-
not the resource has been modified since it was first created
|
|
75
|
-
- also added clearDirty() method
|
|
76
|
-
|
|
77
|
-
### v1.5.0
|
|
78
|
-
|
|
79
|
-
- Added getVariant method to the TranslationUnit class
|
|
80
|
-
|
|
81
|
-
### v1.4.0
|
|
82
|
-
|
|
83
|
-
- Added TranslationUnit and TranslationVariant classes
|
|
84
|
-
- added hashKey function to the utilities
|
|
85
|
-
- fixed missing import for makeDirs() utility function
|
|
86
|
-
|
|
87
|
-
### v1.3.0
|
|
88
|
-
|
|
89
|
-
- Added more utility functions:
|
|
90
|
-
- isEmpty - return whether or not an object is empty
|
|
91
|
-
- cleanString - removing differences that are inconsequential for translation such as leading whitespace
|
|
92
|
-
- makeDirs - create directories on disk
|
|
93
|
-
- containsActualText - test if there is text left over after HTML and entities are stripped
|
|
94
|
-
- objectMap - visitor pattern for objects
|
|
95
|
-
|
|
96
|
-
### v1.2.0
|
|
97
|
-
|
|
98
|
-
- Added formatPath and getLocaleFromPath utility function
|
|
99
|
-
|
|
100
|
-
### v1.1.0
|
|
101
|
-
|
|
102
|
-
- Added ResourceXliff class (represents an xliff file as a list of Resource instances)
|
|
103
|
-
- Added TranslationSet class (sets of Resources)
|
|
104
|
-
- Introduced some backwards compatibility support so that this library
|
|
105
|
-
can be used with loctool plugins.
|
|
106
|
-
- added some deprecated methods and accept some deprecated
|
|
107
|
-
constructor parameters
|
|
108
|
-
|
|
109
|
-
### v1.0.0
|
|
110
|
-
|
|
111
|
-
- Initial code copied from loctool 2.18.0:
|
|
112
|
-
- Resource
|
|
113
|
-
- ResourceString
|
|
114
|
-
- ResourceArray
|
|
115
|
-
- ResourcePlural
|
|
24
|
+
See [CHANGELOG.md](./CHANGELOG.md)
|
package/lib/Location.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;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(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;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
2
|
* Location.js - Location information for a resource
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2024 JEDLSoft
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
|
-
|
|
18
|
+
*//**
|
|
19
19
|
* @class Represents the location of a resource in a file
|
|
20
20
|
*/var Location=/*#__PURE__*/function(){/**
|
|
21
21
|
* Construct a new Location instance. A location should have either an offset from
|
package/lib/Location.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.js","names":["Location","info","_classCallCheck","offset","parseInt","line","_createClass","key","value","getLocation","_default","exports","module","default"],"sources":["../src/Location.js"],"sourcesContent":["/*\n * Location.js - Location information for a resource\n *\n * Copyright © 2024 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\n/**\n * @class Represents the location of a resource in a file\n */\nclass Location {\n /**\n * Construct a new Location instance. A location should have either an offset from\n * the beginning of the file, or a line & character number. The first line of the\n * file is considered line 0, and the first character in a line is character 0.\n *\n * @constructor\n * @param {Object} info location info of the resource\n * @param {Number?} info.offset offset of the first character of the resource\n * relative to the beginning of the file\n * @param {Number?} info.line line number of the resource\n * @param {Number?} info.char character number of the resource\n */\n constructor(info) {\n this.info = {\n };\n\n if (info) {\n if (info.offset) {\n this.info.offset = parseInt(info.offset);\n }\n if (info.line) {\n this.info.line = parseInt(info.line);\n this.info.char = parseInt(info.char);\n }\n }\n }\n\n /**\n * Return the location information\n */\n getLocation() {\n return this.info;\n }\n}\n\nexport default Location;"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Location.js","names":["Location","info","_classCallCheck","offset","parseInt","line","_createClass","key","value","getLocation","_default","exports","module","default"],"sources":["../src/Location.js"],"sourcesContent":["/*\n * Location.js - Location information for a resource\n *\n * Copyright © 2024 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\n/**\n * @class Represents the location of a resource in a file\n */\nclass Location {\n /**\n * Construct a new Location instance. A location should have either an offset from\n * the beginning of the file, or a line & character number. The first line of the\n * file is considered line 0, and the first character in a line is character 0.\n *\n * @constructor\n * @param {Object} info location info of the resource\n * @param {Number?} info.offset offset of the first character of the resource\n * relative to the beginning of the file\n * @param {Number?} info.line line number of the resource\n * @param {Number?} info.char character number of the resource\n */\n constructor(info) {\n this.info = {\n };\n\n if (info) {\n if (info.offset) {\n this.info.offset = parseInt(info.offset);\n }\n if (info.line) {\n this.info.line = parseInt(info.line);\n this.info.char = parseInt(info.char);\n }\n }\n }\n\n /**\n * Return the location information\n */\n getLocation() {\n return this.info;\n }\n}\n\nexport default Location;"],"mappings":"0qCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA;AACA;AACA,GAFA,GAGM,CAAAA,QAAQ,yBACV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACI,SAAAA,SAAYC,IAAI,CAAE,CAAAC,eAAA,MAAAF,QAAA,EACd,IAAI,CAACC,IAAI,CAAG,CACZ,CAAC,CAED,GAAIA,IAAI,CAAE,CACN,GAAIA,IAAI,CAACE,MAAM,CAAE,CACb,IAAI,CAACF,IAAI,CAACE,MAAM,CAAGC,QAAQ,CAACH,IAAI,CAACE,MAAM,CAC3C,CACA,GAAIF,IAAI,CAACI,IAAI,CAAE,CACX,IAAI,CAACJ,IAAI,CAACI,IAAI,CAAGD,QAAQ,CAACH,IAAI,CAACI,IAAI,CAAC,CACpC,IAAI,CAACJ,IAAI,QAAK,CAAGG,QAAQ,CAACH,IAAI,QAAK,CACvC,CACJ,CACJ,CAEA;AACJ;AACA,OAFI,OAAAK,YAAA,CAAAN,QAAA,GAAAO,GAAA,eAAAC,KAAA,CAGA,SAAAC,WAAWA,CAAA,CAAG,CACV,MAAO,KAAI,CAACR,IAChB,CAAC,WAAAS,QAAA,CAAAC,OAAA,YAGUX,QAAQ,CAAAY,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
package/lib/Resource.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;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(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;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
2
|
* Resource.js - super class that represents a resource
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2022-2024 JEDLSoft
|
|
@@ -142,6 +142,15 @@ this.flavor=props.flavor;this.index=props.index;this.location=props.location;//
|
|
|
142
142
|
* @param {String|undefined} comment the translator's comment to set. Use
|
|
143
143
|
* undefined to clear the comment
|
|
144
144
|
*/},{key:"setComment",value:function setComment(comment){this.comment=comment;this.dirty=true}/**
|
|
145
|
+
* Get the "do not translate" flag for this resource.
|
|
146
|
+
*
|
|
147
|
+
* @returns {boolean} true means that the current resource should not
|
|
148
|
+
* be translated, and false means it will be translated.
|
|
149
|
+
*/},{key:"getDNT",value:function getDNT(){return typeof this.dnt==="boolean"?this.dnt:false}/**
|
|
150
|
+
* Set the "do not translate" flag for this resource.
|
|
151
|
+
*
|
|
152
|
+
* @param {boolean} flag set the dnt flag to this value
|
|
153
|
+
*/},{key:"setDNT",value:function setDNT(flag){if(typeof flag!=="boolean"){throw new TypeError("value must be boolean")}this.dnt=flag;this.dirty=true}/**
|
|
145
154
|
* Return the database id if this resource has previously been saved in the
|
|
146
155
|
* database.
|
|
147
156
|
*
|
package/lib/Resource.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","names":["validStates","translationImportant","Resource","props","_classCallCheck","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","state","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","getPath","getComment","setComment","getId","getOrigin","getLocalize","getFlavor","same","other","i","length","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","_default","exports","module","default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2024 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 \"new\":true,\n \"translated\":true,\n \"accepted\":true\n}\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 * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * <li>project {String} - the project that this resource is in\n * <li><i>context</i> {String} - 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 * <li>sourceLocale {String} - the locale of the source resource.\n * <li>targetLocale {String} - the locale of the target resource.\n * <li>key {String} - the unique key of this string, which should include the context\n * of the string\n * <li>pathName {String} - pathName to the file where the string was extracted from\n * <li>autoKey {boolean} - true if the key was generated based on the source text\n * <li>state {String} - current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * <li>id {String} - the id of the current resource\n * <li>comment {String} - the comment (translator's note) of this resource\n * <li>dnt {boolean} - Do not translate this resource when this is set to true. Default: false\n * <li>datatype {String} - the type of file that this resource came from\n * <li>flavor {String} - the \"flavor\" of this string, if any. (Android)\n * <li>location {Location} - the location in the file given in pathName where this this resource\n * is located\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\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 }\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} 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 * 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 */\n setState(state) {\n this.state = validStates[state] ? state : this.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 * 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 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} 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} 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\nexport default Resource;\n"],"mappings":"q6CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB,KAAK,CAAC,IAAI,CACV,YAAY,CAAC,IAAI,CACjB,UAAU,CAAC,IACf,CAAC,CAED,GAAM,CAAAC,oBAAoB,CAAG,CACzB,SAAS,CACT,UAAU,CACV,KAAK,CACL,QAAQ,CACR,SAAS,CACT,QAAQ,CACR,SAAS,CACT,cAAc,CACd,cAAc,CACjB,CAGD;AACA;AACA;AACA;AACA,GAJA,GAKM,CAAAC,QAAQ,yBACV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACI,SAAAA,SAAYC,KAAK,CAAE,CAAAC,eAAA,MAAAF,QAAA,EACf,GAAI,IAAI,CAACG,WAAW,GAAKH,QAAQ,CAAE,CAC/B,KAAM,IAAI,CAAAI,KAAK,CAAC,6CAA6C,CACjE,CAEA,IAAI,CAACC,OAAO,CAAG,KAAK,CAEpB,GAAIJ,KAAK,CAAE,CACP,IAAI,CAACK,OAAO,CAAGL,KAAK,CAACK,OAAO,CAC5B,IAAI,CAACC,OAAO,CAAGN,KAAK,CAACM,OAAO,EAAIC,SAAS,CAAE;AAC3C,IAAI,CAACC,YAAY,CAAGR,KAAK,CAACQ,YAAY,EAAIR,KAAK,CAACS,MAAM,CACtD,IAAI,CAACC,YAAY,CAAGV,KAAK,CAACU,YAAY,CACtC,IAAI,CAACC,MAAM,CAAGX,KAAK,CAACY,GAAG,EAAIZ,KAAK,CAACW,MAAM,CACvC,IAAI,CAACE,QAAQ,CAAGb,KAAK,CAACa,QAAQ,CAC9B,IAAI,CAACT,OAAO,CAAG,MAAO,CAAAJ,KAAK,CAACI,OAAQ,GAAK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A;AACA,OALI,GAAA5D,GAAA,gBAAAiB,KAAA,CAMA,SAAA4C,aAAA,CAAe,CACX,MAAO,KAAI,CAAC/C,SAChB,CAEA;AACJ;AACA,OAFI,GAAAd,GAAA,WAAAiB,KAAA,CAGA,SAAA6C,QAAA,CAAU,CACN,MAAO,KAAI,CAAC/C,KAChB,CAEA;AACJ;AACA;AACA;AACA,OAJI,GAAAf,GAAA,cAAAiB,KAAA,CAKA,SAAA8C,WAAA,CAAa,CACT,IAAI,CAAChD,KAAK,CAAG,KACjB,CAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OARI,GAAAf,GAAA,eAAAiB,KAAA,CASA,SAAA+C,YAAA,CAAc,KAAAC,cAAA,CACV,OAAAA,cAAA,CAAO,IAAI,CAACpD,QAAQ,UAAAoD,cAAA,iBAAbA,cAAA,CAAeD,WAAW,CAAC,CACtC,CAAC,WAAAE,QAAA,CAAAC,OAAA,YAGUhF,QAAQ,CAAAiF,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Resource.js","names":["validStates","translationImportant","Resource","props","_classCallCheck","constructor","Error","autoKey","project","context","undefined","sourceLocale","locale","targetLocale","reskey","key","pathName","state","id","formatted","comment","origin","dnt","datatype","sourceHash","localize","flavor","index","location","instances","dirty","_createClass","value","getProject","getKey","getSource","source","getTarget","target","getType","resType","getDataType","getAutoKey","getContext","getSourceLocale","setSourceLocale","getTargetLocale","setTargetLocale","getState","setProject","setState","getPath","getComment","setComment","getDNT","setDNT","flag","TypeError","getId","getOrigin","getLocalize","getFlavor","same","other","i","length","escapeText","str","_typeof","replace","toString","addInstance","resource","isInstance","unique","every","res","push","_this","prop","getInstances","isDirty","clearDirty","getLocation","_this$location","_default","exports","module","default"],"sources":["../src/Resource.js"],"sourcesContent":["/*\n * Resource.js - super class that represents a resource\n *\n * Copyright © 2022-2024 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 \"new\":true,\n \"translated\":true,\n \"accepted\":true\n}\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 * Construct a new Resource instance.\n * The props may contain any\n * of the following properties:\n *\n * <ul>\n * <li>project {String} - the project that this resource is in\n * <li><i>context</i> {String} - 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 * <li>sourceLocale {String} - the locale of the source resource.\n * <li>targetLocale {String} - the locale of the target resource.\n * <li>key {String} - the unique key of this string, which should include the context\n * of the string\n * <li>pathName {String} - pathName to the file where the string was extracted from\n * <li>autoKey {boolean} - true if the key was generated based on the source text\n * <li>state {String} - current state of the resource (ie. \"new\", \"translated\", or \"accepted\")\n * <li>id {String} - the id of the current resource\n * <li>comment {String} - the comment (translator's note) of this resource\n * <li>dnt {boolean} - Do not translate this resource when this is set to true. Default: false\n * <li>datatype {String} - the type of file that this resource came from\n * <li>flavor {String} - the \"flavor\" of this string, if any. (Android)\n * <li>location {Location} - the location in the file given in pathName where this this resource\n * is located\n * </ul>\n *\n * @constructor\n * @param {Object} props properties of the string, as defined above\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 }\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} 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 * 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 */\n setState(state) {\n this.state = validStates[state] ? state : this.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 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} 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} 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\nexport default Resource;\n"],"mappings":"0qCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAEA,GAAM,CAAAA,WAAW,CAAG,CAChB,KAAK,CAAC,IAAI,CACV,YAAY,CAAC,IAAI,CACjB,UAAU,CAAC,IACf,CAAC,CAED,GAAM,CAAAC,oBAAoB,CAAG,CACzB,SAAS,CACT,UAAU,CACV,KAAK,CACL,QAAQ,CACR,SAAS,CACT,QAAQ,CACR,SAAS,CACT,cAAc,CACd,cAAc,CACjB,CAGD;AACA;AACA;AACA;AACA,GAJA,GAKM,CAAAC,QAAQ,yBACV;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OACI,SAAAA,SAAYC,KAAK,CAAE,CAAAC,eAAA,MAAAF,QAAA,EACf,GAAI,IAAI,CAACG,WAAW,GAAKH,QAAQ,CAAE,CAC/B,KAAM,IAAI,CAAAI,KAAK,CAAC,6CAA6C,CACjE,CAEA,IAAI,CAACC,OAAO,CAAG,KAAK,CAEpB,GAAIJ,KAAK,CAAE,CACP,IAAI,CAACK,OAAO,CAAGL,KAAK,CAACK,OAAO,CAC5B,IAAI,CAACC,OAAO,CAAGN,KAAK,CAACM,OAAO,EAAIC,SAAS,CAAE;AAC3C,IAAI,CAACC,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A,CAAA,CAAG,CACT,IAAI,CAACpD,KAAK,CAAG,KACjB,CAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OARI,GAAAf,GAAA,eAAAiB,KAAA,CASA,SAAAmD,WAAWA,CAAA,CAAG,KAAAC,cAAA,CACV,OAAAA,cAAA,CAAO,IAAI,CAACxD,QAAQ,UAAAwD,cAAA,iBAAbA,cAAA,CAAeD,WAAW,CAAC,CACtC,CAAC,WAAAE,QAAA,CAAAC,OAAA,YAGUpF,QAAQ,CAAAqF,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
package/lib/ResourceArray.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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(
|
|
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
|
* ResourceArray.js - represents an array of strings in a resource file
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2022-2023 JEDLSoft
|
|
@@ -155,7 +155,7 @@ for(var _i=0;_i<this.target.length;_i++){if(this.target[_i]!==other.target[_i])r
|
|
|
155
155
|
* @param {Resource} a resource to check
|
|
156
156
|
* @returns {boolean} true if this is an instance of
|
|
157
157
|
* the current resource, false otherwise.
|
|
158
|
-
*/},{key:"isInstance",value:function isInstance(resource){if(!
|
|
158
|
+
*/},{key:"isInstance",value:function isInstance(resource){if(!_superPropGet(ResourceArray,"isInstance",this,3)([resource])){return false}// now check the properties specific to this resource subclass
|
|
159
159
|
return this.source.every(function(str,i){return(0,_utils.cleanString)(str)===(0,_utils.cleanString)(resource.source[i])})}}],[{key:"hashKey",value:function hashKey(project,context,locale,reskey){var key=["ra",project,context,locale,reskey].join("_");logger.trace("Hashkey is "+key);return key}}])}(_Resource2["default"]);/**
|
|
160
160
|
* The class of this kind of array resource.
|
|
161
161
|
*
|
package/lib/ResourceArray.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceArray.js","names":["_Resource2","_interopRequireDefault","require","_utils","_log4jsApi","obj","__esModule","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","protoProps","staticProps","prototype","t","_toPrimitive","_typeof","r","e","Symbol","toPrimitive","call","String","Number","_callSuper","o","_getPrototypeOf","_possibleConstructorReturn","_isNativeReflectConstruct","Reflect","construct","constructor","apply","self","_assertThisInitialized","ReferenceError","Boolean","valueOf","_get","get","bind","property","receiver","base","_superPropBase","desc","getOwnPropertyDescriptor","arguments","value","object","hasOwnProperty","setPrototypeOf","getPrototypeOf","__proto__","_inherits","subClass","superClass","create","_setPrototypeOf","p","logger","log4js","getLogger","ResourceArray","_Resource","_this","source","subtype","sourceArray","Array","isArray","map","item","toString","targetArray","locale","datatype","resType","resClass","setSource","arr","dirty","setTarget","getSourceArray","getSource","getTargetArray","getTarget","getSourceItem","undefined","getTargetItem","addSourceItem","str","addTargetItem","size","len","Math","max","clone","overrides","equals","other","same","hashKey","targetLocale","getSourceLocale","project","context","reskey","hashKeyForTranslation","cleanHashKey","cleaned","replace","trim","cleanHashKeyForTranslation","isInstance","resource","every","cleanString","join","trace","Resource","_default","exports","module","default"],"sources":["../src/ResourceArray.js"],"sourcesContent":["/*\n * ResourceArray.js - represents an array of strings 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.ResourceArray\");\n\n/**\n * @class A class that models a resource that is an array of strings.\n *\n * @extends Resource\n */\nclass ResourceArray extends Resource {\n /**\n * Construct a new ResourceArray instance.\n *\n * Arrays of strings are used in Android apps, as well as some other\n * places, to specify things like the values for a drop-down box in\n * a UI.<p>\n *\n * The properties in the props parameter may be any of the following:\n *\n * <ul>\n * <li><i>key</i> {String} - The unique key of the array resource\n * <li><i>locale</i> {String} - The locale specifier that gives the\n * languages that the array's strings are written in\n * <li><i>pathName</i> {String} - The path to the file that contains\n * this array resource\n * <li><i>context</i> {String} - 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 * <li><i>source</i> {Array.<String>} An array of strings\n * that are the source language values of this resource\n * <li><i>target</i> {Array.<String>} An array of strings\n * that are the target language values of this resource\n * </ul>\n *\n * @constructor\n * @param {Object} props Any of the properties given above\n */\n constructor(props) {\n super(props);\n\n this.source = [];\n this.subtype = \"string-array\";\n\n if (props) {\n const source = props.source || props.sourceArray;\n if (source) {\n if (!Array.isArray(source)) {\n this.source = [source];\n } else if (source.length) {\n // make a deep copy of the array\n this.source = source.map(item => {\n // both copies the string and ensures that it is a string type\n return new String(item).toString();\n });\n }\n }\n const target = props.target || props.targetArray;\n if (target) {\n if (!Array.isArray(target)) {\n this.target = [target];\n } else if (target.length) {\n // make a deep copy of the array\n this.target = target.map(item => {\n return new String(item).toString();\n });\n }\n }\n if (props.subtype) {\n this.subtype = props.subtype;\n }\n }\n\n this.locale = this.locale || \"en-US\";\n this.datatype = this.datatype || \"x-android-resource\";\n this.resType = ResourceArray.resClass;\n }\n\n /**\n * Set the array of source strings for this resource.\n *\n * @override\n * @param {Array.<String>} arr the array of strings to set\n * as the source array\n */\n setSource(arr) {\n if (!arr || !Array.isArray(arr)) return;\n this.source = arr;\n this.dirty = true;\n }\n\n /**\n * Set the array of target strings for this resource.\n *\n * @param {Array.<String>} arr the array of strings to set\n * as the target array\n */\n setTarget(arr) {\n if (!arr || !Array.isArray(arr)) return;\n this.target = arr;\n this.dirty = true;\n }\n\n /**\n * Return the array of source strings. This method is here\n * for backwards compatilibity with the loctool plugins.\n *\n * @deprecated Use getSource() instead\n * @returns {Array.<String>} the array of source strings\n */\n getSourceArray() {\n return this.getSource();\n }\n\n /**\n * Return the array of target strings. This method is here\n * for backwards compatilibity with the loctool plugins.\n *\n * @deprecated Use getTarget() instead\n * @returns {Array.<String>} the array of target strings\n */\n getTargetArray() {\n return this.getTarget();\n }\n\n /**\n * Return the source string with the given index into the array.\n *\n * @param {number} i The index of the string being sought\n * @returns {String|undefined} the value of the string at index i or\n * undefined if i is outside the bounds of the array\n */\n getSourceItem(i) {\n return (i >= 0 && i < this.source.length) ? this.source[i] : undefined;\n }\n\n /**\n * Return the target string with the given index into the array.\n *\n * @param {number} i The index of the string being sought\n * @returns {String|undefined} the value of the string at index i or\n * undefined if i is outside the bounds of the array\n */\n getTargetItem(i) {\n return (this.target && i >= 0 && i < this.target.length) ? this.target[i] : undefined;\n }\n\n /**\n * Add a string to the source array at index i.\n *\n * @param {number} i the index at which to add the string\n * @param {String} str the string to add\n */\n addSourceItem(i, str) {\n if (typeof(i) === \"undefined\" || i < 0 || typeof(str) === \"undefined\") {\n return;\n }\n\n if (!this.source) {\n this.source = [];\n }\n\n this.source[i] = str;\n this.dirty = true;\n }\n\n /**\n * Add a string to the target array at index i.\n *\n * @param {number} i the index at which to add the string\n * @param {String} str the string to add\n */\n addTargetItem(i, str) {\n // can only add a target string if there is already a source string\n if (typeof(i) === \"undefined\" || i < 0 || typeof(str) === \"undefined\") {\n return;\n }\n\n if (!this.target) {\n this.target = [];\n }\n\n this.target[i] = str;\n this.dirty = true;\n }\n\n /**\n * Return the length of the array of strings in this resource.\n *\n * @returns {number} the length of the array of strings in this\n * resource\n */\n size() {\n let len = this.source ? this.source.length : 0;\n if (this.target) {\n len = Math.max(len, this.target.length);\n }\n return len;\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 ResourceArray(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 resources contains the same resources as\n * the current one. The pathName, state, and comment fields are\n * ignored as minor variations.\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 (!super.equals(other)) {\n logger.trace(\"parent returned false\");\n return false;\n }\n\n if (this.source || other.source) {\n if (this.source && other.source) {\n if (this.source.length !== other.source.length) {\n logger.trace(\"different length source arrays\");\n return false;\n }\n\n for (let i = 0; i < this.source.length; i++) {\n if (this.source[i] !== other.array[i]) {\n logger.trace(\"differed in source content '\" + this.source[i] + \"' !== '\" + other.source[i] + \"'\");\n return false;\n }\n }\n } else {\n logger.trace(\"one has a source array, the other doesn't\");\n return false;\n }\n }\n\n if (this.target || other.target) {\n if (this.target && other.target) {\n if (this.target.length !== other.target.length) {\n logger.trace(\"different length target arrays\");\n return false;\n }\n\n for (let i = 0; i < this.target.length; i++) {\n if (this.target[i] !== other.target[i]) {\n logger.trace(\"differed in target content '\" + this.target[i] + \"' !== '\" + other.target[i] + \"'\");\n return false;\n }\n }\n } else {\n logger.trace(\"one has a target array, the other doesn't\");\n return false;\n }\n }\n\n logger.trace(\"Both the same\");\n return true;\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) || other.source.length !== this.source.length) return false;\n\n for (let i = 0; i < this.source.length; i++) {\n if (this.source[i] !== other.source[i]) return false;\n }\n\n if (this.target && this.target.length) {\n // if this is a source-only resource, there will be no target, and that's okay. Just ignore\n // the target for the purposes of this comparison.\n for (let i = 0; i < this.target.length; i++) {\n if (this.target[i] !== other.target[i]) return false;\n }\n }\n\n return true;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, context, locale, reskey) {\n const key = [\"ra\", project, context, locale, reskey].join(\"_\");\n logger.trace(\"Hashkey 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 ResourceArray.hashKey(this.project, this.context, locale, this.reskey);\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 ResourceArray.hashKey(this.project, this.context, locale, this.reskey);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @return {String} a unique hash key for this resource\n */\n cleanHashKey() {\n const cleaned = this.reskey && this.reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceArray.hashKey(this.project, this.context, locale, cleaned);\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 cleanHashKeyForTranslation(locale) {\n const cleaned = this.reskey && this.reskey.replace(/\\s+/g, \" \").trim() || \"\";\n return ResourceArray.hashKey(this.project, this.context, locale, cleaned);\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 this.source.every((str, i) => {\n return cleanString(str) === cleanString(resource.source[i]);\n });\n }\n}\n\n/**\n * The class of this kind of array resource.\n *\n * @static\n * @const\n */\nResourceArray.resClass = \"array\";\n\nexport default ResourceArray;\n"],"mappings":"kXAmBA,IAAAA,UAAA,CAAAC,sBAAA,CAAAC,OAAA,mBACA,IAAAC,MAAA,CAAAD,OAAA,eACA,IAAAE,UAAA,CAAAH,sBAAA,CAAAC,OAAA,6BAA6C,SAAAD,uBAAAI,GAAA,SAAAA,GAAA,EAAAA,GAAA,CAAAC,UAAA,CAAAD,GAAA,YAAAA,GAAA,WAAAE,gBAAAC,QAAA,CAAAC,WAAA,OAAAD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AAAA,GACX,CAAC,KA5SuB+G,qBAAQ,EA+WpC;AACA;AACA;AACA;AACA;AACA,GACAzD,aAAa,CAACe,QAAQ,CAAG,OAAO,CAAC,IAAA2C,QAAA,CAAAC,OAAA,YAElB3D,aAAa,CAAA4D,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ResourceArray.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","ResourceArray","_Resource","props","_this","source","subtype","sourceArray","Array","isArray","map","item","toString","target","targetArray","locale","datatype","resType","resClass","setSource","arr","dirty","setTarget","getSourceArray","getSource","getTargetArray","getTarget","getSourceItem","undefined","getTargetItem","addSourceItem","str","addTargetItem","size","len","Math","max","clone","overrides","equals","other","same","hashKey","targetLocale","getSourceLocale","project","context","reskey","hashKeyForTranslation","cleanHashKey","cleaned","replace","trim","cleanHashKeyForTranslation","isInstance","resource","every","cleanString","join","trace","Resource","_default","exports","module","default"],"sources":["../src/ResourceArray.js"],"sourcesContent":["/*\n * ResourceArray.js - represents an array of strings 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.ResourceArray\");\n\n/**\n * @class A class that models a resource that is an array of strings.\n *\n * @extends Resource\n */\nclass ResourceArray extends Resource {\n /**\n * Construct a new ResourceArray instance.\n *\n * Arrays of strings are used in Android apps, as well as some other\n * places, to specify things like the values for a drop-down box in\n * a UI.<p>\n *\n * The properties in the props parameter may be any of the following:\n *\n * <ul>\n * <li><i>key</i> {String} - The unique key of the array resource\n * <li><i>locale</i> {String} - The locale specifier that gives the\n * languages that the array's strings are written in\n * <li><i>pathName</i> {String} - The path to the file that contains\n * this array resource\n * <li><i>context</i> {String} - 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 * <li><i>source</i> {Array.<String>} An array of strings\n * that are the source language values of this resource\n * <li><i>target</i> {Array.<String>} An array of strings\n * that are the target language values of this resource\n * </ul>\n *\n * @constructor\n * @param {Object} props Any of the properties given above\n */\n constructor(props) {\n super(props);\n\n this.source = [];\n this.subtype = \"string-array\";\n\n if (props) {\n const source = props.source || props.sourceArray;\n if (source) {\n if (!Array.isArray(source)) {\n this.source = [source];\n } else if (source.length) {\n // make a deep copy of the array\n this.source = source.map(item => {\n // both copies the string and ensures that it is a string type\n return new String(item).toString();\n });\n }\n }\n const target = props.target || props.targetArray;\n if (target) {\n if (!Array.isArray(target)) {\n this.target = [target];\n } else if (target.length) {\n // make a deep copy of the array\n this.target = target.map(item => {\n return new String(item).toString();\n });\n }\n }\n if (props.subtype) {\n this.subtype = props.subtype;\n }\n }\n\n this.locale = this.locale || \"en-US\";\n this.datatype = this.datatype || \"x-android-resource\";\n this.resType = ResourceArray.resClass;\n }\n\n /**\n * Set the array of source strings for this resource.\n *\n * @override\n * @param {Array.<String>} arr the array of strings to set\n * as the source array\n */\n setSource(arr) {\n if (!arr || !Array.isArray(arr)) return;\n this.source = arr;\n this.dirty = true;\n }\n\n /**\n * Set the array of target strings for this resource.\n *\n * @param {Array.<String>} arr the array of strings to set\n * as the target array\n */\n setTarget(arr) {\n if (!arr || !Array.isArray(arr)) return;\n this.target = arr;\n this.dirty = true;\n }\n\n /**\n * Return the array of source strings. This method is here\n * for backwards compatilibity with the loctool plugins.\n *\n * @deprecated Use getSource() instead\n * @returns {Array.<String>} the array of source strings\n */\n getSourceArray() {\n return this.getSource();\n }\n\n /**\n * Return the array of target strings. This method is here\n * for backwards compatilibity with the loctool plugins.\n *\n * @deprecated Use getTarget() instead\n * @returns {Array.<String>} the array of target strings\n */\n getTargetArray() {\n return this.getTarget();\n }\n\n /**\n * Return the source string with the given index into the array.\n *\n * @param {number} i The index of the string being sought\n * @returns {String|undefined} the value of the string at index i or\n * undefined if i is outside the bounds of the array\n */\n getSourceItem(i) {\n return (i >= 0 && i < this.source.length) ? this.source[i] : undefined;\n }\n\n /**\n * Return the target string with the given index into the array.\n *\n * @param {number} i The index of the string being sought\n * @returns {String|undefined} the value of the string at index i or\n * undefined if i is outside the bounds of the array\n */\n getTargetItem(i) {\n return (this.target && i >= 0 && i < this.target.length) ? this.target[i] : undefined;\n }\n\n /**\n * Add a string to the source array at index i.\n *\n * @param {number} i the index at which to add the string\n * @param {String} str the string to add\n */\n addSourceItem(i, str) {\n if (typeof(i) === \"undefined\" || i < 0 || typeof(str) === \"undefined\") {\n return;\n }\n\n if (!this.source) {\n this.source = [];\n }\n\n this.source[i] = str;\n this.dirty = true;\n }\n\n /**\n * Add a string to the target array at index i.\n *\n * @param {number} i the index at which to add the string\n * @param {String} str the string to add\n */\n addTargetItem(i, str) {\n // can only add a target string if there is already a source string\n if (typeof(i) === \"undefined\" || i < 0 || typeof(str) === \"undefined\") {\n return;\n }\n\n if (!this.target) {\n this.target = [];\n }\n\n this.target[i] = str;\n this.dirty = true;\n }\n\n /**\n * Return the length of the array of strings in this resource.\n *\n * @returns {number} the length of the array of strings in this\n * resource\n */\n size() {\n let len = this.source ? this.source.length : 0;\n if (this.target) {\n len = Math.max(len, this.target.length);\n }\n return len;\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 ResourceArray(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 resources contains the same resources as\n * the current one. The pathName, state, and comment fields are\n * ignored as minor variations.\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 (!super.equals(other)) {\n logger.trace(\"parent returned false\");\n return false;\n }\n\n if (this.source || other.source) {\n if (this.source && other.source) {\n if (this.source.length !== other.source.length) {\n logger.trace(\"different length source arrays\");\n return false;\n }\n\n for (let i = 0; i < this.source.length; i++) {\n if (this.source[i] !== other.array[i]) {\n logger.trace(\"differed in source content '\" + this.source[i] + \"' !== '\" + other.source[i] + \"'\");\n return false;\n }\n }\n } else {\n logger.trace(\"one has a source array, the other doesn't\");\n return false;\n }\n }\n\n if (this.target || other.target) {\n if (this.target && other.target) {\n if (this.target.length !== other.target.length) {\n logger.trace(\"different length target arrays\");\n return false;\n }\n\n for (let i = 0; i < this.target.length; i++) {\n if (this.target[i] !== other.target[i]) {\n logger.trace(\"differed in target content '\" + this.target[i] + \"' !== '\" + other.target[i] + \"'\");\n return false;\n }\n }\n } else {\n logger.trace(\"one has a target array, the other doesn't\");\n return false;\n }\n }\n\n logger.trace(\"Both the same\");\n return true;\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) || other.source.length !== this.source.length) return false;\n\n for (let i = 0; i < this.source.length; i++) {\n if (this.source[i] !== other.source[i]) return false;\n }\n\n if (this.target && this.target.length) {\n // if this is a source-only resource, there will be no target, and that's okay. Just ignore\n // the target for the purposes of this comparison.\n for (let i = 0; i < this.target.length; i++) {\n if (this.target[i] !== other.target[i]) return false;\n }\n }\n\n return true;\n }\n\n /**\n * Calculate a resource key string for this class of resource given the\n * parameters.\n *\n * @static\n * @return {String} a hash key\n */\n static hashKey(project, context, locale, reskey) {\n const key = [\"ra\", project, context, locale, reskey].join(\"_\");\n logger.trace(\"Hashkey 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 ResourceArray.hashKey(this.project, this.context, locale, this.reskey);\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 ResourceArray.hashKey(this.project, this.context, locale, this.reskey);\n }\n\n /**\n * Return the a hash key that uniquely identifies this resource, but uses the cleaned version of the string\n *\n * @return {String} a unique hash key for this resource\n */\n cleanHashKey() {\n const cleaned = this.reskey && this.reskey.replace(/\\s+/g, \" \").trim() || \"\";\n const locale = this.targetLocale || this.getSourceLocale();\n return ResourceArray.hashKey(this.project, this.context, locale, cleaned);\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 cleanHashKeyForTranslation(locale) {\n const cleaned = this.reskey && this.reskey.replace(/\\s+/g, \" \").trim() || \"\";\n return ResourceArray.hashKey(this.project, this.context, locale, cleaned);\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 this.source.every((str, i) => {\n return cleanString(str) === cleanString(resource.source[i]);\n });\n }\n}\n\n/**\n * The class of this kind of array resource.\n *\n * @static\n * @const\n */\nResourceArray.resClass = \"array\";\n\nexport default ResourceArray;\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,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AO,CAAE/B,MAAM,CAAEmC,OAAO,CAC5E,CAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OARI,GAAA3F,GAAA,cAAA+B,KAAA,CASA,SAAAgE,UAAUA,CAACC,QAAQ,CAAE,CACjB,GAAI,CAAAzE,aAAA,CAAAmB,aAAA,uBAAkBsD,QAAQ,EAAC,CAAE,CAC7B,MAAO,MACX,CAEA;AACA,MAAO,KAAI,CAAClD,MAAM,CAACmD,KAAK,CAAC,SAACzB,GAAG,CAAErE,CAAC,CAAK,CACjC,MAAO,GAAA+F,kBAAW,EAAC1B,GAAG,CAAC,GAAK,GAAA0B,kBAAW,EAACF,QAAQ,CAAClD,MAAM,CAAC3C,CAAC,CAAC,CAC9D,CAAC,CACL,CAAC,KAAAH,GAAA,WAAA+B,KAAA,CApED,QAAO,CAAAoD,OAAOA,CAACG,OAAO,CAAEC,OAAO,CAAE/B,MAAM,CAAEgC,MAAM,CAAE,CAC7C,GAAM,CAAAxF,GAAG,CAAG,CAAC,IAAI,CAAEsF,OAAO,CAAEC,OAAO,CAAE/B,MAAM,CAAEgC,MAAM,CAAC,CAACW,IAAI,CAAC,GAAG,CAAC,CAC9D5D,MAAM,CAAC6D,KAAK,CAAC,aAAa,CAAGpG,GAAG,CAAC,CACjC,MAAO,CAAAA,GACX,CAAC,KA5SuBqG,qBAAQ,EA+WpC;AACA;AACA;AACA;AACA;AACA,GACA3D,aAAa,CAACiB,QAAQ,CAAG,OAAO,CAAC,IAAA2C,QAAA,CAAAC,OAAA,YAElB7D,aAAa,CAAA8D,MAAA,CAAAD,OAAA,CAAAA,OAAA,CAAAE,OAAA","ignoreList":[]}
|
package/lib/ResourcePlural.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";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(
|
|
1
|
+
"use strict";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 _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)}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
|
* ResourcePlural.js - represents an array of plural strings in a resource file
|
|
3
3
|
*
|
|
4
4
|
* Copyright © 2022-2023 JEDLSoft
|
|
@@ -173,7 +173,7 @@ if(!pluralCategory||!str||!this.source)return;if(!this.target){this.target={}}th
|
|
|
173
173
|
* @param {Resource} a resource to check
|
|
174
174
|
* @returns {boolean} true if this is an instance of
|
|
175
175
|
* the current resource, false otherwise.
|
|
176
|
-
*/},{key:"isInstance",value:function isInstance(resource){var _this2=this;if(!
|
|
176
|
+
*/},{key:"isInstance",value:function isInstance(resource){var _this2=this;if(!_superPropGet(ResourcePlural,"isInstance",this,3)([resource])){return false}// now check the properties specific to this resource subclass
|
|
177
177
|
return Object.keys(this.source).every(function(prop){return(0,_utils.cleanString)(_this2.source[prop])===(0,_utils.cleanString)(resource.source[prop])})}}],[{key:"hashKey",value:function hashKey(project,context,locale,reskey){var key=["rp",project,context,locale,reskey].join("_");logger.trace("Hashkey is "+key);return key}}])}(_Resource2["default"]);/**
|
|
178
178
|
* The class of this kind of string plural.
|
|
179
179
|
*
|