lit 0.3.3 → 0.4.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -6
  3. data/app/assets/javascripts/lit/lit_frontend.js +20 -12
  4. data/app/assets/stylesheets/lit/application.css +3 -0
  5. data/app/controllers/lit/api/v1/base_controller.rb +1 -1
  6. data/app/controllers/lit/api/v1/locales_controller.rb +1 -1
  7. data/app/controllers/lit/api/v1/localization_keys_controller.rb +12 -4
  8. data/app/controllers/lit/api/v1/localizations_controller.rb +25 -9
  9. data/app/controllers/lit/application_controller.rb +11 -8
  10. data/app/controllers/lit/concerns/request_info_store.rb +1 -0
  11. data/app/controllers/lit/incomming_localizations_controller.rb +22 -15
  12. data/app/controllers/lit/locales_controller.rb +1 -1
  13. data/app/controllers/lit/localization_keys_controller.rb +44 -18
  14. data/app/controllers/lit/localizations_controller.rb +16 -11
  15. data/app/controllers/lit/sources_controller.rb +9 -13
  16. data/app/helpers/lit/frontend_helper.rb +28 -16
  17. data/app/helpers/lit/localizations_helper.rb +2 -1
  18. data/app/jobs/lit/synchronize_source_job.rb +1 -1
  19. data/app/models/lit/incomming_localization.rb +71 -41
  20. data/app/models/lit/locale.rb +11 -13
  21. data/app/models/lit/localization.rb +26 -24
  22. data/app/models/lit/localization_key.rb +46 -55
  23. data/app/models/lit/source.rb +17 -74
  24. data/app/queries/localization_key_search_query.rb +80 -0
  25. data/app/services/remote_interactor_service.rb +45 -0
  26. data/app/services/synchronize_source_service.rb +63 -0
  27. data/app/views/kaminari/lit/_gap.html.erb +1 -1
  28. data/app/views/layouts/lit/_navigation.html.erb +1 -1
  29. data/app/views/lit/dashboard/index.html.erb +2 -2
  30. data/app/views/lit/incomming_localizations/index.html.erb +10 -6
  31. data/app/views/lit/localization_keys/_localization_row.html.erb +1 -1
  32. data/app/views/lit/localization_keys/_localizations_list.html.erb +84 -0
  33. data/app/views/lit/localization_keys/_sidebar.html.erb +66 -0
  34. data/app/views/lit/localization_keys/change_completed.js.erb +2 -0
  35. data/app/views/lit/localization_keys/index.html.erb +3 -121
  36. data/app/views/lit/localization_keys/not_translated.html.erb +9 -0
  37. data/app/views/lit/localization_keys/restore_deleted.js.erb +1 -0
  38. data/app/views/lit/localization_keys/visited_again.html.erb +9 -0
  39. data/app/views/lit/localizations/_previous_versions_rows.html.erb +2 -2
  40. data/app/views/lit/localizations/change_completed.js.erb +2 -0
  41. data/app/views/lit/localizations/update.js.erb +2 -0
  42. data/app/views/lit/sources/_form.html.erb +1 -1
  43. data/app/views/lit/sources/index.html.erb +1 -1
  44. data/config/routes.rb +5 -0
  45. data/db/migrate/20181017123839_lit_add_is_deleted_to_localization_keys.rb +8 -0
  46. data/db/migrate/20181018075955_lit_add_localization_key_is_deleted_to_localization_keys.rb +8 -0
  47. data/db/migrate/20181030111522_lit_add_is_visited_again_to_localization_keys.rb +8 -0
  48. data/lib/generators/lit/install/templates/initializer.rb +5 -1
  49. data/lib/lit.rb +1 -0
  50. data/lib/lit/adapters/redis_storage.rb +1 -1
  51. data/lib/lit/cache.rb +32 -54
  52. data/lib/lit/export.rb +80 -0
  53. data/lib/lit/i18n_backend.rb +12 -9
  54. data/lib/lit/import.rb +179 -0
  55. data/lib/lit/loader.rb +2 -0
  56. data/lib/lit/version.rb +1 -1
  57. data/lib/tasks/lit_tasks.rake +78 -13
  58. metadata +21 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c4bb066b08ec7f1bb1cbd9992dca9e572acde0e
4
- data.tar.gz: 704bb8463f8f8f6ff83bd5f0c5b63937323db920
3
+ metadata.gz: 6bcba84c0fc5b731bbbbd07f38d7a263f1778869
4
+ data.tar.gz: 105fcbf83b9b7df7f19eee1a33dc60802ff0703e
5
5
  SHA512:
6
- metadata.gz: 63086561d6b158cbe8ae12a97cc3c6a29d78f1905a4bec3378247f9bb12a13a0cae19d5c0cdcbf4edcb2cfb626058feceb13199a7e290a43b05fdafdb6da9c15
7
- data.tar.gz: 8413129a9c31d0c01cd2b6c97dd497d4a018f46848833685e4b27cd77fb5fc6872fe55da123e08c761edc2b0bab264af0ece86052bc159a7bb6a315dd6a632bc
6
+ metadata.gz: 9aeaae0bb50a36db06603cbe05323d12ac63ee6635acf76f8b70db0dbef5db694f063fabac4eb1416724c121b46d1cee1cc434ae988d59472e7528a8ec24f301
7
+ data.tar.gz: 277a1d97c1737886c8b5a0536336515f1bbc58dab0c0d4385b5f11dbd956136aafc0d1f040def8cf8ea0866bd5cfb5aaaff9eabc70b2b4e5d693777721ca6b86
data/README.md CHANGED
@@ -16,7 +16,7 @@ Highly inspired by Copycopter by thoughtbot.
16
16
  3. Versioning translations - you can always check, how value did look like in past
17
17
  4. Possibility to synchronize translations between environments or apps
18
18
  5. Easy to install - works as an engine, comes with simple generator
19
- 6. You can always export all translations to plain old YAML file
19
+ 6. You can always export all translations to plain old YAML file which can then be imported elsewhere. Translations can also be exported to (and then imported from) a CSV file so that e.g. a third party can easily edit translations for you using any spreadsheet editor, without access to your website's Lit panel.
20
20
  7. Has build in wysiwyg editor ([jQuery TE](http://jqueryte.com/))
21
21
  8. Translating apps directly in frontend (see bellow)
22
22
  9. (On request) stores paths where translation keys were called
@@ -50,26 +50,60 @@ gem 'lit'
50
50
  You may want to take a look at generated initializer in `config/initializers/lit.rb` and change some default configuration options.
51
51
 
52
52
  ### So... again - what is it and how to use it?
53
- *Lit* is Rails engine - it runs in it's own namespace, by default it's avaulable under `/lit`. It provides UI for managing translations of your app.
53
+ *Lit* is Rails engine - it runs in it's own namespace, by default it's available under `/lit`. It provides UI for managing translations of your app.
54
54
 
55
- Once you call `I18n.t()` function from your views, *Lit* is asked whether it has or not proper value for it. If translation is present in database and is available for *Lit*, it's served back. If it does not exists, record is automatically created in database with initial value provided in `default` option key. If `default` key is not present, value `nil` is saved to database. When app is starting, *Lit* will preload all keys from your local `config/locale/*.yml` files - this is why app startup may take a while.
55
+ Once you call `I18n.t()` function from your views, *Lit* is asked whether it has or not proper value for it. If translation is present in database and is available for *Lit*, it's served back. If it does not exist, record is automatically created in database with initial value provided in `default` option key. If `default` key is not present, value `nil` is saved to database. When app is starting, *Lit* will preload all keys from your local `config/locale/*.yml` files - this is why app startup may take a while.
56
56
 
57
57
  To optimize translation key lookup, *Lit* can use different cache engines. For production with many workers `redis` is suggested, for local development `hash` will be fine (`hash` is stored in memory, so if you have many workers and will update translation value in backend, only one worker will have proper translation in it's cache - db will be updated anyway).
58
58
 
59
59
  Keys ending with `_html` have auto wysiwyg support.
60
60
 
61
- You can also export translations using rake task
61
+ ### Import and export
62
62
 
63
+ #### Export
64
+
65
+ Translations can be exported using the `lit:export` rake task:
63
66
  ```bash
64
67
  $ rake lit:export
65
68
  ```
66
69
 
67
- You may also give it extra env variables to limit the export results.
70
+ The task exports to YAML format by default, which can be overridden by setting the `FORMAT` environment variable to `csv`.
71
+ As well as this, by default, it exports all of your application's locales; using the `LOCALES` environment variable you can limit it to specific locales.
72
+ Using `OUTPUT` environment variable you can specify the output file (defaults to `config/locales/lit.yml` or `.csv`).
73
+
74
+ For example:
75
+ ```bash
76
+ $ rake lit:export FORMAT=csv LOCALES=en,pl OUTPUT=export.csv
77
+ ```
78
+ ...will only export the `en` and `pl` locales, producing CSV output to `export.csv` in the current folder.
79
+
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
+
82
+ #### Import
83
+
84
+ Translation import is handled using the `lit:import` task, where imported file name should be specified in the `FILE` envionment variable:
85
+ ```bash
86
+ $ rake lit:import FILE=stuff.csv
87
+ ```
88
+
89
+ Optionally, `LOCALES` and `SKIP_NIL` environment variables can be used to select specific locales to import from a multi-locale CSV file and to prevent nil values from being set as translated values for localizations, respectively.
90
+ The following call:
91
+ ```bash
92
+ $ rake lit:import FILE=stuff.csv LOCALES=en,pl SKIP_NIL=1
93
+ ```
94
+ ...will only load `en` and `pl` locales from the file, skipping nil values.
68
95
 
96
+ Additionally, there is the `lit:warm_up_keys` task (temporarily aliased as `lit:raw_import` for compatibility) which serves a different purpose: rather than for actual import of translations, it is intended to pre-load into database translations from a specific locale's YAML file **when the application is first deployed to a server and not all translation keys are present in the database yet**. This task also takes the `SKIP_NIL` option in a similar way as the import task.
69
97
  ```bash
70
- $ LOCALES=en,de rake lit:export
98
+ $ rake lit:warm_up_keys FILES=config/locales/en.yml LOCALES=en
71
99
  ```
100
+ In this case, when the `config/locales/en.yml` contains a translation for `foo` which doesn't have a key in the DB yet, it will be created, but if it already exists in the DB with a translation, it won't be overridden.
101
+
102
+ #### Deleted keys
103
+
104
+ Keys marked as deleted (i.e. still existing but deleted from the Lit UI) are *not* exported. In order to make these keys exported again, you need to restore them from the "Deleted and visited again" view.
72
105
 
106
+ Deleted keys whose translations are encountered during import are restored automatically.
73
107
 
74
108
  ### 0.2 -> 0.3 upgrade guide
75
109
 
@@ -7,15 +7,22 @@
7
7
  replaceWithForm, submitForm, removeLitForm;
8
8
 
9
9
  buildLocalizationForm = function(e){
10
+ e.stopPropagation();
11
+
10
12
  var $this = $(this);
13
+
14
+ if($this.is(':focus'))
15
+ return false;
16
+
11
17
  var meta = $('meta[name="lit-url-base"]');
12
- if(meta.length > 0){
18
+
19
+ if(meta.length > 0)
13
20
  getLocalizationPath($this, meta);
14
- //replaceWithForm(e.currentTarget, value, update_path)
15
- }
16
- e.stopPropagation();
21
+ else
22
+ console.error('cannot find lit base url');
23
+
17
24
  return false;
18
- }
25
+ };
19
26
 
20
27
  getLocalizationPath = function(elem, metaElem) {
21
28
  $.getJSON(metaElem.attr('value'),
@@ -38,8 +45,9 @@
38
45
  replaceWithForm = function(elem, value, update_path){
39
46
  removeLitForm();
40
47
  var $this = $(elem);
41
- $this.attr('contentEditable', true);
42
- $this.html( value );
48
+ $this.attr('contenteditable', true);
49
+ if(value)
50
+ $this.html(value);
43
51
  $this.focus();
44
52
  $this.on('blur', function(){
45
53
  submitForm($this, $this.html(), update_path);
@@ -59,15 +67,15 @@
59
67
  console.log('saved ' + elem.data('key'));
60
68
  },
61
69
  error: function(){
62
- console.log('problem saving ' + elem.data('key'));
63
- alert('ups, ops, something went wrong');
70
+ console.error('cannot save ' + elem.data('key'));
71
+ alert('cannot save ' + elem.data('key'));
64
72
  }
65
73
  });
66
74
  };
67
75
 
68
76
  removeLitForm = function(){
69
77
  $('#litForm').remove();
70
- }
78
+ };
71
79
 
72
80
  $(document).ready(function(){
73
81
  $('<div id="lit_button_wrapper" />').appendTo('body');
@@ -75,14 +83,14 @@
75
83
  $btn.on('click', function(){
76
84
  removeLitForm();
77
85
  if($btn.hasClass('lit-highlight-enabled')){
78
- $('.lit-key-generic').removeClass('lit-key-highlight').off('click.form');
86
+ $('.lit-key-generic').removeClass('lit-key-highlight').off('click.lit');
79
87
  $btn.removeClass('lit-highlight-enabled');
80
88
  $('.lit-key-generic').each(function(_, elem){
81
89
  $elem = $(elem);
82
90
  $elem.attr('title', $elem.data('old-title') || '');
83
91
  });
84
92
  }else{
85
- $('.lit-key-generic').addClass('lit-key-highlight').on('click.form', buildLocalizationForm);
93
+ $('.lit-key-generic').addClass('lit-key-highlight').on('click.lit', buildLocalizationForm);
86
94
  $btn.addClass('lit-highlight-enabled');
87
95
  $('.lit-key-generic').each(function(_, elem){
88
96
  $elem = $(elem);
@@ -48,6 +48,9 @@ padding: 5px 7px;
48
48
  .well label{
49
49
  font-weight: normal;
50
50
  }
51
+ .well .form-search {
52
+ margin-bottom: 15px;
53
+ }
51
54
  .localization_row em{
52
55
  color: #bbb;
53
56
  }
@@ -3,7 +3,7 @@ module Lit
3
3
  module V1
4
4
  class BaseController < ActionController::Base
5
5
  layout nil
6
- respond_to :json
6
+ respond_to :json if ::Rails::VERSION::MAJOR < 5
7
7
  before_action :authenticate_requests!
8
8
 
9
9
  private
@@ -6,7 +6,7 @@ module Lit
6
6
  class LocalesController < Api::V1::BaseController
7
7
  def index
8
8
  @locales = Locale.all
9
- render json: @locales.as_json(root: false, only: [:id, :locale])
9
+ render json: @locales.as_json(root: false, only: %i[id locale])
10
10
  end
11
11
  end
12
12
  end
@@ -3,13 +3,21 @@ require_dependency 'lit/api/v1/base_controller'
3
3
  module Lit
4
4
  class Api::V1::LocalizationKeysController < Api::V1::BaseController
5
5
  def index
6
- @localization_keys = LocalizationKey
6
+ @localization_keys = fetch_localization_keys
7
+ render json: @localization_keys.as_json(
8
+ root: false, only: %i[id localization_key is_deleted]
9
+ )
10
+ end
11
+
12
+ private
13
+
14
+ def fetch_localization_keys
7
15
  if params[:after].present?
8
- @localization_keys = @localization_keys.after(DateTime.parse(params[:after])).to_a
16
+ after_date = Time.parse(params[:after])
17
+ LocalizationKey.after(after_date).to_a
9
18
  else
10
- @localization_keys = @localization_keys.all
19
+ LocalizationKey.all
11
20
  end
12
- render json: @localization_keys.as_json(root: false, only: [:id, :localization_key])
13
21
  end
14
22
  end
15
23
  end
@@ -1,18 +1,34 @@
1
1
  module Lit
2
2
  class Api::V1::LocalizationsController < Api::V1::BaseController
3
3
  def index
4
- @localizations = Localization
5
- if params[:after].present?
6
- @localizations = @localizations.after(DateTime.parse(params[:after])).to_a
7
- else
8
- @localizations = @localizations.all
9
- end
10
- render json: @localizations.as_json(root: false, only: [:id, :localization_key_id, :locale_id], methods: [:value, :localization_key_str, :locale_str])
4
+ @localizations = fetch_localizations
5
+ render json: @localizations.as_json(
6
+ root: false,
7
+ only: %i[id localization_key_id locale_id],
8
+ methods: %i[
9
+ value localization_key_str locale_str
10
+ localization_key_is_deleted
11
+ ]
12
+ )
11
13
  end
12
14
 
13
15
  def last_change
14
- @localization = Localization.order('updated_at DESC').first
15
- render json: @localization.as_json(root: false, only: [], methods: [:last_change])
16
+ @localization = Localization.order(updated_at: :desc).first
17
+ render json: @localization.as_json(
18
+ root: false, only: [], methods: [:last_change]
19
+ )
20
+ end
21
+
22
+ private
23
+
24
+ def fetch_localizations
25
+ if params[:after].present?
26
+ after_date = Time.parse("#{params[:after]} #{Time.zone.name}")
27
+ .in_time_zone
28
+ Localization.after(after_date).to_a
29
+ else
30
+ Localization.all
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -1,8 +1,8 @@
1
1
  module Lit
2
2
  class ApplicationController < ActionController::Base
3
3
  unless respond_to?(:before_action)
4
- alias_method :before_action, :before_filter
5
- alias_method :after_action, :after_filter
4
+ alias before_action before_filter
5
+ alias after_action after_filter
6
6
  end
7
7
  before_action :authenticate
8
8
  before_action :stop_hits_counter
@@ -24,16 +24,19 @@ module Lit
24
24
  Lit.init.cache.restore_hits_counter
25
25
  end
26
26
 
27
- def redirect_to_back_or_default(fallback_location: lit.localization_keys_path)
27
+ def redirect_to_back_or_default(fallback_location: nil)
28
+ fallback_location ||= lit.localization_keys_path
28
29
  if respond_to?(:redirect_back)
29
30
  redirect_back fallback_location: fallback_location
31
+ elsif referer.present? && referer != request.env['REQUEST_URI']
32
+ redirect_to :back
30
33
  else
31
- if request.env["HTTP_REFERER"].present? and request.env["HTTP_REFERER"] != request.env["REQUEST_URI"]
32
- redirect_to :back
33
- else
34
- redirect_to fallback_location
35
- end
34
+ redirect_to fallback_location
36
35
  end
37
36
  end
37
+
38
+ def referer
39
+ request.referer
40
+ end
38
41
  end
39
42
  end
@@ -14,3 +14,4 @@ module Lit
14
14
  end
15
15
  end
16
16
  end
17
+
@@ -2,37 +2,32 @@ require_dependency 'lit/application_controller'
2
2
 
3
3
  module Lit
4
4
  class IncommingLocalizationsController < ApplicationController
5
- before_action :find_source
5
+ before_action :find_source_and_incomming_localizations
6
+ before_action :find_icomming_localization, only: %i[accept destroy]
6
7
 
7
- def index
8
- @incomming_localizations = @source.incomming_localizations
9
- end
8
+ def index; end
10
9
 
11
10
  def accept
12
- @incomming_localization = @source.incomming_localizations.find(params[:id].to_i)
13
11
  @incomming_localization.accept
14
- Lit.init.cache.refresh_key @incomming_localization.full_key
15
12
  respond_to do |format|
16
- format.html { redirect_to_back_or_default(fallback_location: source_incomming_localizations_path(@source)) }
13
+ format.html { finish_request }
17
14
  format.js
18
15
  end
19
16
  end
20
17
 
21
18
  def accept_all
22
- @source.incomming_localizations.each do |li|
23
- li.accept
24
- Lit.init.cache.refresh_key li.full_key
19
+ ActiveRecord::Base.transaction do
20
+ @incomming_localizations.each(&:accept)
25
21
  end
26
- redirect_to_back_or_default(fallback_location: source_incomming_localizations_path(@source))
22
+ finish_request
27
23
  end
28
24
 
29
25
  def reject_all
30
- @source.incomming_localizations.destroy_all
31
- redirect_to_back_or_default(fallback_location: source_incomming_localizations_path(@source))
26
+ @incomming_localizations.destroy_all
27
+ finish_request
32
28
  end
33
29
 
34
30
  def destroy
35
- @incomming_localization = @source.incomming_localizations.find(params[:id].to_i)
36
31
  @incomming_localization.destroy
37
32
  respond_to do |format|
38
33
  format.html { redirect_to source_incomming_localizations_path(@source) }
@@ -42,8 +37,20 @@ module Lit
42
37
 
43
38
  private
44
39
 
45
- def find_source
40
+ def find_icomming_localization
41
+ @incomming_localization = @source.incomming_localizations
42
+ .find(params[:id].to_i)
43
+ end
44
+
45
+ def find_source_and_incomming_localizations
46
46
  @source = Source.find(params[:source_id].to_i)
47
+ @incomming_localizations = @source.incomming_localizations
48
+ end
49
+
50
+ def finish_request
51
+ redirect_to_back_or_default(
52
+ fallback_location: source_incomming_localizations_path(@source)
53
+ )
47
54
  end
48
55
  end
49
56
  end
@@ -13,7 +13,7 @@ module Lit
13
13
 
14
14
  def hide
15
15
  @locale = Locale.find(params[:id])
16
- @locale.is_hidden = !@locale.is_hidden?
16
+ @locale.toggle :is_hidden
17
17
  @locale.save
18
18
  respond_to :js
19
19
  end
@@ -1,14 +1,28 @@
1
1
  module Lit
2
2
  class LocalizationKeysController < ::Lit::ApplicationController
3
- before_action :get_localization_scope, except: [:destroy, :find_localization]
3
+ before_action :find_localization_scope,
4
+ except: %i[destroy find_localization]
5
+ before_action :find_localization_key,
6
+ only: %i[star destroy change_completed restore_deleted]
4
7
 
5
8
  def index
6
9
  get_localization_keys
7
10
  end
8
11
 
12
+ def not_translated
13
+ @scope = @scope.not_completed
14
+ get_localization_keys
15
+ end
16
+
17
+ def visited_again
18
+ @scope = @scope.unscope(where: :is_deleted).not_active.visited_again
19
+ get_localization_keys
20
+ end
21
+
9
22
  def find_localization
10
- localization_key = Lit::LocalizationKey. \
11
- find_by!(localization_key: params[:key])
23
+ localization_key = Lit::LocalizationKey.find_by!(
24
+ localization_key: params[:key]
25
+ )
12
26
  locale = Lit::Locale.find_by!(locale: params[:locale])
13
27
  localization = localization_key.localizations.find_by(locale_id: locale)
14
28
  render json: {
@@ -19,7 +33,7 @@ module Lit
19
33
  def starred
20
34
  @scope = @scope.where(is_starred: true)
21
35
 
22
- if defined?(Kaminari) && \
36
+ if defined?(Kaminari) &&
23
37
  @scope.respond_to?(Kaminari.config.page_method_name)
24
38
  @scope = @scope.send(Kaminari.config.page_method_name, params[:page])
25
39
  end
@@ -28,31 +42,41 @@ module Lit
28
42
  end
29
43
 
30
44
  def star
31
- @localization_key = LocalizationKey.find params[:id].to_i
32
- @localization_key.is_starred = !@localization_key.is_starred?
45
+ @localization_key.toggle :is_starred
33
46
  @localization_key.save
34
47
  respond_to :js
35
48
  end
36
49
 
50
+ def change_completed
51
+ @localization_key.change_all_completed
52
+ respond_to :js
53
+ end
54
+
55
+ def restore_deleted
56
+ @localization_key.restore
57
+ respond_to :js
58
+ end
59
+
37
60
  def destroy
38
- @localization_key = LocalizationKey.find params[:id].to_i
39
- @localization_key.destroy
40
- I18n.backend.available_locales.each do |l|
41
- Lit.init.cache.delete_key "#{l}.#{@localization_key.localization_key}"
42
- end
61
+ @localization_key.soft_destroy
43
62
  respond_to :js
44
63
  end
45
64
 
46
65
  private
47
66
 
48
- def get_localization_scope
67
+ def find_localization_key
68
+ @localization_key = LocalizationKey.find params[:id].to_i
69
+ end
70
+
71
+ def find_localization_scope
49
72
  @search_options = if params.respond_to?(:permit)
50
73
  params.permit(*valid_keys)
51
74
  else
52
75
  params.slice(*valid_keys)
53
76
  end
54
- @search_options[:include_completed] = '1' if @search_options.empty?
55
- @scope = LocalizationKey.distinct.preload(localizations: :locale).search(@search_options)
77
+ @scope = LocalizationKey.distinct.active
78
+ .preload(localizations: :locale)
79
+ .search(@search_options)
56
80
  end
57
81
 
58
82
  def get_localization_keys
@@ -70,7 +94,7 @@ module Lit
70
94
  end
71
95
 
72
96
  def valid_keys
73
- %w( key include_completed key_prefix order )
97
+ %w[key key_prefix order]
74
98
  end
75
99
 
76
100
  def grouped_localizations
@@ -105,13 +129,15 @@ module Lit
105
129
  end
106
130
  helper_method :localization_for
107
131
 
108
- def has_versions?(localization)
132
+ def versions?(localization)
109
133
  @_versions ||= begin
110
134
  ids = grouped_localizations.values.map(&:values).flatten.map(&:id)
111
- Lit::Localization.where(id: ids).joins(:versions).group("#{Lit::Localization.quoted_table_name}.id").count
135
+ Lit::Localization.active.where(id: ids).joins(:versions).group(
136
+ "#{Lit::Localization.quoted_table_name}.id"
137
+ ).count
112
138
  end
113
139
  @_versions[localization.id].to_i > 0
114
140
  end
115
- helper_method :has_versions?
141
+ helper_method :versions?
116
142
  end
117
143
  end