refinerycms-i18n 0.9.9 → 0.9.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gemspec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- version = '0.9.9'
2
+ version = '0.9.9.1'
3
3
  raise "Could not get version so gemspec can not be built" if version.nil?
4
4
  files = Dir.glob("**/*").flatten.reject do |file|
5
5
  file =~ /\.gem(spec)?$/
data/lib/refinery/i18n.rb CHANGED
@@ -61,7 +61,7 @@ module Refinery
61
61
 
62
62
  Refinery::Plugin.register do |plugin|
63
63
  plugin.name = "refinery_i18n"
64
- plugin.version = %q{0.9.9}
64
+ plugin.version = %q{0.9.9.1}
65
65
  plugin.hide_from_menu = true
66
66
  plugin.always_allow_access = true
67
67
  end
@@ -40,9 +40,8 @@ namespace :translate do
40
40
  locale_hash = {}
41
41
 
42
42
  puts "Searching for missing translations for the locale: #{locale}"
43
- default_locale_files = Dir.glob(Rails.root.join('vendor', 'plugins', '*', 'config', 'locales', "#{locale}.yml").to_s)
44
- default_locale_files += Dir.glob(Refinery.root.join('vendor', 'plugins', '*', 'config', 'locales', "#{locale}.yml").to_s)
45
- default_locale_files += Dir.glob(Refinery.root.join('vendor', 'refinerycms', '*', 'config', 'locales', "#{locale}.yml").to_s)
43
+ default_locale_files = Dir.glob(Rails.root.join('vendor', 'engines', '*', 'config', 'locales', "#{locale}.yml").to_s)
44
+ default_locale_files += Dir.glob(Refinery.root.join('*', 'config', 'locales', "#{locale}.yml").to_s)
46
45
  default_locale_files += Dir.glob(File.join(Translate.locales_dir, "**","#{locale}.yml").to_s)
47
46
 
48
47
  default_locale_files.uniq.each do |locale_file_name|
@@ -53,26 +52,29 @@ namespace :translate do
53
52
  lookup_pattern = /\b(?:I18n\.t|I18n\.translate|t)(?:\s|\():?'([a-z0-9_]*.[a-z0-9_.]+)'\)?/
54
53
  templates = Dir.glob(Rails.root.join('app', '**', '*.{erb,rb}').to_s)
55
54
  templates += Dir.glob(Rails.root.join.join('vendor', 'plugins', '**', 'app', '**', '*.{erb,rb}').to_s)
56
- templates += Dir.glob(Refinery.root.join('vendor', 'plugins', '**', 'app', '**', '*.{erb,rb}').to_s)
57
- templates += Dir.glob(Refinery.root.join('vendor', 'refinerycms', '**', 'app', '**', '*.{erb,rb}').to_s)
55
+ templates += Dir.glob(Refinery.root.join('*', 'app', '**', '*.{erb,rb}').to_s)
58
56
 
59
57
  templates.reject{|t| t =~ /\/lib\/generators\/.+?\/templates\//}.uniq.each do |file_name|
60
58
  File.open(file_name, "r+").each do |line|
61
59
  line.scan(lookup_pattern) do |key_string|
62
- # qualify the namespace if beginning with . like t('.log_out')
60
+ # qualify the namespace if beginning with . like t('.log_out') or has :scope => 'something.else'
61
+ namespace = []
63
62
  if key_string.first =~ /^\./
64
63
  namespace = file_name.split("app/").last.split(/^.+?\//).last.split('/')
65
- namespace = namespace | [namespace.pop.gsub(/^\_/, '').split('.').first]
66
- key_string = ["#{namespace.join('.')}#{key_string.first}"]
64
+ namespace |= [namespace.pop.gsub(/^\_/, '').split('.').first]
65
+ elsif (scope_matches = line.scan(/:scope\ +?=>\ +?["|']([^\'\"]+)["|']/)).any?
66
+ namespace = scope_matches.map { |scope| scope.first.split('.') }.flatten | ['']
67
67
  end
68
+ key_string = "#{namespace.join('.')}#{key_string.first}"
68
69
 
69
- unless key_exist?(key_string.first.split("."), locale_hash)
70
+ # don't duplicate, don't use strings with string interpolation
71
+ unless key_string =~ /\#\{.+?\}/ or key_exist?(key_string.split("."), locale_hash)
70
72
  result << "#{key_string} in \t #{file_name} \t is not in any #{locale} locale file"
71
73
  end
72
74
  end
73
- end unless file_name =~ /translate\/spec/
75
+ end if file_name !~ /translate\/spec/
74
76
  end
75
- puts result.empty? ? "No missing translations for locale: #{locale}" : "#{result.join("\n\n")}\n\nNumber of missing translations for #{locale}: #{result.length}"
77
+ puts result.empty? ? "No missing translations for locale: #{locale}" : "#{result.join("\n")}\n\nNumber of missing translations for #{locale}: #{result.length}"
76
78
  end
77
79
 
78
80
  desc "Show I18n keys that are missing in the specified locale YAML file. Defaults to I18n.default_locale, unless LOCALE env is specified"
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 9
8
8
  - 9
9
- version: 0.9.9
9
+ - 1
10
+ version: 0.9.9.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Resolve Digital
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-13 00:00:00 +13:00
18
+ date: 2011-01-18 00:00:00 +13:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency