From ca5c5d8e500fd1adf5f9f6d4d40ca8b2dc63391d Mon Sep 17 00:00:00 2001 From: Alex Pelan Date: Sun, 24 Jan 2016 20:44:22 -0500 Subject: [PATCH] Fixes #277: Localization for Imaging Module --- app/components/nav-menu.js | 1 - app/controllers/abstract-edit-controller.js | 10 ++-- app/imaging/completed/route.js | 3 +- app/imaging/completed/template.hbs | 8 ++-- app/imaging/edit/controller.js | 12 +++-- app/imaging/edit/route.js | 5 +- app/imaging/edit/template.hbs | 16 +++---- app/imaging/index/route.js | 4 +- app/imaging/index/template.hbs | 2 +- app/imaging/route.js | 24 ++++++---- app/initializers/i18n.js | 11 +++++ app/locales/en/translations.js | 50 +++++++++++++++++++- app/mixins/modal-helper.js | 7 ++- app/templates/components/patient-summary.hbs | 6 +-- 14 files changed, 115 insertions(+), 44 deletions(-) create mode 100644 app/initializers/i18n.js diff --git a/app/components/nav-menu.js b/app/components/nav-menu.js index b3cc61783d..e416fa8dc0 100644 --- a/app/components/nav-menu.js +++ b/app/components/nav-menu.js @@ -27,7 +27,6 @@ export default Ember.Component.extend(UserSession, { actions: { toggleContent: function() { - // debugger; this.set('isShowing', !this.get('isShowing')); this.sendAction('callNavAction', this.nav); }, diff --git a/app/controllers/abstract-edit-controller.js b/app/controllers/abstract-edit-controller.js index f39e85ce45..ccdf04d666 100644 --- a/app/controllers/abstract-edit-controller.js +++ b/app/controllers/abstract-edit-controller.js @@ -7,11 +7,12 @@ export default Ember.Controller.extend(EditPanelProps, IsUpdateDisabled, ModalHe cancelAction: 'allItems', cancelButtonText: function() { + let i18n = this.get('i18n'); var hasDirtyAttributes = this.get('model.hasDirtyAttributes'); if (hasDirtyAttributes) { - return 'Cancel'; + return i18n.t('buttons.cancel'); } else { - return 'Return'; + return i18n.t('buttons.return_button'); } }.property('model.hasDirtyAttributes'), @@ -43,10 +44,11 @@ export default Ember.Controller.extend(EditPanelProps, IsUpdateDisabled, ModalHe updateButtonAction: 'update', updateButtonText: function() { + let i18n = this.get('i18n'); if (this.get('model.isNew')) { - return 'Add'; + return i18n.t('buttons.add'); } else { - return 'Update'; + return i18n.t('buttons.update'); } }.property('model.isNew'), updateCapability: null, diff --git a/app/imaging/completed/route.js b/app/imaging/completed/route.js index aa21a02163..4d0a68ae69 100755 --- a/app/imaging/completed/route.js +++ b/app/imaging/completed/route.js @@ -1,5 +1,6 @@ +import { translationMacro as t } from 'ember-i18n'; import ImagingIndexRoute from 'hospitalrun/imaging/index/route'; export default ImagingIndexRoute.extend({ - pageTitle: 'Completed Imaging', + pageTitle: t('imaging.titles.completed_imaging'), searchStatus: 'Completed' }); diff --git a/app/imaging/completed/template.hbs b/app/imaging/completed/template.hbs index 2879f02f16..03209578e6 100644 --- a/app/imaging/completed/template.hbs +++ b/app/imaging/completed/template.hbs @@ -3,10 +3,10 @@ - + - - + + {{#each model as |imaging|}} @@ -22,7 +22,7 @@
{{t 'labels.date_requested'}}Date Completed{{t 'labels.date_completed'}} {{t 'labels.patient'}}{{t 'labels.imaging_type'}}Results{{t 'labels.imaging_type '}}{{t 'labels.results'}} {{t 'labels.notes'}}
{{else}}
-

No completed items found.

+

{{t 'imaging.messages.no_completed'}}

{{/if}} {{/item-listing}} diff --git a/app/imaging/edit/controller.js b/app/imaging/edit/controller.js index 067ccb6958..581cfec0d3 100644 --- a/app/imaging/edit/controller.js +++ b/app/imaging/edit/controller.js @@ -69,6 +69,7 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, { }, additionalButtons: function() { + let i18n = this.get('i18n'); var canComplete = this.get('canComplete'), isValid = this.get('model.isValid'); if (isValid && canComplete) { @@ -76,7 +77,7 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, { buttonAction: 'completeImaging', buttonIcon: 'glyphicon glyphicon-ok', class: 'btn btn-primary on-white', - buttonText: 'Complete' + buttonText: i18n.t('buttons.complete') }]; } }.property('canComplete', 'model.isValid'), @@ -97,16 +98,17 @@ export default AbstractEditController.extend(ChargeActions, PatientSubmodule, { updateCapability: 'add_imaging', afterUpdate: function(saveResponse, multipleRecords) { + let i18n = this.get('i18n'); this.updateLookupLists(); var afterDialogAction, alertTitle, alertMessage; if (this.get('model.status') === 'Completed') { - alertTitle = 'Imaging Request Completed'; - alertMessage = 'The imaging request has been completed.'; + alertTitle = i18n.t('imaging.alerts.completed_title'); + alertMessage = i18n.t('imaging.alerts.completed_message'); } else { - alertTitle = 'Imaging Request Saved'; - alertMessage = 'The imaging request has been saved.'; + alertTitle = i18n.t('imaging.alerts.saved_title'); + alertMessage = i18n.t('imaging.alerts.saved_message'); } if (multipleRecords) { afterDialogAction = this.get('cancelAction'); diff --git a/app/imaging/edit/route.js b/app/imaging/edit/route.js index d36fa71122..4cfab00d62 100644 --- a/app/imaging/edit/route.js +++ b/app/imaging/edit/route.js @@ -1,11 +1,12 @@ +import { translationMacro as t } from 'ember-i18n'; import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; import ChargeRoute from 'hospitalrun/mixins/charge-route'; import Ember from 'ember'; import PatientListRoute from 'hospitalrun/mixins/patient-list-route'; export default AbstractEditRoute.extend(ChargeRoute, PatientListRoute, { - editTitle: 'Edit Imaging Request', + editTitle: t('imaging.titles.edit_title'), modelName: 'imaging', - newTitle: 'New Imaging Request', + newTitle: t('imaging.titles.new_title'), pricingCategory: 'Imaging', getNewData: function() { diff --git a/app/imaging/edit/template.hbs b/app/imaging/edit/template.hbs index 39ceb6a38d..6110c97610 100644 --- a/app/imaging/edit/template.hbs +++ b/app/imaging/edit/template.hbs @@ -1,21 +1,21 @@ {{#edit-panel editPanelProps=editPanelProps}} {{#em-form model=model submitButton=false }} {{#if model.selectPatient}} - {{patient-typeahead property="patientTypeAhead" label="Patient" content=patientList selection=selectedPatient class="required patient-input"}} + {{patient-typeahead property="patientTypeAhead" label=(t 'labels.patient')content=patientList selection=selectedPatient class="required patient-input"}} {{else}} {{patient-summary patient=model.patient returnTo='imaging.edit' returnToContext=model.id disablePatientLink=model.isNew }} {{/if}} {{#if model.isNew}}
- {{em-select class="col-xs-3 required" label="Visit" + {{em-select class="col-xs-3 required" label=(t 'labels.visit') property="visit" content=patientVisitsForSelect optionValuePath="selectObject" optionLabelPath="selectObject.visitDescription" - prompt="--Add New Visit--" + prompt=(t 'imaging.labels.add_new_visit') selected=model.visit }}
{{checkbox-or-typeahead property="imagingTypeName" - label="Imaging Type" list=objectTypeList + label=(t 'labels.imaging_type') list=objectTypeList selection=selectedImagingType optionLabelPath='name' typeAheadType='pricing' @@ -27,7 +27,7 @@ {{else}}
- +

{{model.visit.visitDate}}

@@ -38,12 +38,12 @@ {{/if}} {{#if canComplete}} {{select-or-typeahead property="radiologist" - label="Radiologist" list=radiologistList + label=(t 'imaging.labels.radiologist') list=radiologistList prompt=" " class="radiologist-input" }} - {{em-input property="result" label="Result" class="result-input"}} + {{em-input property="result" label=(t 'labels.result') class="result-input"}} {{/if}} - {{em-text property="notes" label="Notes" rows=3 }} + {{em-text property="notes" label=(t 'labels.notes') rows=3 }} {{/em-form}} {{/edit-panel}} diff --git a/app/imaging/index/route.js b/app/imaging/index/route.js index b6c70d6a45..72561007d7 100644 --- a/app/imaging/index/route.js +++ b/app/imaging/index/route.js @@ -1,7 +1,8 @@ +import { translationMacro as t } from 'ember-i18n'; import AbstractIndexRoute from 'hospitalrun/routes/abstract-index-route'; export default AbstractIndexRoute.extend({ modelName: 'imaging', - pageTitle: 'Imaging Requests', + pageTitle: t('imaging.page_title'), searchStatus: 'Requested', _getStartKeyFromItem: function(item) { @@ -11,7 +12,6 @@ export default AbstractIndexRoute.extend({ searchStatus = this.get('searchStatus'); return [searchStatus, requestedDateAsTime, imagingDateAsTime, id]; }, - _modelQueryParams: function() { var maxId = this._getMaxPouchId(), maxValue = this.get('maxValue'), diff --git a/app/imaging/index/template.hbs b/app/imaging/index/template.hbs index 40d3b1fcc5..87d0def83c 100644 --- a/app/imaging/index/template.hbs +++ b/app/imaging/index/template.hbs @@ -28,7 +28,7 @@ {{else}}
-

No items found. {{#if canAdd}} Create a new record?{{/if}}

+

{{t 'messages.no_items_found'}} {{#if canAdd}} {{t 'messages.create_new_record'}}{{/if}}

{{/if}} {{/item-listing}} diff --git a/app/imaging/route.js b/app/imaging/route.js index bfbada2b54..7dff4ac6ff 100644 --- a/app/imaging/route.js +++ b/app/imaging/route.js @@ -1,3 +1,4 @@ +import { translationMacro as t } from 'ember-i18n'; import AbstractModuleRoute from 'hospitalrun/routes/abstract-module-route'; export default AbstractModuleRoute.extend({ addCapability: 'add_imaging', @@ -10,14 +11,19 @@ export default AbstractModuleRoute.extend({ }], allowSearch: false, moduleName: 'imaging', - newButtonText: '+ new imaging', - sectionTitle: 'Imaging', - subActions: [{ - text: 'Requests', - linkTo: 'imaging.index' - }, { - text: 'Completed', - linkTo: 'imaging.completed' - }] + newButtonText: t('imaging.buttons.new_button'), + sectionTitle: t('imaging.section_title'), + subActions: function() { + let i18n = this.get("i18n"); + + return [{ + text: i18n.t('labels.requests'), + linkTo: 'imaging.index' + }, { + text: i18n.t('labels.completed'), + linkTo: 'imaging.completed' + }]; + + }.property() }); diff --git a/app/initializers/i18n.js b/app/initializers/i18n.js new file mode 100644 index 0000000000..02511aad45 --- /dev/null +++ b/app/initializers/i18n.js @@ -0,0 +1,11 @@ +export default { + name: 'i18n', + + after: 'ember-i18n', + + initialize: function(app) { + app.inject('route', 'i18n', 'service:i18n'); + app.inject('controller', 'i18n', 'service:i18n'); + app.inject('mixin', 'i18n', 'service:i18n'); + } +}; \ No newline at end of file diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index cebbaddf08..ae1be91df4 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -8,13 +8,34 @@ export default { quantity: 'Quantity', requested_on: 'Requested On', date_requested: 'Date Requested', + date_completed: 'Date Completed', requested_by: 'Requested By', fulfill: 'Fulfill', actions: 'Actions', action: 'Action', notes: 'Notes', edit: 'Edit', - imaging_type: 'Imaging Type' + imaging_type: 'Imaging Type', + result: 'Result', + results: 'Results', + visit: 'Visit', + requests: 'Requests', + completed: 'Completed', + id: 'Id', + gender: 'Gender', + age: 'Age' + }, + messages: { + no_items_found: 'No items found.', + create_new_record: 'Create a new record?' + }, + buttons: { + complete: 'Complete', + cancel: 'Cancel', + return_button: 'Return', + add: 'Add', + update: 'Update', + ok: 'Ok' }, login: { messages: { @@ -31,5 +52,30 @@ export default { no_requests: 'No requests found.', create_request: 'Create a new request?' } - } + }, + imaging : { + page_title: 'Imaging Requests', + section_title: 'Imaging', + buttons: { + new_button: '+ new imaging', + }, + labels: { + radiologist: 'Radiologist', + add_new_visit: '--Add New Visit--' + }, + messages: { + no_completed: 'No completed items found.' + }, + titles: { + completed_imaging: 'Completed Imaging', + edit_title: 'Edit Imaging Request', + new_title: 'New Imaging Request' + }, + alerts: { + completed_title: 'Imaging Request Completed', + completed_message: 'The imaging request has been completed.', + saved_title: 'Imaging Request Saved', + saved_message: 'The imaging request has been saved.' + } + } }; diff --git a/app/mixins/modal-helper.js b/app/mixins/modal-helper.js index b41ddd466f..1077ecf7d4 100644 --- a/app/mixins/modal-helper.js +++ b/app/mixins/modal-helper.js @@ -6,13 +6,16 @@ export default Ember.Mixin.create({ * @param message string containing the message to display. */ displayAlert: function(title, message, okAction) { - this.send('openModal', 'dialog', Ember.Object.create({ + let i18n = this.get('i18n'); + let modalOptions = Ember.Object.extend({ + updateButtonText: i18n.t('buttons.ok') + }); + this.send('openModal', 'dialog', modalOptions.create({ title: title, message: message, okAction: okAction, hideCancelButton: true, updateButtonAction: 'ok', - updateButtonText: 'Ok' })); }, diff --git a/app/templates/components/patient-summary.hbs b/app/templates/components/patient-summary.hbs index 00b4b74030..e852a03ba8 100644 --- a/app/templates/components/patient-summary.hbs +++ b/app/templates/components/patient-summary.hbs @@ -2,16 +2,16 @@
- {{patient.displayPatientId}} + {{patient.displayPatientId}}
{{patient.displayName}}
- {{patient.gender}} + {{patient.gender}}
- {{patient.age}} + {{patient.age}}
{{#if havePrimaryDiagnoses}}