the_actual_locales 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/gem_version.rb +3 -0
- data/lib/the_actual_locales/i18n_patch.rb +18 -0
- data/lib/the_actual_locales/version.rb +1 -0
- data/lib/the_actual_locales.rb +45 -0
- data/the_actual_locales.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5380ba380be0daabee0fabcc59f8974bda574a5f
|
4
|
+
data.tar.gz: f8f6d8d031d03e82847c7c2d079db874170c1014
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0eb1da8c9b64a33aac00a72999cae0acc1fdce2c294259f859881d6cfc20d404c1bc8617ebe5e3acc826622a63281854fb3fd7160228871ba58bb02dc4e74bc
|
7
|
+
data.tar.gz: 7de7cb225c6ce7118c779e6c4fceba4ab2c5b7e262baa7faea95bc3839b11609a557b8afec4bf037523a557b57f63566f86212b470ffb73ee00750f8be160bc2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ilya N. Zykin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## TheActualLocales
|
2
|
+
|
3
|
+
Way to find and log actual localization keys into your i18n locale files
|
4
|
+
|
5
|
+
### The Problem
|
6
|
+
|
7
|
+
It can be difficult to find actual localization keys after months of maintenance of rails project
|
8
|
+
|
9
|
+
### The Solution
|
10
|
+
|
11
|
+
This gem collect all executed `I18n.translate` and `I18n.t` calls and dump it into YAML file at
|
12
|
+
`#{Rails.root}/log/`
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
group :development do
|
18
|
+
gem 'the_actual_locales', '~> 0.0.1'
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
### Usage
|
29
|
+
|
30
|
+
1. Install gem
|
31
|
+
2. exec `rails s`
|
32
|
+
2. Visit required pages with required locales
|
33
|
+
3. Learn `/log/actual_locale.LOCALE_NAME.yml`
|
34
|
+
|
35
|
+
#### MIT license
|
data/Rakefile
ADDED
data/gem_version.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module I18n
|
2
|
+
class << self
|
3
|
+
def translate(*args)
|
4
|
+
tname = args.try :[], 0
|
5
|
+
_args = args.try :[], 1
|
6
|
+
scope = Array.wrap _args.try(:[],:scope) || _args.try(:[], 'scope')
|
7
|
+
|
8
|
+
key = [ scope, tname ].flatten
|
9
|
+
value = super
|
10
|
+
|
11
|
+
TheActualLocales.dump(locale.to_s, key, value)
|
12
|
+
|
13
|
+
value
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :t, :translate
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../../gem_version.rb'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "the_actual_locales/version"
|
2
|
+
|
3
|
+
module TheActualLocales
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
config.after_initialize do
|
6
|
+
require "the_actual_locales/i18n_patch"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.log_path locale
|
11
|
+
"#{ Rails.root }/log/actual_locale.#{ locale }.yml"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.dump locale, path, value
|
15
|
+
# Create actual file if not exists
|
16
|
+
log_path = self.log_path(locale)
|
17
|
+
File.open(log_path, 'w+').close unless File.exists? log_path
|
18
|
+
|
19
|
+
# Open and read actual locale file
|
20
|
+
i18n_log = File.open(log_path, "r")
|
21
|
+
log_content = i18n_log.read
|
22
|
+
i18n_log.close
|
23
|
+
|
24
|
+
# Read YAML
|
25
|
+
# Create { 'en' => {} } if exception
|
26
|
+
locale_data = (begin; YAML.load(log_content); rescue; {}; end) || {}
|
27
|
+
locale_data[locale] = {} unless locale_data[locale]
|
28
|
+
|
29
|
+
# Set base values
|
30
|
+
path_size = path.size - 1
|
31
|
+
current_level = locale_data[locale]
|
32
|
+
|
33
|
+
# Set base values
|
34
|
+
path.each_with_index do |v, i|
|
35
|
+
_value = (path_size == i) ? value : {}
|
36
|
+
current_level[v.to_s] = _value unless current_level[v.to_s]
|
37
|
+
current_level = current_level[v.to_s]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Open actual locale file and write
|
41
|
+
i18n_log = File.open(log_path, 'w')
|
42
|
+
i18n_log.write locale_data.to_yaml
|
43
|
+
i18n_log.close
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'the_actual_locales/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "the_actual_locales"
|
8
|
+
spec.version = TheActualLocales::VERSION
|
9
|
+
spec.authors = ["Ilya N. Zykin"]
|
10
|
+
spec.email = ["zykin-ilya@ya.ru"]
|
11
|
+
spec.summary = %q{Actual locales logger}
|
12
|
+
spec.description = %q{Find required locales keys}
|
13
|
+
spec.homepage = "https://github.com/the-teacher/the_actual_locales"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rails", '~> 0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: the_actual_locales
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilya N. Zykin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Find required locales keys
|
56
|
+
email:
|
57
|
+
- zykin-ilya@ya.ru
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- gem_version.rb
|
68
|
+
- lib/the_actual_locales.rb
|
69
|
+
- lib/the_actual_locales/i18n_patch.rb
|
70
|
+
- lib/the_actual_locales/version.rb
|
71
|
+
- the_actual_locales.gemspec
|
72
|
+
homepage: https://github.com/the-teacher/the_actual_locales
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Actual locales logger
|
96
|
+
test_files: []
|