lit 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,7 +12,7 @@ Highly inspired by Copycopter by thoughtbot.
12
12
  1. Runs with your app - no need for external services
13
13
  2. Support for array types, (ie. `date.abbr_day_names`)
14
14
  3. Versioning translations - you can always check, how value did look like in past
15
- 4. Possibility to synchronize between environments or even apps
15
+ 4. Possibility to synchronize translations between environments or apps
16
16
  5. Easy to install - works as an engine, comes with simple generator
17
17
  6. You can always export all translations to plain old YAML file
18
18
  7. Has build in wysiwyg editor ([jQuery TE](http://jqueryte.com/))
@@ -21,19 +21,26 @@ Highly inspired by Copycopter by thoughtbot.
21
21
 
22
22
  Check wiki: [Screenshots](https://github.com/prograils/lit/wiki/Screenshots)
23
23
 
24
+ ### So... again - what is it and how to use it?
25
+ *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.
26
+
27
+ 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.
28
+
29
+ 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).
30
+
24
31
  ### Installation
25
32
 
26
33
  1. Add `lit` gem to your `Gemfile`
27
34
  ```ruby
28
- gem "lit"
29
- ````
35
+ gem 'lit'
36
+ ```
30
37
 
31
38
  2. run `bundle install`
32
39
 
33
40
  3. run installation generator `bundle exec rails g lit:install`
34
41
  (for production/staging environment `redis` is suggested as key value engine. `hash` will not work in multi process environment)
35
42
 
36
- 4. After doing above and restarting app, point your browser to ```http://app/lit```
43
+ 4. After doing above and restarting app, point your browser to `http://app/lit`
37
44
 
38
45
  5. Profit!
39
46
 
@@ -54,7 +61,7 @@ You may want to take a look at generated initializer in `config/initializers/lit
54
61
  * Better cache
55
62
  * ~~Support for other key value providers (ie. Redis does not support Array types in easy way)~~ (not applicable, as array storage works now with redis).
56
63
  * Integration with ActiveAdmin
57
- * Support for Proc defaults (like in `I18n.t("not_exising_keys", :default=> lambda{|_, options| "text"})` )
64
+ * Support for Proc defaults (like in `I18n.t('not_exising_keys', default: lambda{|_, options| 'text'})` )
58
65
 
59
66
 
60
67
  ### License
@@ -32,9 +32,12 @@ module Lit
32
32
 
33
33
  def clear_params
34
34
  if defined?(::ActionController::StrongParameters)
35
- clear_params = params.require(:localization).permit(:translated_value, :locale_id)
36
- clear_params.merge! params.require(:localization).permit(:translated_value => []) # allow translated_value to be an array
37
- clear_params
35
+ # allow translated_value to be an array
36
+ if @localization.value.is_a?(Array)
37
+ params.require(:localization).permit(:locale_id, :translated_value => [])
38
+ else
39
+ params.require(:localization).permit(:locale_id, :translated_value)
40
+ end
38
41
  else
39
42
  params[:localization].is_a?(Hash) ? params[:localization].slice(:translated_value, :locale_id) : {}
40
43
  end
@@ -1,6 +1,6 @@
1
1
  <%= paginator.render do %>
2
- <div class="pagination">
3
- <ul>
2
+ <div>
3
+ <ul class="pagination">
4
4
  <%= first_page_tag unless current_page.first? %>
5
5
  <%= prev_page_tag unless current_page.first? %>
6
6
  <% each_page do |page| %>
@@ -29,7 +29,10 @@ module Lit
29
29
  # @param [Hash] data nested key-value pairs to be added as blurbs
30
30
  def store_translations(locale, data, options = {})
31
31
  super
32
- store_item(locale, data)
32
+ locales = ::Rails.configuration.i18n.available_locales
33
+ if !locales || locales.map(&:to_s).include?(locale.to_s)
34
+ store_item(locale, data)
35
+ end
33
36
  end
34
37
 
35
38
 
@@ -1,3 +1,3 @@
1
1
  module Lit
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  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.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-08 00:00:00.000000000 Z
12
+ date: 2014-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -228,6 +228,7 @@ files:
228
228
  - app/assets/images/lit/famfamfam_flags/ir.png
229
229
  - app/assets/images/lit/famfamfam_flags/is.png
230
230
  - app/assets/images/lit/famfamfam_flags/it.png
231
+ - app/assets/images/lit/famfamfam_flags/ja.png
231
232
  - app/assets/images/lit/famfamfam_flags/jm.png
232
233
  - app/assets/images/lit/famfamfam_flags/jo.png
233
234
  - app/assets/images/lit/famfamfam_flags/jp.png