From 9d4ce86fff2b2c1d3ace88d5379e68de06b71d1a Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 29 Jun 2017 17:09:54 -0400 Subject: [PATCH] LP#1708291: introduce egI18N 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 Signed-off-by: Kathy Lussier Conflicts: Open-ILS/src/templates/staff/base_js.tt2 Open-ILS/web/js/ui/default/staff/Gruntfile.js Signed-off-by: Dan Wells --- Open-ILS/src/templates/staff/base_js.tt2 | 2 ++ Open-ILS/web/js/ui/default/staff/Gruntfile.js | 3 ++- .../web/js/ui/default/staff/services/coresvc.js | 7 ++++--- Open-ILS/web/js/ui/default/staff/services/i18n.js | 22 ++++++++++++++++++++++ .../web/js/ui/default/staff/test/karma.conf.js | 1 + 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 Open-ILS/web/js/ui/default/staff/services/i18n.js diff --git a/Open-ILS/src/templates/staff/base_js.tt2 b/Open-ILS/src/templates/staff/base_js.tt2 index 24742454a6..5d93fbe344 100644 --- a/Open-ILS/src/templates/staff/base_js.tt2 +++ b/Open-ILS/src/templates/staff/base_js.tt2 @@ -123,6 +123,7 @@ UpUp.start({ + @@ -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}})') %]"; }]); diff --git a/Open-ILS/web/js/ui/default/staff/Gruntfile.js b/Open-ILS/web/js/ui/default/staff/Gruntfile.js index d8a05e1f2a..13ae1dabb2 100644 --- a/Open-ILS/web/js/ui/default/staff/Gruntfile.js +++ b/Open-ILS/web/js/ui/default/staff/Gruntfile.js @@ -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' }, diff --git a/Open-ILS/web/js/ui/default/staff/services/coresvc.js b/Open-ILS/web/js/ui/default/staff/services/coresvc.js index f75477047a..c1218cc80a 100644 --- a/Open-ILS/web/js/ui/default/staff/services/coresvc.js +++ b/Open-ILS/web/js/ui/default/staff/services/coresvc.js @@ -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 index 0000000000..2c521d0630 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/services/i18n.js @@ -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() + } + ); + } + } +}]); diff --git a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js index 0b30d4ad8c..12cc87e274 100644 --- a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js +++ b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js @@ -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', -- 2.11.0