[gnome-characters] character: Don't capitalize acronyms



commit f33d70e0db91c61c9a7c39d6422efb50628a0110
Author: Daiki Ueno <dueno src gnome org>
Date:   Tue Aug 25 11:21:06 2015 +0900

    character: Don't capitalize acronyms

 src/util.js |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/util.js b/src/util.js
index 14e8bf1..2c17482 100644
--- a/src/util.js
+++ b/src/util.js
@@ -124,11 +124,24 @@ function assertNotEqual(one, two) {
         throw Error('Assertion failed: ' + one + ' == ' + two);
 }
 
+function capitalizeWord(w) {
+    if (w.length > 0)
+        return w[0].toUpperCase() + w.slice(1).toLowerCase()
+    return w;
+}
+
 function capitalize(s) {
     return s.split(/\s+/).map(function(w) {
-        if (w.length > 0)
-            return w[0].toUpperCase() + w.slice(1).toLowerCase();
-        return w;
+        let acronyms = ["CJK"];
+        if (acronyms.indexOf(w) > -1)
+            return w;
+        let prefixes = ["IDEOGRAPH-", "SELECTOR-"];
+        for (let index in prefixes) {
+            let prefix = prefixes[index];
+            if (w.startsWith(prefix))
+                return capitalizeWord(prefix) + w.slice(prefix.length);
+        }
+        return capitalizeWord(w);
     }).join(' ');
 }
 


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