zlocalize 6.0.1.5 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 341b51637724b4029977922322949963c04922eb358fdf95dfc991d51f462b07
4
- data.tar.gz: 0df02afbd17aef66afcc8c5065bdf94f312e7760cf8111a5a5b7caaa32ec67a4
3
+ metadata.gz: 66b5522b6ea82798fe981eebf7d3dc4194244150004eb86b293db3fd8800978d
4
+ data.tar.gz: 281562dcdc5ca40e6618c60c4629856d152606b746fbaee0b53be84ef720f666
5
5
  SHA512:
6
- metadata.gz: e7457f52b3249f1b45aed2114e11520e21652a48713d3e6fa38babc89951b711b320a234ef232afda78b39b0d4e45aa523b314a5df24f7c3ed3dd89771e6fc7d
7
- data.tar.gz: 624d7292777dc3fb06bc7f0085067c39795e5f3b466fdc92411c1029b2f4503537aabd4da7d8e88259eaccd0838ca068f37fdca9716d3fc4c7e22e1f0e674344
6
+ metadata.gz: 6be05d4c717b68ef0b2dd1babfc31e98e44e85f3e019418bc4e58852af9f99b3fe74dfa37d87d65b1a3c4ec66a628e23686e37cb6db1ed6d8cf51c5f5c492c20
7
+ data.tar.gz: 815138a1bea01dd2695ef521d841615a6e92c398f01bd7712c527ad8cc00a065f045166863ca81b7088f3bef395f5a713abefeb9c7e473e047a8ea4a3300ad07
@@ -15,7 +15,7 @@ module ZLocalize
15
15
 
16
16
  attr_accessor :rails_root
17
17
 
18
- DEFAULT_HARVEST_OPTIONS = { :output => 'config/locales/app-strings.yml',
18
+ DEFAULT_HARVEST_OPTIONS = { :output => 'config/translations/app-strings.yml',
19
19
  :overwrite_existing => false,
20
20
  :add_paths => [],
21
21
  :silent => false,
@@ -12,6 +12,7 @@ require 'rails/generators/base'
12
12
 
13
13
  def create_initializer_file
14
14
  template "initializer_template.rb", "config/initializers/zlocalize.rb"
15
+ FileUtils.mkdir_p "config/translations"
15
16
  end
16
17
 
17
18
  end
@@ -35,12 +35,12 @@ ZLocalize.config.return_source_on_missing = { development: false, test: false,
35
35
  ZLocalize.config.locales = {
36
36
  en: {
37
37
  plural_select: -> (n) { n <= 0 ? 0 : (n > 1 ? 2 : 1) },
38
- translations: File.join(Rails.root,'config/locales/en.strings.yml'),
38
+ translations: File.join(Rails.root,'config/translations/en.strings.yml'),
39
39
  convert_float: -> (s) { s.to_s.gsub(',','') }
40
40
  },
41
41
  # fr: {
42
42
  # plural_select: -> (n) { n <= 0 ? 0 : (n > 1 ? 2 : 1) },
43
- # translations: File.join(Rails.root,'config/locales/fr.strings.yml'),
43
+ # translations: File.join(Rails.root,'config/translations/fr.strings.yml'),
44
44
  # titleize: -> (s) { s.capitalize.to_s },
45
45
  # convert_float: -> (s) { s.to_s.gsub(' ','').gsub(',','.') }
46
46
  # }
@@ -5,7 +5,7 @@ namespace :zlocalize do
5
5
  desc "Collect all translatable strings (used in _('...') and n_('...') calls) in your Rails application\n\n" +
6
6
  "Usage: rake zlocalize:harvest\n" +
7
7
  "Options and their defaults are:\n\n" +
8
- " output=FILE_PATH Output file, relative to Rails.root (default: \'config/locales/app-strings.yml\')\n" +
8
+ " output=FILE_PATH Output file, relative to Rails.root (default: \'config/translations/app-strings.yml\')\n" +
9
9
  " purge=true|false Remove unused entries in the existing output file (if it exists). (default: false)\n" +
10
10
  " clear=true|false Clearing the existing translations in output file (if it exists). (default: false)\n" +
11
11
  " silent=true|false If true, do not report progress. (default: false)\n" +
@@ -14,7 +14,7 @@ namespace :zlocalize do
14
14
  task :harvest => :environment do
15
15
  options = { :clear => ['1','true'].include?(ENV['clear']),
16
16
  :purge => ['1','true'].include?(ENV['purge']),
17
- :output => ENV['output'].to_s.empty? ? 'config/locales/app-strings.yml' : ENV['output'],
17
+ :output => ENV['output'].to_s.empty? ? 'config/translations/app-strings.yml' : ENV['output'],
18
18
  :add_paths => ENV['add_paths'].to_s.empty? ? [] : ENV['add_paths'].split(','),
19
19
  :silent => ['1','true'].include?(ENV['silent']) }
20
20
 
@@ -27,7 +27,7 @@ class TranslationValidator < ActiveModel::EachValidator
27
27
  end
28
28
  end
29
29
 
30
- def validate_each(record,attr_name,value)
30
+ def validate_each(record, attr_name, value)
31
31
  configuration = { :message => :missing_translations,
32
32
  :required_locales => record.respond_to?(:get_required_locales) ? :get_required_locales : [] }
33
33
  configuration.update(options)
@@ -44,8 +44,7 @@ class TranslationValidator < ActiveModel::EachValidator
44
44
  end
45
45
  end
46
46
  if missing_locales.size > 0
47
- # m = configuration[:message].to_s.gsub()
48
- record.errors.add(attr_name, configuration[:message], { :locales => missing_locales.to_sentence })
47
+ record.errors.add(attr_name, :missing_translation, :message => configuration[:message], :locales => missing_locales.to_sentence)
49
48
  end
50
49
  end
51
50
 
@@ -18,8 +18,12 @@ module ZLocalize
18
18
  content = ActionView::Template::Handlers::ERB::Erubi.new(content, escape: true, trim: true).src
19
19
  end
20
20
  @parser = create_parser_for_ruby_version
21
- @stree = @parser.parse(content)
22
- process(@stree)
21
+ begin
22
+ @stree = @parser.parse(content)
23
+ process(@stree)
24
+ rescue ArgumentError => ae
25
+ raise ArgumentError.new("In #{filename} #{ae.message}")
26
+ end
23
27
  end
24
28
 
25
29
  def create_parser_for_ruby_version
@@ -59,14 +63,14 @@ module ZLocalize
59
63
 
60
64
  def get_string_node_value(node)
61
65
  unless node.is_a?(AST::Node) && node.type == :str
62
- raise ArgumentError.new("String Expected but got: #{node.inspect}")
66
+ raise ArgumentError.new("On line #{node.loc.selector.line} at column #{node.loc.selector.column+1} : String Expected but got: #{node.inspect}")
63
67
  end
64
68
  return node.children[0]
65
69
  end
66
70
 
67
71
  def get_string_array_node_value(node)
68
72
  unless node.is_a?(AST::Node) || node.type != :array
69
- raise ArgumentError.new("Array expected but got: #{node.inspect}")
73
+ raise ArgumentError.new("On line #{node.loc.selector.line} at column #{node.loc.selector.column+1} : Array expected but got: #{node.inspect}")
70
74
  end
71
75
  a = []
72
76
  for i in 0..node.children.size - 1
@@ -196,10 +196,14 @@ module ZLocalize
196
196
  end
197
197
 
198
198
  def load(filename)
199
- if File.exists?(filename)
199
+ if File.exist?(filename)
200
200
  content = File.open(filename,"r") { |f| f.read }
201
201
  read_yaml_header(content)
202
- entries = YAML::load(content)
202
+ begin
203
+ entries = YAML::load(content)
204
+ rescue StandardError => e
205
+ raise TranslationFileError.new("Error reading ZLocalize TranslationFile #{filename} : #{e.message}")
206
+ end
203
207
  if entries && !entries.is_a?(Hash)
204
208
  raise TranslationFileError.new("Invalid YAML translation file #{filename}\n\n#{entries.inspect}")
205
209
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zlocalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1.5
4
+ version: 6.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Bedard
8
8
  - Stephane Volet
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-09 00:00:00.000000000 Z
12
+ date: 2022-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -87,7 +87,7 @@ dependencies:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '2.7'
90
- description:
90
+ description:
91
91
  email:
92
92
  - zzeligg@gmail.com
93
93
  - steph@zboing.ca
@@ -118,7 +118,7 @@ homepage: https://github.com/zzeligg/zlocalize
118
118
  licenses:
119
119
  - MIT
120
120
  metadata: {}
121
- post_install_message:
121
+ post_install_message:
122
122
  rdoc_options: []
123
123
  require_paths:
124
124
  - lib
@@ -133,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.2.7
137
- signing_key:
136
+ rubygems_version: 3.3.10
137
+ signing_key:
138
138
  specification_version: 4
139
139
  summary: Translation engine for Rails applications
140
140
  test_files: []