Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rubygems deprecations #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cameel
Copy link

@cameel cameel commented Jul 13, 2011

gettext is using deprecated method Gem.all_load_paths from RubyGems. This makes 'rake gettext:find' crash in the process of generating locale files.

I fixed it, but my fix depends on newer version of RubyGems (obviously, deprecated calls had to be replaced with their newer alternatives). You may want to pull it anyway so I make this pull request.

- Gem.all_load_paths() has been deprecated recently. Not only that - some of the other deprecated methods it depends on uses have probably not not been updated in a long time and cause 'rake gettext:find' to crash ('undefined method `specifications' for "/usr/lib/ruby/gems/1.9.1":String').
- This patch iterates over all specifications and collects values of their gem_dir properties in an array instead
- Use only those specifications that have been activated. The old implementation was using all of them, even if there were multiple versions of the same gem.
- My patch that fixes the use of deprecated Gem.all_load_paths() uses rubygems features that have been added in version 1.8.0. Make that requirement explicit.
@gucki
Copy link

gucki commented Oct 12, 2011

+1. Please pull and release new gem. This bug drove me crazy :-(

@grrrisu
Copy link

grrrisu commented Oct 28, 2011

+1 Please pull.

@egze
Copy link

egze commented Nov 8, 2011

+1 please pull. very annoying bug

@ichelm
Copy link

ichelm commented Nov 20, 2011

I also wrote another patch for this issue. This probably works with any version of Rubygems.

--- lib/gettext/runtime/locale_path.rb.orig
+++ lib/gettext/runtime/locale_path.rb
@@ -52,7 +52,14 @@

         load_path = $LOAD_PATH.dup
         if defined? ::Gem
-          load_path += Gem.all_load_paths
+          begin
+            load_path +=Gem::Specification.map{|s|s.gem_dir}
+          rescue NoMethodError
+            begin
+              load_path +=Gem.all_load_paths
+            rescue NoMethodError
+            end
+          end
         end
         load_path.map!{|v| v.match(/(.*?)(\/lib)*?$/); $1}
         load_path.each {|path|

@Jimflip
Copy link

Jimflip commented Nov 25, 2011

come on sort it out!

@mfernandezrodriguez
Copy link

+1 pls ...

@dgilperez
Copy link

I'm having a strange behaviour using @cameel 's fix.

It works for finding and packing the files, but on runtime, any translated string containing variables won't work properly. Example:

_('Hello, %{name}, have a nice day') % {:name => 'Peter'}

will show in the view

Hello, , have a nice day

This happens all along my site, only after this fix.

Ideas?

@grosser
Copy link
Contributor

grosser commented Dec 23, 2011

my hotfix :)

module Gem;def self.all_load_paths;[];end;end

@brodock
Copy link

brodock commented Jan 12, 2012

any new on oficial fix for this issue?

@nikosd
Copy link

nikosd commented May 2, 2012

Switch over to the maintained ruby gettext : http://ruby-gettext.github.com/ / https://github.com/ruby-gettext/gettext

@grosser
Copy link
Contributor

grosser commented May 2, 2012

They both push to the same gem, is there a difference ?

@nikosd
Copy link

nikosd commented May 2, 2012

Doh! You're right :)

@kou
Copy link

kou commented May 24, 2012

I got push permission from @mutoh.
So there is no difference. ruby-gettext/gettext is the successor to mutoh/gettext.

I want to work together with fast_gettext if available.

fotos pushed a commit to skroutz/gettext that referenced this pull request Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet