i18n-jsautotranslate 3.18.61 → 3.18.62

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.
Files changed (2) hide show
  1. package/index.js +11 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -14,7 +14,7 @@ var translate = {
14
14
  * 格式:major.minor.patch.date
15
15
  */
16
16
  // AUTO_VERSION_START
17
- version: '3.18.61.20250928',
17
+ version: '3.18.62.20250928',
18
18
  // AUTO_VERSION_END
19
19
  /*
20
20
  当前使用的版本,默认使用v2. 可使用 setUseVersion2();
@@ -843,7 +843,15 @@ var translate = {
843
843
 
844
844
 
845
845
  //如果是自定义术语的key等于value,则是属于指定的某些文本不进行翻译的情况,所以这里要单独判断一下,它俩不相等才会去进行替换操作,免得进行性能计算浪费 - 虽然这一步是不会到的,因为在这个方法的入口处就已经经过这个判定了
846
- if(nodeObject != null){
846
+ if(nodeObject != null && typeof(nodeObject.node) !== 'undefined' && nodeObject.node !== null){
847
+
848
+ // 记录此次node的改变是有 translate.js 导致的,避免被dom改变监听给误以为别的引起的
849
+ if(translate.node.get(nodeObject.node) != null){
850
+ translate.node.get(nodeObject.node).lastTranslateRenderTime = Date.now();
851
+ }else{
852
+ //这个如果有 translate.js 内部自主触发,肯定不会没有值的。但是如果手动再其他程序里触发,那这个是会没有值的
853
+ }
854
+
847
855
  if(nomenclatureKey === nomenclatureValue){
848
856
  //自定义忽略翻译的文字 ,key 跟 value 相等,便是忽略翻译的
849
857
  translate.element.nodeAnalyse.set(nodeObject.node, nomenclatureKey, nomenclatureValue, nodeObject.attribute);
@@ -4092,14 +4100,12 @@ var translate = {
4092
4100
 
4093
4101
 
4094
4102
  //记录 nodeHistory - 判断text是否已经被拆分了
4095
- //console.log(textArray);
4096
- if(textArray.length > 1 || textArray[0] != text){
4103
+ if(textArray.length > 0 && textArray[0] != text){ //主要是后面的是否相等,前面的>0只是避免代码报错
4097
4104
  translate.node.get(node)[nodeAttribute.key].whole = false; //已经被拆分了,不是整体翻译了
4098
4105
  //这时,也默认给其赋值操作,将自定义术语匹配后的结果进行赋予
4099
4106
  }else{
4100
4107
  translate.node.get(node)[nodeAttribute.key].whole = true; //未拆分,是整体翻译
4101
4108
  }
4102
-
4103
4109
  //成功加入到 nodeQueue 的对象。 如果长度为0,那就是还没有加入到 translate.nodeQueue 中,可能全被自定义术语命中了
4104
4110
  var addQueueObjectArray = [];
4105
4111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18n-jsautotranslate",
3
- "version": "3.18.61",
3
+ "version": "3.18.62",
4
4
  "description": "Two lines of js realize automatic html translation. No need to change the page, no language configuration file, no API key, SEO friendly!",
5
5
  "main": "index.js",
6
6
  "scripts": {