Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Localization for Admin Module #281

Closed
jkleinsc opened this issue Jan 22, 2016 · 21 comments
Closed

Localization for Admin Module #281

jkleinsc opened this issue Jan 22, 2016 · 21 comments
Labels
help wanted indicates that an issue is open for contributions

Comments

@jkleinsc
Copy link
Member

Now that i18n support has been added to HospitalRun via PR #248 and issue #141 we need to localize the app. This issue is to track localization for the admin module. Localization in HospitalRun uses Ember-I18n. The translations/default text will be placed in app/locales/en/translations.js.
See https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Translating-Text for information on how to localize the templates.

@jkleinsc jkleinsc added Admin help wanted indicates that an issue is open for contributions labels Jan 22, 2016
@tangollama tangollama modified the milestone: HospitalRun 1.0 Feb 14, 2016
@renato04
Copy link

Hello! I want to help you with pt-br localization, how could i do that?

@jkleinsc
Copy link
Member Author

@renato04 we need to first move the text in the system to app/locales/en/translations.js. Once it is there, it can be translated to pt-br in the app/locales/pt-BR/translations.js.

@renato04
Copy link

@jkleinsc Are there anyone doing this? Could I help to do this?

@jkleinsc
Copy link
Member Author

No one is working on this particular one for the admin module, so you are welcome to work on it. See the directions at the top of this issue. If you do decide to work on it, please comment in this ticket so that we know someone is working on it.

@renato04
Copy link

@jkleinsc Hello,
I'm trying to configure my environment on windows 10, after execute the initcouch.sh from git bash it is showing this message error:

[info] [<0.155.0>] 127.0.0.1 - - PUT /_users/org.couchdb.user:hradmin 500
[error] [<0.155.0>] httpd 500 error response:
{"error":"EXIT","reason":"{{badmatch,\n {error,\n {enoent,\n [{erlang,open_port,\n [{spawn,\n "c:/Program Files (x86)/Apache Software Foundation/CouchDB/lib/couch-1.6.1/priv/couchspawnkillable ./couchjs.exe ../share/couchdb/server/main.js"},\n [stream,{line,4096},binary,exit_status,hide]],\n []},\n {couch_os_process,init,1,\n [{file,\n "c:/cygwin/relax/APACHE2.1/src/couchdb/couch_os_process.erl"},\n {line,148}]},\n {gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},\n {proc_lib,init_p_do_apply,3,\n [{file,"proc_lib.erl"},{line,239}]}]}}},\n [{couch_query_servers,new_process,3,\n [{file,"c:/cygwin/relax/APACHE2.1/src/couchdb/couch_query_servers.erl"},\n {line,477}]},\n {couch_query_servers,lang_proc,3,\n [{file,"c:/cygwin/relax/APACHE2.1/src/couchdb/couch_query_servers.erl"},\n {line,462}]},\n {couch_query_servers,handle_call,3,\n [{file,"c:/cygwin/relax/APACHE2.1/src/couchdb/couch_query_servers.erl"},\n {line,322}]},\n {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,585}]},\n {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}"}

Could anyone help me?

@renato04
Copy link

@jkleinsc I managed to install the database. Now i'm ready to start. I'll start to do this. Ok?

@nerdkid93
Copy link

You probably already figured this out, but for other people to know, you need to make sure that CouchDB is running when you interact with the database. On Windows, you just need to start the "Start CouchDB" script that is added into your start menu when you install CouchDB. You need to do this before running /scripts/initcouch.sh and before you run ember (using 'ember serve').

Hope this helps, and we look forward to your contributions.

@nerdkid93
Copy link

I realize that might not have actually been the solution to your issue. If you did something else to get the script working, could you let me know? I'm curious as I am also developing in Windows 10.

@renato04
Copy link

I'm sorry. I forgot to share the solution.
The couchdb has to be installed in c:\ couchdb folder.
The default is in Program FIles.
After install in c\couchdb folder it worked for me.

@renato04
Copy link

I don't know if i can put this here
I am unable to use the this.get('i18n').t('KEY') in app/mixins/navagition.js

Here it is the message error
Error while processing route: login this.get is not a function TypeError: this.get is not a function

I'm trying in this way:
title: 'Administration', iconClass: 'octicon-person', route: 'admin.lookup', capability: 'admin', subnav: [ { title: this.get('i18n').t('admin.lookup_lists'), iconClass: 'octicon-chevron-right', route: 'admin.lookup', capability: 'update_config' }

@nerdkid93
Copy link

Hmm, I have couch installed in Program Files and it works just fine for me. I bet you just needed to reinstall the program. It might not have installed properly the first time.

@renato04
Copy link

i reinstall a several times. And Apparently it doesn't happen just to me.
I found the solution here http://stackoverflow.com/questions/19672034/couchdb-installs-fine-for-everything-except-execution-of-views-on-win7-x64

@alexpelan
Copy link
Contributor

@renato04 does this approach not work for that field?

https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Translating-Text#translation-computed-property-macro

I think it isn't working because 'this' isn't bound properly to get the i18n service. If just using the t helper doesn't work, you can change it to a property - I had to do that here, for an example: https://github.com/HospitalRun/hospitalrun-frontend/blob/master/app/imaging/route.js#L16

@renato04
Copy link

@alexpelan that approach doesnt work for that field

I tried import and

import Ember from 'ember';
import { translationMacro as t } from 'ember-i18n';
export default Ember.Mixin.create({
  navItems: [
  (...)
  {

      title: 'Administration',
      iconClass: 'octicon-person',
      route: 'admin.lookup',
      capability: 'admin',
      subnav: [
        {
          title: t('admin.lookup_lists'),
          iconClass: 'octicon-chevron-right',
          route: 'admin.lookup',
          capability: 'update_config'
        },
    }
    (...)

This is the error showed on browser multiples times:
DEPRECATION: You modified (-join-classes "primary-section-link nav-link" "ember-view" (-normalize-class "active" active activeClass=undefined inactiveClass=undefined) (-normalize-class "loading" loading activeClass=undefined inactiveClass=undefined) (-normalize-class "disabled" disabled activeClass=undefined inactiveClass=undefined) (-normalize-class "transitioningIn" transitioningIn activeClass=undefined inactiveClass=undefined) (-normalize-class "transitioningOut" transitioningOut activeClass=undefined inactiveClass=undefined)) twice in a single render. This was unreliable in Ember 1.x and will be removed in Ember 2.0 [deprecation id: ember-views.render-double-modify] at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:15219:7) at raiseOnDeprecation (http://localhost:4200/assets/vendor.js:15129:12) at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:15219:7) at handleDeprecationWorkflow (http://localhost:4200/assets/vendor.js:64682:9) at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:15219:7) at deprecationCollector (http://localhost:4200/assets/vendor.js:64704:5) at HANDLERS.(anonymous function) (http://localhost:4200/assets/vendor.js:15219:7) at invoke (http://localhost:4200/assets/vendor.js:15235:7) at deprecate (http://localhost:4200/assets/vendor.js:15188:32)

Thank you for the help

@alexpelan
Copy link
Contributor

@renato04 the second approach I suggested works. You need to change navItems to be a property: here's a gist of how I got it to work: https://gist.github.com/alexpelan/f544e7056a77ae916506

@renato04
Copy link

@alexpelan Thank you for the help. It worked here. But i don't know how to localize the input label like this
{{em-input label="Address 1 Label" property="value.address1Label"}}

@jkleinsc
Copy link
Member Author

@renato04 for items like {{em-input}}, you can use the apporach used for Nesting Translations, so you would end up with something like this:

{{em-input label=(t 'admin.address1_label') property="value.address1Label"}}

@renato04
Copy link

@jkleinsc Thank you, i'll try later and let you know if it work.

@renato04
Copy link

@jkleinsc Thank you your suggestion worked.

Now i'm facing another difficulty, i'm sorry for the many questions, i'm new with this.
I'm trying to localize app\admin\lookup\controller.js and here it is how i'm trying

import Ember from 'ember';
import BillingCategories from 'hospitalrun/mixins/billing-categories';
import LabPricingTypes from 'hospitalrun/mixins/lab-pricing-types';
import ModalHelper from 'hospitalrun/mixins/modal-helper';
import ImagingPricingTypes from 'hospitalrun/mixins/imaging-pricing-types';
import InventoryTypeList from 'hospitalrun/mixins/inventory-type-list';
import UnitTypes from 'hospitalrun/mixins/unit-types';
import VisitTypes from 'hospitalrun/mixins/visit-types';
import { translationMacro as t } from "ember-i18n";
export default Ember.Controller.extend(BillingCategories, LabPricingTypes,
  ModalHelper, ImagingPricingTypes, InventoryTypeList,  UnitTypes, VisitTypes, {
    fileSystem: Ember.inject.service('filesystem'),
    lookupTypes: [{ 
      i18n: Ember.inject.service(),
      name: t('admin.lookup.anesthesia_types'),
      value: 'anesthesia_types',
      model: {
        procedure: 'anesthesiaType'
      }
    },

it is throwing the following error: Uncaught Error: Assertion Failed: Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.

If i try using this.get('i18n').t it throws: this.get is not a function.

Thank you in Advance.

@jkleinsc
Copy link
Member Author

Move the following line to be above the lookupTypes definition:

i18n: Ember.inject.service(),

@renato04
Copy link

@jkleinsc Thank you

I tried your suggestion like this:

import Ember from 'ember';
import BillingCategories from 'hospitalrun/mixins/billing-categories';
import LabPricingTypes from 'hospitalrun/mixins/lab-pricing-types';
import ModalHelper from 'hospitalrun/mixins/modal-helper';
import ImagingPricingTypes from 'hospitalrun/mixins/imaging-pricing-types';
import InventoryTypeList from 'hospitalrun/mixins/inventory-type-list';
import UnitTypes from 'hospitalrun/mixins/unit-types';
import VisitTypes from 'hospitalrun/mixins/visit-types';
import { translationMacro as t } from "ember-i18n";
export default Ember.Controller.extend(BillingCategories, LabPricingTypes,
  ModalHelper, ImagingPricingTypes, InventoryTypeList,  UnitTypes, VisitTypes, {
    fileSystem: Ember.inject.service('filesystem'),
    i18n: Ember.inject.service(),
    lookupTypes:  [{
      name: t('lookup.anesthesia_types'),
      value: 'anesthesia_types',
      model: {
        procedure: 'anesthesiaType'
      }
    }

And it is throwing this error:
Uncaught Error: Assertion Failed: Cannot translate lookup.anesthesia_types. [object Object] does not have an i18n.

Update

I resolved this question following this suggestion
https://github.com/jamesarosen/ember-i18n/issues/352

@jkleinsc Thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted indicates that an issue is open for contributions
Projects
None yet
Development

No branches or pull requests

5 participants