extract_i18n 0.6.2 → 0.7.0
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 +4 -4
- data/CONTRIBUTING.md +14 -0
- data/README.md +12 -0
- data/extract_i18n.gemspec +6 -3
- data/js/.gitignore +1 -0
- data/js/.tool-versions +1 -0
- data/js/find_string_tokens.js +106 -0
- data/lib/extract_i18n/adapters/adapter.rb +1 -0
- data/lib/extract_i18n/adapters/js_adapter.rb +79 -0
- data/lib/extract_i18n/adapters/vue_adapter.rb +18 -1
- data/lib/extract_i18n/adapters/vue_pug_adapter.rb +24 -0
- data/lib/extract_i18n/version.rb +1 -1
- data/lib/extract_i18n.rb +14 -4
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d821da5a501918ce7aab427aeeb58ba4da863e1f87b4d846e256753301f55fcc
|
4
|
+
data.tar.gz: ab6d26c92aa2ae78d15fe1e802fb6024febf78d281c07117e6b0793aa369a997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 396e63617070e13ee79c0353e5c847289d19e9b7643d6897ea14af84740b86232759ff4edea52584431b713eb4c4d1a7b8f30fe734ab936a95b06860af909233
|
7
|
+
data.tar.gz: 5808700e8db2e02eea5f62c04804d68613ed8a2f711ca71976a3acd4c0eda04a1ab57fbb77bb61f44554ab8d16142451507fa8588df7451a8e5f34abde02f340
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Contributing Guide
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/extract_i18n)
|
4
|
+
|
5
|
+
## Workflow
|
6
|
+
- fork the repository and setup the environment
|
7
|
+
- create a new branch: `feature/xxx`, `fix/xxx`
|
8
|
+
- commit codes and tests to finish the feature or bug fix
|
9
|
+
- push to remote and create a pull request
|
10
|
+
|
11
|
+
## Environment setup
|
12
|
+
- use ruby version: 2.6
|
13
|
+
- install dependencies: `bundle install`
|
14
|
+
- make sure the test passed: `bundle exec rspec`
|
data/README.md
CHANGED
@@ -17,12 +17,16 @@ This Gem **supports** the following source files:
|
|
17
17
|
- Caveats: because of limitations of the HTML/XML parser it will slightly transform the HTML, for example, self closing tags are expanded (e.g. ``<Component />`` will become ``<Component></Component>``). Also multi-line arrangements of attributes, tags etc. might produce unexpected results, so make sure to use Git and diff the result.
|
18
18
|
- Vue Pug views
|
19
19
|
- Pug is very similar to slim and thus relatively well extractable via Regexp.
|
20
|
+
- Javascript string Literals by vendoring a small **nodeJS** script in ``js/find_string_tokens.js`` (requires node16+).
|
21
|
+
- Vue: Literal strings in script block (via bundled nodejs file)
|
22
|
+
- JS/TS: Literal strings
|
20
23
|
- ERB views
|
21
24
|
- by vendoring/extending https://github.com/ProGM/i18n-html_extractor (MIT License)
|
22
25
|
|
23
26
|
CURRENTLY THERE IS **NO SUPPORT** FOR:
|
24
27
|
|
25
28
|
- haml ( integrating https://github.com/shaiguitar/haml-i18n-extractor)
|
29
|
+
- JS: Template-Literals
|
26
30
|
|
27
31
|
But I am open to integrating PRs for those!
|
28
32
|
|
@@ -49,6 +53,14 @@ extract-i18n --locale de --yaml config/locales/unsorted.de.yml app/views/user
|
|
49
53
|
If you prefer relative keys in slim views use ``--slim-relative``, e.g. ``t('.title')`` instead of ``t('users.index.title')``.
|
50
54
|
I prefer absolute keys, as it makes copy pasting/ moving files much safer.
|
51
55
|
|
56
|
+
To extract Vue/JS files, we usually put them in a namespace ``js.*`` and handle them with i18n-tasks as well, so to extract Vue-Components, or plain JS files:
|
57
|
+
|
58
|
+
```
|
59
|
+
extract-i18n --locale de --yaml config/locales/unsorted.de.yml -n js app/javascript/components/Foobar.vue
|
60
|
+
```
|
61
|
+
|
62
|
+
Will prefix the keys with ``js.components.foobar``. This system also switches the **interpolation format** from ``%{foo}`` to ``{foo}``, when handling Vue,JS,TS file.
|
63
|
+
|
52
64
|
|
53
65
|
## Contributing
|
54
66
|
|
data/extract_i18n.gemspec
CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = ExtractI18n::VERSION
|
8
8
|
spec.authors = ["Stefan Wienert"]
|
9
9
|
spec.email = ["info@stefanwienert.de"]
|
10
|
+
spec.metadata = { "rubygems_mfa_required" => "true" }
|
10
11
|
|
11
12
|
spec.summary = %q{Extact i18n from Ruby files using Ruby parser and slim files using regex}
|
12
13
|
spec.description = %q{Extact i18n from Ruby files using Ruby parser and slim files using regex interactively}
|
@@ -20,10 +21,12 @@ Gem::Specification.new do |spec|
|
|
20
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
22
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
23
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
-
end
|
24
|
-
|
25
|
-
spec.
|
24
|
+
end - ['js/build.js', 'js/package.json', 'js/yarn.lock', 'js/run.mjs']
|
25
|
+
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables << "extract-i18n"
|
26
28
|
spec.require_paths = ["lib"]
|
29
|
+
spec.required_ruby_version = '>= 2.7.0'
|
27
30
|
|
28
31
|
spec.add_runtime_dependency 'nokogiri'
|
29
32
|
spec.add_runtime_dependency 'parser', '>= 2.6'
|
data/js/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
node_modules
|
data/js/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
nodejs 18.12.1
|