I'm taking a look at the Apple Sample code called PhotoSearch. In DateCell.m, there is a use of NSLocalizedString as follows: - (NSString *)todayString { return NSLocalizedString(@"Today", @"Today title string"); } I translated this as: def todayString return NSLocalizedString( "Today", "Today title string") end but got: DateCell.rb:217:in `todayString': undefined method `NSLocalizedString' for #<DateCell:0x200c86740> (NoMethodError) Changing the line to return NSBundle.mainBundle.localizedStringForKey("Today", value:"Today title string", table:nil) works but NSLocalizedString is supposed to be a Foundation Function, so should be 'freely' available in MacRuby, shouldn't it?
On Mon, Feb 21, 2011 at 8:23 AM, Martin Hawkins <martin.hawkins@gmail.com> wrote:
Changing the line to return NSBundle.mainBundle.localizedStringForKey("Today", value:"Today title string", table:nil) works but NSLocalizedString is supposed to be a Foundation Function, so should be 'freely' available in MacRuby, shouldn't it?
The trouble is that NSLocalizedString is not actually a function — it's a macro, so MacRuby can't call it. It really just needs to be reimplemented, but until then the NSBundle methods are precisely equivalent. — Chuck
Something like this: module Kernel private def NSLocalizedString(key, value) NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil) end end On 21 feb 2011, at 23:56, Charles Steinman wrote:
On Mon, Feb 21, 2011 at 8:23 AM, Martin Hawkins <martin.hawkins@gmail.com> wrote:
Changing the line to return NSBundle.mainBundle.localizedStringForKey("Today", value:"Today title string", table:nil) works but NSLocalizedString is supposed to be a Foundation Function, so should be 'freely' available in MacRuby, shouldn't it?
The trouble is that NSLocalizedString is not actually a function — it's a macro, so MacRuby can't call it. It really just needs to be reimplemented, but until then the NSBundle methods are precisely equivalent.
— Chuck _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
We could add such a method in MacRuby core, but I wonder if it will be really that much of a use. NSLocalizedString macros are used in Objective-C programs because they are parsed by the genstrings command-line tool, to generate the translation file. I am not sure if genstrings can be used on Ruby files. At some point we will need a l10n solution for MacRuby apps, though. I am wondering if there isn't already a Ruby library for this? (something like gettext?). Laurent On Feb 22, 2011, at 9:50 AM, Eloy Duran wrote:
Something like this:
module Kernel private
def NSLocalizedString(key, value) NSBundle.mainBundle.localizedStringForKey(key, value:value, table:nil) end end
On 21 feb 2011, at 23:56, Charles Steinman wrote:
On Mon, Feb 21, 2011 at 8:23 AM, Martin Hawkins <martin.hawkins@gmail.com> wrote:
Changing the line to return NSBundle.mainBundle.localizedStringForKey("Today", value:"Today title string", table:nil) works but NSLocalizedString is supposed to be a Foundation Function, so should be 'freely' available in MacRuby, shouldn't it?
The trouble is that NSLocalizedString is not actually a function — it's a macro, so MacRuby can't call it. It really just needs to be reimplemented, but until then the NSBundle methods are precisely equivalent.
— Chuck _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (4)
-
Charles Steinman
-
Eloy Duran
-
Laurent Sansonetti
-
Martin Hawkins