ferrous26/hotcocoa — Issue #35: shortcuts for localisation
Author: benilovj
Created: 2011-10-16 21:48:30+00:00
State: open

Currently, in order to internationalise the menus of the app i'm doing, I have the following in the menu.rb file:

```ruby
module I18n
def self.t key
NSBundle.mainBundle.localizedStringForKey(key, value: nil, table: nil)
end
end

module HotCocoa
def application_menu
menu do |main|
main.submenu :apple do |apple|
apple.item :about, title: I18n.t("apple:about")
...
end
end
end
end
```

("apple:about" then references values in the Localizable.strings files for each country, yadda yadda)

I 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.

I was thinking of having something like this (ahem, '*inspired*' by http://guides.rubyonrails.org/i18n.html#the-public-i18n-api):

```ruby
module I18n
class << self
def translate key, fallback: fallback
NSBundle.mainBundle.localizedStringForKey(key, value: fallback, table: nil)
end
alias_method "t:fallback", "translate:fallback"

def translate key
translate key, fallback: nil
end
alias_method :t, :translate
end
end
```

What 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.

Anyway,
1) Do you think that this is a good candidate for inclusion into hotcocoa?
2) If so, how is it best technically accomplished?