{"comment":{"created_at":"2011-10-16T22:31:01Z","body":"Sounds good. If you wanted to drop the I18n part, you could create a mapping for the I18n class that you wrote; however, I'm not sure use of the I18n class is complicated enough to warrant a mapping. \r\n\r\nPerhaps just using #extend in the class that implements the app would be enough, just like how apps include HotCocoa right now.","updated_at":"2011-10-16T22:31:01Z","url":"https://api.github.com/repos/ferrous26/hotcocoa/issues/comments/2423456","id":2423456,"user":{"gravatar_id":"76724aec9d42b6c956ab03a94ff4c060","avatar_url":"https://secure.gravatar.com/avatar/76724aec9d42b6c956ab03a94ff4c060?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/ferrous26","id":38430,"login":"ferrous26"}},"action":"created","issue":{"number":35,"created_at":"2011-10-16T21:48:30Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Currently, in order to internationalise the menus of the app i'm doing, I have the following in the menu.rb file:\r\n\r\n```ruby\r\nmodule I18n\r\n  def self.t key\r\n    NSBundle.mainBundle.localizedStringForKey(key, value: nil, table: nil)\r\n  end\r\nend\r\n\r\nmodule HotCocoa\r\n  def application_menu\r\n    menu do |main|\r\n      main.submenu :apple do |apple|\r\n        apple.item :about, title: I18n.t(\"apple:about\")\r\n        ...\r\n      end\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n(\"apple:about\" then references values in the Localizable.strings files for each country, yadda yadda)\r\n\r\nI think it might be useful for hotcocoa to have certain localisation shortcuts built-in, especially since the NSLocalizedString macro (http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/macro/NSLocalizedString) doesn't appear to work in MacRuby. \r\n\r\nI was thinking of having something like this (ahem, '*inspired*' by http://guides.rubyonrails.org/i18n.html#the-public-i18n-api):\r\n\r\n```ruby\r\nmodule I18n\r\n  class << self    \r\n    def translate key, fallback: fallback\r\n      NSBundle.mainBundle.localizedStringForKey(key, value: fallback, table: nil)\r\n    end\r\n    alias_method \"t:fallback\", \"translate:fallback\"\r\n\r\n    def translate key\r\n      translate key, fallback: nil\r\n    end\r\n    alias_method :t, :translate\r\n  end\r\nend\r\n```\r\n\r\nWhat would also be neat is to not have to always put I18n in front, but I don't know the innards of hotcocoa well enough yet to accomplish that.\r\n\r\nAnyway,\r\n1) Do you think that this is a good candidate for inclusion into hotcocoa?\r\n2) If so, how is it best accomplished technically?","comments":1,"title":"shortcuts for localisation","updated_at":"2011-10-16T22:31:01Z","url":"https://api.github.com/repos/ferrous26/hotcocoa/issues/35","id":1923450,"assignee":null,"milestone":null,"closed_at":null,"user":{"gravatar_id":"4c204de448ddb0150beca236c591d240","avatar_url":"https://secure.gravatar.com/avatar/4c204de448ddb0150beca236c591d240?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/benilovj","id":23801,"login":"benilovj"},"html_url":"https://github.com/ferrous26/hotcocoa/issues/35","labels":[],"state":"open"},"legacy":{"issue_id":1923450,"comment_id":2423456}}