Bug 1514126 - Fix broken address book contact UI by correcting dodgy translations. r=mkmelin a=jorgk
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 27 Feb 2019 11:27:25 +1300
changeset 33515 ea9948ac39b0c4a5e26e6c5370e24adf0a9cbd32
parent 33514 2960e4a6cec05f9fcd3061719f64772a112167ec
child 33516 080b31a50795e4f47ca3243fde40de737c0b4d9b
push id2384
push usermozilla@jorgk.com
push dateWed, 06 Mar 2019 00:14:50 +0000
treeherdercomm-beta@33baca79596d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1514126
Bug 1514126 - Fix broken address book contact UI by correcting dodgy translations. r=mkmelin a=jorgk
mail/components/addrbook/content/abCard.inc.xul
mail/components/addrbook/content/abCard.js
--- a/mail/components/addrbook/content/abCard.inc.xul
+++ b/mail/components/addrbook/content/abCard.inc.xul
@@ -35,17 +35,17 @@
               <label control="&NameField1.id;" value="&NameField1.label;"
                      accesskey="&NameField1.accesskey;"/>
               <hbox class="CardEditWidth" align="center">
                 <textbox id="&NameField1.id;" flex="1"
                          oninput="GenerateDisplayName()"/>
 
                 <!-- LOCALIZATION NOTE:
                      Fields for phonetic are disabled as default and can be
-                     enabled by^editing "mail.addr_book.show_phonetic_fields"
+                     enabled by editing "mail.addr_book.show_phonetic_fields"
                   -->
 
                 <spacer id="PhoneticSpacer1" flex="1" hidden="true"/>
                 <label id="PhoneticLabel1" control="&PhoneticField1.id;"
                        value="&PhoneticField1.label;" hidden="true"/>
                 <textbox id="&PhoneticField1.id;" flex="1" hidden="true"/>
               </hbox>
             </hbox>
--- a/mail/components/addrbook/content/abCard.js
+++ b/mail/components/addrbook/content/abCard.js
@@ -380,16 +380,33 @@ function InitPhoneticFields() {
   if (showPhoneticFields == "true") {
     for (var i = kPhoneticFields.length; i-- > 0;) {
       document.getElementById(kPhoneticFields[i]).hidden = false;
     }
   }
 }
 
 function InitEditCard() {
+  // Fix broken element IDs caused by translation mistakes. NameField1's ID should be either
+  // "FirstName" or "LastName", and if it isn't, make it so.
+  let nameField1Container = document.getElementById("NameField1Container");
+  let nameField1 = nameField1Container.querySelector("textbox");
+  if (nameField1.id != "FirstName" && nameField1.id != "LastName") {
+    nameField1Container.querySelector("label").setAttribute("control", "FirstName");
+    nameField1.id = "FirstName";
+    nameField1Container.querySelector("textbox ~ label").setAttribute("control", "PhoneticFirstName");
+    nameField1Container.querySelector("textbox ~ textbox").id = "PhoneticFirstName";
+
+    let nameField2Container = document.getElementById("NameField2Container");
+    nameField2Container.querySelector("label").setAttribute("control", "LastName");
+    nameField2Container.querySelector("textbox").id = "LastName";
+    nameField2Container.querySelector("textbox ~ label").setAttribute("control", "PhoneticLastName");
+    nameField2Container.querySelector("textbox ~ textbox").id = "PhoneticLastName";
+  }
+
   InitPhoneticFields();
 
   InitCommonJS();
 
   // Create gEditCard object that contains global variables for the current js
   //   file.
   gEditCard = {};