dcparker / ruby-gmail

A Rubyesque interface to Gmail. Connect to Gmail via IMAP and manipulate emails and labels. Send email with your Gmail account via SMTP. Includes full support for parsing and generating MIME messages.
http://dcparker.github.com/ruby-gmail
790 stars 123 forks source link

i18n support #44

Closed luciolucio closed 10 years ago

luciolucio commented 11 years ago

Message#archive! does not work in other languages because "All Mail" is hardcoded in message.rb. "Spam" can potentially change too from one language to another.

For example, in Italian while "Spam" is still "Spam", the "All Mail" mailbox is called "Tutti i messaggi"

luciolucio commented 11 years ago

I believe gmail's IMAP has an API to get the localized name of a folder.

luciolucio commented 11 years ago

OK, here's an example (based on this). I'm trying to think of where's the best place to use this. What do you think of gmail.rb getting a mailbox_name member, to be used like mailbox_name( :All ) returns "[Gmail]/All Mail", used in message.rb?

require 'net/imap'

imap = Net::IMAP.new('imap.gmail.com',993,true,nil,false)
res = imap.login( 'user', 'password' )

if res && res.name == "OK"
    l = imap.list( "[Gmail]/", "%" )
    x = l.select { | m | m.attr.include?( :All ) }
    all_mail = x.first.name
    y = l.select { | m | m.attr.include?( :Junk ) }
    spam = y.first.name

    imap.logout

    puts all_mail
    puts spam
end
myobie commented 10 years ago

I think you can use the i18n gem directly and not need to integrate it into this gem directly.