Skip to content

Fix rubygems deprecations#11

Open
cameel wants to merge 2 commits into
mutoh:masterfrom
cameel:fix-rubygems-deprecations
Open

Fix rubygems deprecations#11
cameel wants to merge 2 commits into
mutoh:masterfrom
cameel:fix-rubygems-deprecations

Conversation

@cameel

@cameel cameel commented Jul 13, 2011

Copy link
Copy Markdown

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.

cameel added 2 commits July 12, 2011 19:49
- 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

gucki commented Oct 12, 2011

Copy link
Copy Markdown

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

@grrrisu

grrrisu commented Oct 28, 2011

Copy link
Copy Markdown

+1 Please pull.

@egze

egze commented Nov 8, 2011

Copy link
Copy Markdown

+1 please pull. very annoying bug

@ichelm

ichelm commented Nov 20, 2011

Copy link
Copy Markdown

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

Jimflip commented Nov 25, 2011

Copy link
Copy Markdown

come on sort it out!

@mfernandezrodriguez

Copy link
Copy Markdown

+1 pls ...

@dgilperez

Copy link
Copy Markdown

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

grosser commented Dec 23, 2011

Copy link
Copy Markdown
Contributor

my hotfix :)

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

@brodock

brodock commented Jan 12, 2012

Copy link
Copy Markdown

any new on oficial fix for this issue?

@nikosd

nikosd commented May 2, 2012

Copy link
Copy Markdown

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

@grosser

grosser commented May 2, 2012

Copy link
Copy Markdown
Contributor

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

@nikosd

nikosd commented May 2, 2012

Copy link
Copy Markdown

Doh! You're right :)

@kou

kou commented May 24, 2012

Copy link
Copy Markdown

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.