i18n-analyzer 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6ff7a3c2ece55420785b938db6410a5054f24e6304b4e5b0e1897edb0bcd7f41
4
+ data.tar.gz: 637d9ef134e5b95cded7b2cdae33669d8c0038dd33faa146945853f57a856a20
5
+ SHA512:
6
+ metadata.gz: 06e137807490742fa26e3898e1338f2b748d8e8f9fc7f5ac74ff12a84618893485278cbdf399abf19db68e96931b60c38a025aa01add50241b4cad0f4bddaa5c
7
+ data.tar.gz: 856765900a00b0d2bb5280f7081db4df4a321c4836ed65165529525112bf6d4bd8fd45660febc0315b0d948a7317de372df3263400611c880edce127ee6589df
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright hko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # I18n::Analyzer
2
+ I18n-Analyzer is a small and mountable gem developed by open-circle-ltd for analyzing I18n translations. It gives you an additional page, where you can exactly see, what is translated and what is still missing, from model classes to its fields.
3
+
4
+ ## Usage
5
+ Look at the installation section
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "i18n-analyzer"
12
+ ```
13
+
14
+ Then add this line to your application's routes.rb:
15
+
16
+ ```ruby
17
+ mount I18n::Analyzer::Engine, at: '/analyzer'
18
+ ```
19
+ it is also possible to create another link, if it is necessary
20
+
21
+ ### Security Note
22
+ If the analyzer is being mounted, it is recommended to safeguard it by mounting the analyzer in a protected namespace, an example would look like this in routes.rb:
23
+ ```ruby
24
+ authenticate :admin do
25
+ # other mountable apps, not visible for the world
26
+ mount I18n::Analyzer::Engine, at: '/analyzer'
27
+ end
28
+ ```
29
+
30
+ And then execute:
31
+ ```bash
32
+ $ bundle
33
+ ```
34
+
35
+
36
+ ~~Or install it yourself as:~~ Not working for now, gem has to be yet published
37
+ ```bash
38
+ $ gem install i18n-analyzer
39
+ ```
40
+
41
+ ## Using Library locally
42
+ You can also use the library locally, the steps are as follows:
43
+
44
+ ```ruby
45
+ gem "i18n-analyzer", path: '/path/to/your/gem/i18n-analyzer'
46
+ ```
47
+
48
+ Then add this line to your application's routes.rb:
49
+
50
+ ```ruby
51
+ mount I18n::Analyzer::Engine, at: '/analyzer'
52
+ ```
53
+
54
+ And then execute:
55
+ ```bash
56
+ $ bundle
57
+ ```
58
+
59
+ ## Contributing
60
+ Feel free to create a pull request
61
+
62
+ ## License
63
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ // TODO: configure file
2
+ // link i18n/analyzer/application.css
@@ -0,0 +1,18 @@
1
+ /*
2
+ This file is commented out for now, later on it will be worked upon
3
+ */
4
+ /*
5
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
6
+ * listed below.
7
+ *
8
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
9
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
10
+ *
11
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
12
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
13
+ * files in this directory. Styles in this file should be added after the last require_* statement.
14
+ * It is generally better to create a new file per style scope.
15
+ *
16
+ *= require_tree .
17
+ *= require_self
18
+ */
@@ -0,0 +1,5 @@
1
+ module I18n::Analyzer
2
+ class AnalyzersController < ApplicationController
3
+ def index; end
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module I18n
2
+ module Analyzer
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,52 @@
1
+ -# TODO: implement bootstrap to replace css
2
+ -# NOTE: CSS was implemented to make the functionality presentable. Please do not roast this css
3
+ :css
4
+ *{ font-family: sans-serif; text-align: center; margin-left: auto; margin-right: auto;} .analyzer-table {font-family: Arial, Helvetica, sans-serif; border-collapse: collapse; width: 60%;} .analyzer-table td, .analyzer-table th {border: 1px solid #ddd; padding: 8px;} .analyzer-table th {padding-top: 12px;padding-bottom: 12px;text-align: center;background-color: #0d3862;color: white;} .no-translation{background-color: #c12917; color: white;}
5
+
6
+ %h1 I18N - ActiveRecord Debug
7
+ - Rails.application.eager_load! if Rails.env.development?
8
+ - models = ApplicationRecord.descendants
9
+ %table.analyzer-table
10
+ %tr
11
+ %th
12
+ %th{colspan: 2} DE
13
+ %th{colspan: 2} EN
14
+ %tr
15
+ %th Model
16
+ %th Singular
17
+ %th Plural
18
+ %th Singular
19
+ %th Plural
20
+ - models.sort_by { |i| i.name }.each do |model|
21
+ %tr
22
+ %th= model.name
23
+ - I18n.with_locale(:de) do
24
+ %td{class: "#{'no-translation' if model.model_name.human(count: 1, default: '').empty?}"}
25
+ = model.model_name.human(count: 1)
26
+ %td{class: "#{'no-translation' if model.model_name.human(count: 99, default: '').empty?}"}
27
+ = model.model_name.human(count: 99)
28
+
29
+ - I18n.with_locale(:en) do
30
+ %td{class: "#{'no-translation' if model.model_name.human(count: 1, default: '').empty?}"}
31
+ = model.model_name.human(count: 1)
32
+ %td{class: "#{'no-translation' if model.model_name.human(count: 99, default: '').empty?}"}
33
+ = model.model_name.human(count: 99)
34
+
35
+ - models.sort_by { |i| i.name }.each do |model|
36
+ %h2= model.name
37
+ %table.analyzer-table
38
+ %tr
39
+ %th Attribute
40
+ -# TODO: make it, that it reads out the languages from the project and then it loops through the languages
41
+ %th DE
42
+ %th EN
43
+ - model.new.attributes.sort_by { |i| i }.each do |atr, _value|
44
+ %tr
45
+ %th= atr
46
+ - I18n.with_locale(:de) do
47
+ %td{class: "#{'no-translation' if model.human_attribute_name(atr, default: '').empty?}"}
48
+ = model.human_attribute_name(atr)
49
+
50
+ - I18n.with_locale(:en) do
51
+ %td{class: "#{'no-translation' if model.human_attribute_name(atr, default: '').empty?}"}
52
+ = model.human_attribute_name(atr)
@@ -0,0 +1,10 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ %title I18n-Analyzer
6
+ = csrf_meta_tags
7
+ = csp_meta_tag
8
+ = yield :head
9
+ %body
10
+ = yield
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ I18n::Analyzer::Engine.routes.draw do
2
+ root to: "analyzers#index"
3
+ end
@@ -0,0 +1,12 @@
1
+ module I18n
2
+ module Analyzer
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace I18n::Analyzer
5
+
6
+ # TODO: figure out asset precompilation
7
+ # initializer "i18n_analyzer.assets.precompile" do |app|
8
+ # app.config.assets.precompile += %w[i18n_analyzer/application.css]
9
+ # end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module I18n
2
+ # TODO: make versioning dynamically with semantic release
3
+ module Analyzer
4
+ VERSION = "0.1.3"
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ require "i18n/analyzer/version"
2
+ require "i18n/analyzer/engine"
3
+
4
+ module I18n
5
+ module Analyzer
6
+ # NOTE: This is an important method, do not delete this, this was carefully designed and reviewed
7
+ def self.❨╯°□°❩╯︵┻━┻
8
+ puts "Take a deep breath and count to ten..."
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n-analyzer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - opencircle-operator
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-03-12 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 7.0.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '7.0'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 7.0.1
32
+ - !ruby/object:Gem::Dependency
33
+ name: haml
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '5'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '5'
46
+ description: I18n-Analyzer is a small and mountable gem developed by open-circle-ltd
47
+ for analyzing I18n translations. It gives you an additional page, where you can
48
+ exactly see, what is translated and what is still missing, from model classes to
49
+ its fields.
50
+ email:
51
+ - operator@open-circle.ch
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - MIT-LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - app/assets/config/manifest.js
60
+ - app/assets/stylesheets/i18n/analyzer/application.css
61
+ - app/controllers/i18n/analyzer/analyzers_controller.rb
62
+ - app/controllers/i18n/analyzer/application_controller.rb
63
+ - app/views/i18n/analyzer/analyzers/index.html.haml
64
+ - app/views/layouts/i18n/analyzer/application.html.haml
65
+ - config/routes.rb
66
+ - lib/i18n/analyzer.rb
67
+ - lib/i18n/analyzer/engine.rb
68
+ - lib/i18n/analyzer/version.rb
69
+ homepage: https://github.com/open-circle-ltd/i18n-analyzer
70
+ licenses:
71
+ - MIT
72
+ metadata:
73
+ homepage_uri: https://github.com/open-circle-ltd/i18n-analyzer
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 3.3.0
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.6.2
89
+ specification_version: 4
90
+ summary: A mountable gem for analyzing I18n translations in your rails application.
91
+ test_files: []