{"action":"opened","issue":{"url":"https://api.github.com/repos/OSC/ood_core/issues/68","repository_url":"https://api.github.com/repos/OSC/ood_core","labels_url":"https://api.github.com/repos/OSC/ood_core/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/OSC/ood_core/issues/68/comments","events_url":"https://api.github.com/repos/OSC/ood_core/issues/68/events","html_url":"https://github.com/OSC/ood_core/issues/68","id":284757666,"number":68,"title":"Define Adapter#tr for localization support","user":{"login":"ericfranz","id":512333,"avatar_url":"https://avatars2.githubusercontent.com/u/512333?v=4","gravatar_id":"","url":"https://api.github.com/users/ericfranz","html_url":"https://github.com/ericfranz","followers_url":"https://api.github.com/users/ericfranz/followers","following_url":"https://api.github.com/users/ericfranz/following{/other_user}","gists_url":"https://api.github.com/users/ericfranz/gists{/gist_id}","starred_url":"https://api.github.com/users/ericfranz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericfranz/subscriptions","organizations_url":"https://api.github.com/users/ericfranz/orgs","repos_url":"https://api.github.com/users/ericfranz/repos","events_url":"https://api.github.com/users/ericfranz/events{/privacy}","received_events_url":"https://api.github.com/users/ericfranz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-12-27T16:46:04Z","updated_at":"2017-12-27T16:46:04Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"In Qt, localization is used by wrapping a tr method around every string. In Rails, its using http://guides.rubyonrails.org/i18n.html I18n.translate method which has a short `t` i.e. instead of\r\n\r\n```ruby\r\n  def index\r\n    flash[:notice] = \"Hello flash!\"\r\n  end\r\n```\r\n\r\nyou would do\r\n\r\n```ruby\r\n  def index\r\n    flash[:notice] = t(:hello_flash)\r\n  end\r\n```\r\n\r\nAnd then in `config/locales/en.yml` you would have:\r\n\r\n```yaml\r\nen:\r\n  hello_flash: Hello flash!\r\n```\r\n\r\nand `config/locales/fr.yml` you would have:\r\n\r\n```yaml\r\nfr:\r\n  hello_flash: Bonjour Flash\r\n```\r\n\r\nTypically this works because there is some global value like `I18n.locale == 'en'` or `I18n.locale == 'fr'` specifying the locale to use, so when the `translate` or `t` method is called it knows what value to return for the key `:hello_flash`.\r\n\r\nIn OnDemand's case, our \"locale\" is the adapter subclass type being used (Slurm, PBS Pro, Torque) and an example of a word that needs internalized is \"queue\" (for Torque) and \"partition\" (for Slurm).\r\n\r\nSo instead we should use something like:\r\n\r\n`Adapter#tr(:queue)` which the base class returns \"queue\" (just `:queue.to_s`) and the Slurm adapter returns \"partition\" and the Torque adapter returns \"queue\" i.e. base class implementation:\r\n\r\n```ruby\r\ndef tr(word)\r\n  word.to_s\r\nend\r\n```\r\n\r\nand subclass:\r\n\r\n```ruby\r\ndef tr(word)\r\n  { queue: \"partition\" }.fetch(word, super(word))\r\nend\r\n```\r\n"}}
{"actor":{"display_login":"ericfranz"}}