lit 0.4.0.pre.alpha.3 → 0.4.0.pre.alpha.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2eed64b6f3c006939c60bb3850cb780cdbaf271f
4
- data.tar.gz: 81c8627bf675c560cc08daf9c2ed3d08064f7e29
3
+ metadata.gz: 8731e7911097d0e6c8b3cdbf164d5a4dfb7d9c45
4
+ data.tar.gz: c478524af6694e7cf55272ae7d2f83381d05b161
5
5
  SHA512:
6
- metadata.gz: 4690ca47f19899c3a1b0d3d09c7027fc0f12f76f92cfdac3e7ebd7cd8492c1c953c4262476243f4ad8fc2c6b6b905b67dbeb1411dba553c590b62fe457825f59
7
- data.tar.gz: 072161c067037aba2cb4627ca389dc137d89439f19c9d65cd5103b8a67e5faa2d895265a28d1009efed5e3cd667ade6f37ff144004b906c80ac21574d44b3823
6
+ metadata.gz: b096959dfb69f64ff171173026d4c582042e8409593cfc76e522aee75ecf016ecfb13ca794e5d93588594a4428b50d30f55fd0dcd7b0b378c609efc25c4ce244
7
+ data.tar.gz: 7171984114ea8cc6d546e5e1530cf89f6d5acb46e7b9a1fc8f38256dc4a74886ccbded8aaeb7a8729afd90dbf34e6a93e8fdd47b4747f81b02d083633abc66f0
data/README.md CHANGED
@@ -79,6 +79,8 @@ $ rake lit:export FORMAT=csv LOCALES=en,pl OUTPUT=export.csv
79
79
 
80
80
  Using the task `lit:export_splitted` does the same as `lit:export` but splits the locales by their name (`config/locales/en.yml`, etc).
81
81
 
82
+ Optionally, the `INCLUDE_HITS_COUNT` option (only applicable for CSV export) can be used to include current hits count for each localization key. Note that it only makes sense to use this option when Redis is Lit's key-value engine because these counters are stored in cache and not in the database.
83
+
82
84
  #### Import
83
85
 
84
86
  Translation import is handled using the `lit:import` task, where imported file name should be specified in the `FILE` envionment variable:
@@ -2,7 +2,7 @@ require 'csv'
2
2
 
3
3
  module Lit
4
4
  class Export
5
- def self.call(locale_keys:, format:)
5
+ def self.call(locale_keys:, format:, include_hits_count: false)
6
6
  raise ArgumentError, "format must be yaml or csv" if %i[yaml csv].exclude?(format)
7
7
  Lit.loader.cache.load_all_translations
8
8
  localizations_scope = Lit::Localization.active
@@ -22,7 +22,7 @@ module Lit
22
22
  when :csv
23
23
  relevant_locales = locale_keys.presence || I18n.available_locales.map(&:to_s)
24
24
  CSV.generate do |csv|
25
- csv << ['key', *relevant_locales]
25
+ csv << ['key', *relevant_locales, ('hits' if include_hits_count)].compact
26
26
  keys_without_locales = db_localizations.keys.map { |k| k.gsub(/(#{relevant_locales.join('|')})\./, '') }.uniq
27
27
  keys_without_locales.each do |key_without_locale|
28
28
  # Here, we need to determine if we're dealing with an array or a scalar.
@@ -44,7 +44,11 @@ module Lit
44
44
  key_localizations_per_locale =
45
45
  relevant_locales.map { |l| Array.wrap(db_localizations["#{l}.#{key_without_locale}"]) }
46
46
  transpose(key_localizations_per_locale).each do |translation_series|
47
- csv << [key_without_locale, *translation_series]
47
+ csv_row = [key_without_locale, *translation_series]
48
+ if include_hits_count
49
+ csv_row << (Lit.init.cache.get_global_hits_counter(key_without_locale) || 0)
50
+ end
51
+ csv << csv_row
48
52
  end
49
53
  end
50
54
  end
@@ -1,3 +1,3 @@
1
1
  module Lit
2
- VERSION = '0.4.0-alpha.3'.freeze
2
+ VERSION = '0.4.0-alpha.4'.freeze
3
3
  end
@@ -3,9 +3,10 @@ namespace :lit do
3
3
  task export: :environment do
4
4
  locale_keys = ENV['LOCALES'].to_s.split(',') || []
5
5
  export_format = ENV['FORMAT'].presence&.downcase&.to_sym || :yaml
6
+ include_hits_count = ENV['INCLUDE_HITS_COUNT'].present?
6
7
  path = ENV['OUTPUT'].presence || Rails.root.join('config', 'locales', "lit.#{file_extension(export_format)}")
7
-
8
- if exported = Lit::Export.call(locale_keys: locale_keys, format: export_format)
8
+ if exported = Lit::Export.call(locale_keys: locale_keys, format: export_format,
9
+ include_hits_count: include_hits_count)
9
10
  File.new(path, 'w').write(exported)
10
11
  puts "Successfully exported #{path}."
11
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre.alpha.3
4
+ version: 0.4.0.pre.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Litwiniuk
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-28 00:00:00.000000000 Z
13
+ date: 2018-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: i18n
16
+ name: rails
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '0.7'
21
+ version: 4.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '0.7'
28
+ version: 4.2.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: jquery-rails
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -41,19 +41,19 @@ dependencies:
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
- name: rails
44
+ name: coffee-rails
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 4.2.0
49
+ version: '0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 4.2.0
56
+ version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: appraisal
59
59
  requirement: !ruby/object:Gem::Requirement