LP#1708291: introduce egI18N
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 29 Jun 2017 21:09:54 +0000 (17:09 -0400)
committerDan Wells <dbw2@calvin.edu>
Fri, 1 Sep 2017 16:47:32 +0000 (12:47 -0400)
egI18N is a module that will serve as a grab-bag of functions
related to I18N and L10N. The initial function it provides
takes a acpl IDL object and returns a formatted name qualified
by the org unit, with the underlying template accessible
to the translation subsystem.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Conflicts:
Open-ILS/src/templates/staff/base_js.tt2
Open-ILS/web/js/ui/default/staff/Gruntfile.js

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/templates/staff/base_js.tt2
Open-ILS/web/js/ui/default/staff/Gruntfile.js
Open-ILS/web/js/ui/default/staff/services/coresvc.js
Open-ILS/web/js/ui/default/staff/services/i18n.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/test/karma.conf.js

index 2474245..5d93fbe 100644 (file)
@@ -123,6 +123,7 @@ UpUp.start({
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/user.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/navbar.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/i18n.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/date.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/op_change.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/lovefield.js"></script>
@@ -184,6 +185,7 @@ UpUp.start({
     s.ITEM_NOT_FOUND = "[% l('Item not found') %]";
     s.CONFIRM_CLEAR_PENDING = "[% l('Clear pending transactions') %]";
     s.CONFIRM_CLEAR_PENDING_BODY = "[% l('Are you certain you want to clear these pending offline transactions? This action is irreversible. Transactions cannot be recovered after clearing!') %]";
+    s.LOCATION_NAME_OU_QUALIFIED = "[% l('{{location_name}} ({{owning_lib_shortname}})') %]";
   }]);
 </script>
 
index d8a05e1..13ae1da 100644 (file)
@@ -183,7 +183,8 @@ module.exports = function(grunt) {
             'services/ui.js',
             'services/date.js',
             'services/op_change.js',
-            'services/file.js'
+            'services/file.js',
+            'services/i18n.js'
         ],
         dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js'
       },
index f754770..c1218cc 100644 (file)
@@ -10,10 +10,10 @@ angular.module('egCoreMod')
 .factory('egCore', 
        ['egIDL','egNet','egEnv','egOrg','egPCRUD','egEvent','egAuth',
         'egPerm','egHatch','egPrint','egStartup','egStrings','egAudio',
-        'egDate',
+        'egDate','egI18N',
 function(egIDL , egNet , egEnv , egOrg , egPCRUD , egEvent , egAuth ,
          egPerm , egHatch , egPrint , egStartup , egStrings , egAudio , 
-         egDate) {
+         egDate , egI18N) {
 
     return {
         idl     : egIDL,
@@ -29,7 +29,8 @@ function(egIDL , egNet , egEnv , egOrg , egPCRUD , egEvent , egAuth ,
         startup : egStartup,
         strings : egStrings,
         audio   : egAudio,
-        date    : egDate
+        date    : egDate,
+        i18n    : egI18N
     };
 
 }]);
diff --git a/Open-ILS/web/js/ui/default/staff/services/i18n.js b/Open-ILS/web/js/ui/default/staff/services/i18n.js
new file mode 100644 (file)
index 0000000..2c521d0
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * egI18N : service for I18N and L10N functions
+ *
+ * This is a grab-bag of stuff related to I18N.
+ *
+ */
+
+angular.module('egCoreMod')
+.factory('egI18N', ['egStrings',
+            function(egStrings) {
+    return {
+        ou_qualified_location_name : function(loc) {
+            return egStrings.$replace(
+                egStrings.LOCATION_NAME_OU_QUALIFIED,
+                {
+                    location_name : loc.name(),
+                    owning_lib_shortname : loc.owning_lib().shortname()
+                }
+            );
+        }        
+    }
+}]);
index 0b30d4a..12cc87e 100644 (file)
@@ -50,6 +50,7 @@ module.exports = function(config){
       'services/lovefield.js',
       'services/navbar.js', 'services/date.js',
       'services/user-bucket.js',
+      'services/i18n.js',
       // load app scripts
       'app.js',
       'circ/**/*.js',