From 20958379b851ddc10f3510a3f70ec1698891a5fc Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Thu, 2 Nov 2017 20:11:18 -0400
Subject: [PATCH] localize and update welcome message, suprress font message if
 font is optimal

---
 pd/nw/index.html                  |  4 +---
 pd/nw/index.js                    | 18 +++++++++++++-----
 pd/nw/locales/en/translation.json |  2 ++
 pd/nw/pdgui.js                    |  3 +++
 4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/pd/nw/index.html b/pd/nw/index.html
index 0a51f10d5..32da532bc 100644
--- a/pd/nw/index.html
+++ b/pd/nw/index.html
@@ -26,9 +26,7 @@
     <input style="display:none;" id="saveDialog" type="file" nwsaveas />
     <div id = "console_bottom">
       <div id = "printout">
-        <pre id="p1"
-             style="white-space: pre-wrap;">Welcome to Pd GUI using Node-Webkit
-        <script>document.write(process.versions['node-webkit'])</script><br/></pre> 
+        <pre id="p1" style="white-space: pre-wrap;"></pre>
       </div>
     </div>
     <div id="console_find" style="display:none;">
diff --git a/pd/nw/index.js b/pd/nw/index.js
index b852054c0..862a056af 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -62,11 +62,6 @@ function set_vars(win) {
     // nw context callbacks (mostly just creating/destroying windows)
     pdgui.set_new_window_fn(nw_create_window);
     pdgui.set_close_window_fn(nw_close_window);
-    if (!font_engine_sanity) {
-        pdgui.post("warning: your system's font stack is maintained by troglodytes.");
-    } else {
-        pdgui.post("font stack check: using optimal font sizes.");
-    }
 }
 
 function app_quit() {
@@ -743,12 +738,25 @@ function nw_create_pd_window_menus(gui, w) {
     });
 }
 
+function post_startup_messages() {
+    // These will be the first messages printed to the main Pd window.
+    // Later let's use a link to the docs for new users.
+    pdgui.post(l("pd_window.welcome"));
+    // Warn the user if the font sizes aren't optimal. Font sizes which
+    // aren't optimal result in extra space at the end of object/message
+    // boxes
+    if (!pdgui.get_font_engine_sanity()) {
+        pdgui.post(l("pd_window.font_size_warning"));
+    }
+}
+
 function gui_init(win) {
     set_vars(win);
     add_events();
     nw_create_pd_window_menus(gui, win);
     // Set up the Pd Window
     gui.Window.get().setMinimumSize(350, 250);
+    post_startup_messages();
     // Now we create a connection from the GUI to Pd, in one of two ways:
     // 1) If the GUI was started by Pd, then we create a tcp client and
     //    connect on the port Pd fed us in our command line arguments.
diff --git a/pd/nw/locales/en/translation.json b/pd/nw/locales/en/translation.json
index 62814d604..0d7721090 100644
--- a/pd/nw/locales/en/translation.json
+++ b/pd/nw/locales/en/translation.json
@@ -270,6 +270,8 @@
     "devtools_tt": "Show the DevTools window (for debugging)"
   },
   "pd_window": {
+    "welcome": "Welcome to Purr Data",
+    "font_size_warning": "warning: your system's font stack is not optimal",
     "find": {
       "placeholder": "Search in Console"
     }
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 84ffa4b0b..02a37e72e 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -127,6 +127,9 @@ exports.set_font_engine_sanity = function(win) {
         font_engine_sanity = false;
     }
     canvas.parentNode.removeChild(canvas);
+}
+
+exports.get_font_engine_sanity = function() {
     return font_engine_sanity;
 }
 
-- 
GitLab