trans-coord-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trans-coord/gnun/server/gnun ChangeLog link-dif...


From: Ineiev
Subject: trans-coord/gnun/server/gnun ChangeLog link-dif...
Date: Sat, 2 Sep 2017 07:11:54 -0400 (EDT)

CVSROOT:        /sources/trans-coord
Module name:    trans-coord
Changes by:     Ineiev <ineiev> 17/09/02 07:11:54

Modified files:
        gnun/server/gnun: ChangeLog link-diff.awk 

Log message:
        (pacify_translator_notes): Be more permissive about link order.
        (extract_link): New function.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/trans-coord/gnun/server/gnun/ChangeLog?cvsroot=trans-coord&r1=1.460&r2=1.461
http://cvs.savannah.gnu.org/viewcvs/trans-coord/gnun/server/gnun/link-diff.awk?cvsroot=trans-coord&r1=1.2&r2=1.3

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/trans-coord/trans-coord/gnun/server/gnun/ChangeLog,v
retrieving revision 1.460
retrieving revision 1.461
diff -u -b -r1.460 -r1.461
--- ChangeLog   26 Aug 2017 09:16:40 -0000      1.460
+++ ChangeLog   2 Sep 2017 11:11:54 -0000       1.461
@@ -1,3 +1,9 @@
+2017-09-02  Pavel Kharitonov  <address@hidden>
+
+       * link-diff.awk (pacify_translator_notes):
+       Be more permissive about link order.
+       * link-diff.awk (extract_link): New function.
+
 2017-08-26  Pavel Kharitonov  <address@hidden>
 
        * link-diff.awk: Take into account more CC licenses.

Index: link-diff.awk
===================================================================
RCS file: /sources/trans-coord/trans-coord/gnun/server/gnun/link-diff.awk,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- link-diff.awk       26 Aug 2017 09:16:40 -0000      1.2
+++ link-diff.awk       2 Sep 2017 11:11:54 -0000       1.3
@@ -289,17 +289,27 @@
   return text
 }
 
+# Get link text from difference notation.
+function extract_link(text)
+{
+  return substr(text, index(text, ":") + 1)
+}
+
 # Suppress certain differences:
 # * Local links from translations to ids defined in translator's notes
 #   are allowed.
 # * Local (back) links from translator's notes to ids additionally
 #   defined in translations are allowed.
 # * Links from translator's credits are allowed.
+# * Pairs of links that exchange their order, like
+#   <a href="rms">rms</a>'s <a href="lec">lecture</a> ->
+#   -> <a href="lec">lecture</a> by <a href="rms">rms</a>
 function pacify_translator_notes(\
  i, j, n, m, trans_notes, back_trans_notes, tn, tn_i, t, link, k)
 {
   trans_notes = ""
   back_trans_notes = ""
+  # Extract translator's notes; drop any links in translator's credits.
   for (i = 0; i < msg_no; i++)
     if (msg_ids[i] == "*GNUN-SLOT: TRANSLATOR'S NOTES*")
       {
@@ -314,8 +324,41 @@
       }
     else if (msg_ids[i] == "*GNUN-SLOT: TRANSLATOR'S CREDITS*")
       link_diff[i] = ""
+  # Suppress pairs of links that changed their order in the text by one.
+  for (i = 0; i < msg_no; i++)
+    {
+      if (link_diff[i] == "")
+        continue
+      n = split(link_diff[i], t, "\n")
+      if (n < 2)
+        continue
+      link = ""
+      for (j = 1; j < n; j++)
+        {
+          if (substr(t[j], 1, 1) != "-")
+            {
+              link = link "\n" t[j]
+              continue
+            }
+          if (substr(t[j + 1], 1, 1) != "+")
+            {
+              link = link "\n" t[j]
+              continue
+            }
+          if (extract_link(t[j]) == extract_link(t[j + 1]))
+            {
+              j++
+              continue
+            }
+          link = link "\n" t[j]
+        }
+      if (j == n)
+        link = link "\n" t[j]
+      link_diff[i] = substr(link, 2)
+    }
   if (trans_notes == "")
     return
+  # Suppress links to translator's notes.
   n = split(trans_notes, tn, "\n")
   for (i = 1; i <= n; i++)
     sub(/[^:]*:/, "", tn[i])
@@ -326,8 +369,7 @@
         {
           if (substr(t[j], 1, 1) != "+")
             continue
-          link = t[j]
-          sub(/.*:/, "", link)
+          link = extract_link(t[j])
           for (k = 1; k <= n; k++)
             if ("#" tn[k] == link)
               {
@@ -341,6 +383,7 @@
           link_diff[i] = link_diff[i] "\n" t[j]
       link_diff[i] = substr(link_diff[i], 2)
     }
+  # Suppress new local links from translator's notes.
   n = split(back_trans_notes, tn, "\n")
   for (i = 1; i <= n; i++)
     sub(/[^:]*:/, "", tn[i])
@@ -351,8 +394,7 @@
         {
           if (substr(t[j], 1, 1) != "+")
             continue
-          link = t[j]
-          sub(/.*:/, "", link)
+          link = extract_link(t[j])
           for (k = 1; k <= n; k++)
             if (tn[k] == "#" link)
               {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]