i18nize 0.5 → 0.5.1
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/CHANGELOG.md +93 -2
- data/README.md +57 -40
- data/lib/i18nize/version.rb +1 -1
- metadata +15 -9
- data/.idea/.gitignore +0 -8
- data/.idea/git_toolbox_prj.xml +0 -15
- data/.idea/i18nize.iml +0 -53
- data/.idea/material_theme_project_new.xml +0 -12
- data/.idea/vcs.xml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecaecd54d2f036282dddadfefe26591090c54272cf6a5646fb12d53367509795
|
|
4
|
+
data.tar.gz: '08adc947c1a7b46f2f7e3dc486d3429bb9e404ed9d7b61ab683a6813ee45cbd2'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a32cac5c9df881264c7ae1688345410efa5ed64d8a3481526f83d2f4ef84f888af4e83fdce0af2da09f9f2594918d2606ffe31bd3c66e4a7af84f823c2443eb
|
|
7
|
+
data.tar.gz: 68fa3a1028e87cf9965e20be6ab5b663c438b0b27ec3269fc8fc7a4543a59551f832d206e416cf79784e38cca474be09aa9ddc47d208bd581cf0aa830f0d4ce5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
1
3
|
## [Unreleased]
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
### Changed
|
|
9
|
+
### Removed
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## [0.5.0] - 2025-09-08
|
|
17
|
+
### Added
|
|
18
|
+
- **Conflict policy**: source locale is now treated as the source of truth.
|
|
19
|
+
If the target locale has a scalar where a nested hash is required, the scalar is **overwritten** with the correct structure from the source.
|
|
20
|
+
- **Pluralization support**: automatic handling of `one`, `other`, and related plural keys. Scalars can be coerced into plural hashes.
|
|
21
|
+
- **Placeholder preservation**: `%{count}` and other I18n-style placeholders are protected from being altered by DeepL.
|
|
22
|
+
- Improved file name detection for `.yml` and `.yaml` formats, including names like `app.en.yml`.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Default behaviour: conflicts are no longer skipped or raise errors, but are resolved by overwriting with source locale values.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
- **Rake task `i18nize:translate`** has been removed.
|
|
29
|
+
Use the CLI instead:
|
|
30
|
+
```bash
|
|
31
|
+
i18nize cs
|
|
32
|
+
i18nize cs --from en
|
|
33
|
+
i18nize cs --missing
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
* Eliminated `IndexError: string not matched` errors when attempting to insert into scalar values.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## \[0.4.4] - 2025-09-08
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
* CLI option `--missing [FROM]` to list missing keys without translating.
|
|
47
|
+
|
|
48
|
+
* `i18nize cs --missing` → shows missing Czech keys (from English).
|
|
49
|
+
* `i18nize cs --missing de` → shows missing Czech keys (from German).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## \[0.4.2.1] - 2025-09-08
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
* Correct requires for `Translator` and `Inserter` inside CLI (prevented `NameError`).
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## \[0.4.2] - 2025-09-08
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
|
|
65
|
+
* `.env` file support (via `dotenv` if present).
|
|
66
|
+
* Improved CLI error messages.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## \[0.4.1] - 2025-09-08
|
|
71
|
+
|
|
72
|
+
### Fixed
|
|
73
|
+
|
|
74
|
+
* File path normalization for top-level locales (`en.yml` → `cs.yml`).
|
|
75
|
+
* Safer regex for file name replacement.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## \[0.4.0] - 2025-08-25
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
|
|
83
|
+
* Standalone CLI (`i18nize <locale>`) — no need to call only via Rake.
|
|
84
|
+
* Basic `--from` option for source language.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## \[0.1.0] - 2025-07-30
|
|
89
|
+
|
|
90
|
+
### Added
|
|
4
91
|
|
|
5
|
-
|
|
92
|
+
* Initial release.
|
|
93
|
+
* DeepL translation of missing keys.
|
|
94
|
+
* Character count estimation and confirmation prompt.
|
|
95
|
+
* Automatic creation of target locale files.
|
|
96
|
+
* Rake task `i18nize:translate[locale]`.
|
data/README.md
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
# i18nize
|
|
2
2
|
|
|
3
|
-
🧠 Automatically fills in missing I18n YAML keys using DeepL translation API.
|
|
3
|
+
🧠 Automatically fills in missing I18n YAML keys using DeepL translation API.
|
|
4
4
|
Designed to streamline multi-language support in Ruby and Rails projects.
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
## ✨ Features
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
* Detects missing or empty translation keys in locale files
|
|
9
|
+
* Supports multiple YAML files and nested directories (e.g. `config/locales/api/en.yml`)
|
|
10
|
+
* Automatically translates from a source locale (**default: `en`**) to a target (e.g. `cs`)
|
|
11
|
+
* Integrates with DeepL API (Free or Pro)
|
|
12
|
+
* Safely merges translations into corresponding `*.yml` files
|
|
13
|
+
* Handles structural conflicts by overwriting target with source truth
|
|
14
|
+
* Character count check with confirmation prompt
|
|
15
|
+
* CLI (`i18nize`)
|
|
17
16
|
|
|
18
17
|
## 🔧 Installation
|
|
19
18
|
|
|
@@ -21,7 +20,7 @@ Add this line to your application's Gemfile:
|
|
|
21
20
|
|
|
22
21
|
```ruby
|
|
23
22
|
gem "i18nize"
|
|
24
|
-
|
|
23
|
+
```
|
|
25
24
|
|
|
26
25
|
Then run:
|
|
27
26
|
|
|
@@ -35,61 +34,70 @@ Or install manually:
|
|
|
35
34
|
gem install i18nize
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
|
|
39
37
|
## 🚀 Usage
|
|
40
38
|
|
|
41
39
|
### 1. Set your DeepL API key
|
|
42
40
|
|
|
43
|
-
Create a `.env` or export it in your shell:
|
|
41
|
+
Create a `.env` file (loaded automatically if you use `dotenv`) or export it in your shell:
|
|
44
42
|
|
|
45
43
|
```bash
|
|
46
44
|
export DEEPL_API_KEY=your-api-key
|
|
47
45
|
export DEEPL_ENDPOINT=https://api.deepl.com/v2/translate # Only if you are using a DeepL Pro account
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
👉 You can use the [Free DeepL API](https://www.deepl.com/pro#developer).
|
|
53
49
|
|
|
54
|
-
### 2. Run
|
|
50
|
+
### 2. Run translations via CLI
|
|
55
51
|
|
|
56
52
|
```bash
|
|
57
|
-
|
|
53
|
+
# Translate from en → cs
|
|
54
|
+
i18nize cs
|
|
55
|
+
|
|
56
|
+
# Translate from de → fr
|
|
57
|
+
i18nize fr --from de
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
💬 This will:
|
|
61
61
|
|
|
62
|
-
* Scan config/locales/**/*en.yml (
|
|
63
|
-
* Detect which `
|
|
62
|
+
* Scan `config/locales/**/*en.yml` (or your chosen source language)
|
|
63
|
+
* Detect which `cs.yml` files are missing keys
|
|
64
64
|
* Use DeepL to translate missing values
|
|
65
|
-
* Write them to the appropriate files (
|
|
65
|
+
* Write them to the appropriate files (creating them if needed)
|
|
66
|
+
|
|
67
|
+
### 3. Show missing keys only
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Missing cs keys (source en)
|
|
71
|
+
i18nize cs --missing
|
|
72
|
+
|
|
73
|
+
# Missing cs keys (source de)
|
|
74
|
+
i18nize cs --missing de
|
|
75
|
+
```
|
|
66
76
|
|
|
77
|
+
This mode only lists missing keys, no translations are written.
|
|
67
78
|
|
|
68
79
|
|
|
69
80
|
## 🛡️ Character limit check
|
|
70
81
|
|
|
71
|
-
Before translating, the
|
|
82
|
+
Before translating, the CLI:
|
|
72
83
|
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
84
|
+
* Counts the total number of characters
|
|
85
|
+
* Warns if the count exceeds **500,000** (DeepL Free monthly limit)
|
|
86
|
+
* Asks for confirmation:
|
|
76
87
|
|
|
77
88
|
```text
|
|
78
89
|
[i18nize] Estimated character count: 43125
|
|
79
90
|
Proceed with translation? [y/N]:
|
|
80
91
|
```
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
|
|
84
93
|
## 🗂️ Locale file support
|
|
85
94
|
|
|
86
|
-
* Files are
|
|
95
|
+
* Files are matched by name:
|
|
87
96
|
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
* `config/locales/api/en.yml` → `config/locales/api/cs.yml`
|
|
98
|
+
* `config/locales/en.devise.yml` → `config/locales/cs.devise.yml`
|
|
90
99
|
* Missing files are created automatically
|
|
91
|
-
|
|
92
|
-
|
|
100
|
+
* If a scalar exists where a nested structure is required, **it is overwritten by source locale structure**
|
|
93
101
|
|
|
94
102
|
## 🧩 Example structure
|
|
95
103
|
|
|
@@ -102,7 +110,13 @@ config/locales/
|
|
|
102
110
|
│ └── cs.yml
|
|
103
111
|
```
|
|
104
112
|
|
|
105
|
-
After running
|
|
113
|
+
After running:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
i18nize cs
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
the gem will create:
|
|
106
120
|
|
|
107
121
|
```
|
|
108
122
|
config/locales/api/cs.yml
|
|
@@ -114,16 +128,19 @@ With keys translated from `api/en.yml`.
|
|
|
114
128
|
|
|
115
129
|
## 📦 Configuration
|
|
116
130
|
|
|
117
|
-
For now, configuration is via
|
|
118
|
-
Optional future support: `.i18nize.yml`.
|
|
131
|
+
For now, configuration is via CLI flags and environment variables:
|
|
119
132
|
|
|
133
|
+
* `--from LANG` (default `en`)
|
|
134
|
+
* `--missing [FROM]` (list missing keys only)
|
|
135
|
+
* `DEEPL_API_KEY` (required)
|
|
136
|
+
* `DEEPL_ENDPOINT` (optional, only for Pro)
|
|
120
137
|
|
|
138
|
+
---
|
|
121
139
|
|
|
122
140
|
## 🔍 TODO
|
|
123
141
|
|
|
124
|
-
*
|
|
125
|
-
* YAML key sorting
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
|
|
142
|
+
* RSpec test suite
|
|
143
|
+
* YAML key sorting / format preservation
|
|
144
|
+
* Richer conflict resolution strategies (configurable overwrite / skip)
|
|
145
|
+
* Use custom char limit
|
|
129
146
|
|
data/lib/i18nize/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: i18nize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- nikolas2145
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-09-
|
|
11
|
+
date: 2025-09-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: "i18nize helps Ruby and Rails projects stay multilingual by automatically
|
|
14
|
+
filling in \nmissing translations in I18n YAML locale files. It scans for missing
|
|
15
|
+
or empty keys \nacross nested locale structures, and uses the DeepL API (Free or
|
|
16
|
+
Pro) to translate \nthem from a chosen source locale (default: en).\n\nFeatures:\n-
|
|
17
|
+
Detects and lists missing translation keys\n- Automatically translates and inserts
|
|
18
|
+
values into the correct YAML files\n- Supports nested directories and multiple locale
|
|
19
|
+
files (e.g. config/locales/api/en.yml)\n- Preserves I18n placeholders such as %{count}\n-
|
|
20
|
+
Handles pluralization branches (one, other, etc.)\n- Source locale is treated as
|
|
21
|
+
the single source of truth (conflicts are resolved by overwrite)\n- Simple CLI:
|
|
22
|
+
`i18nize <locale>` or `i18nize <locale> --missing`\n\nThis gem streamlines the translation
|
|
23
|
+
workflow, making it easier to maintain \nconsistent, up-to-date locale files across
|
|
24
|
+
large Ruby on Rails applications.\n"
|
|
14
25
|
email:
|
|
15
26
|
- nikolas2145@gmail.com
|
|
16
27
|
executables:
|
|
@@ -18,11 +29,6 @@ executables:
|
|
|
18
29
|
extensions: []
|
|
19
30
|
extra_rdoc_files: []
|
|
20
31
|
files:
|
|
21
|
-
- ".idea/.gitignore"
|
|
22
|
-
- ".idea/git_toolbox_prj.xml"
|
|
23
|
-
- ".idea/i18nize.iml"
|
|
24
|
-
- ".idea/material_theme_project_new.xml"
|
|
25
|
-
- ".idea/vcs.xml"
|
|
26
32
|
- ".rspec"
|
|
27
33
|
- ".rubocop.yml"
|
|
28
34
|
- CHANGELOG.md
|
|
@@ -66,5 +72,5 @@ requirements: []
|
|
|
66
72
|
rubygems_version: 3.4.19
|
|
67
73
|
signing_key:
|
|
68
74
|
specification_version: 4
|
|
69
|
-
summary:
|
|
75
|
+
summary: Automatic DeepL-powered translations for I18n YAML files
|
|
70
76
|
test_files: []
|
data/.idea/.gitignore
DELETED
data/.idea/git_toolbox_prj.xml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="GitToolBoxProjectSettings">
|
|
4
|
-
<option name="commitMessageIssueKeyValidationOverride">
|
|
5
|
-
<BoolValueOverride>
|
|
6
|
-
<option name="enabled" value="true" />
|
|
7
|
-
</BoolValueOverride>
|
|
8
|
-
</option>
|
|
9
|
-
<option name="commitMessageValidationEnabledOverride">
|
|
10
|
-
<BoolValueOverride>
|
|
11
|
-
<option name="enabled" value="true" />
|
|
12
|
-
</BoolValueOverride>
|
|
13
|
-
</option>
|
|
14
|
-
</component>
|
|
15
|
-
</project>
|
data/.idea/i18nize.iml
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module version="4">
|
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
|
4
|
-
<shared />
|
|
5
|
-
</component>
|
|
6
|
-
<component name="RakeTasksCache-v2">
|
|
7
|
-
<option name="myRootTask">
|
|
8
|
-
<RakeTaskImpl id="rake">
|
|
9
|
-
<subtasks>
|
|
10
|
-
<RakeTaskImpl description="Build i18nize-0.4.0.gem into the pkg directory" fullCommand="build" id="build" />
|
|
11
|
-
<RakeTaskImpl id="build">
|
|
12
|
-
<subtasks>
|
|
13
|
-
<RakeTaskImpl description="Generate SHA512 checksum of i18nize-0.4.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
|
14
|
-
</subtasks>
|
|
15
|
-
</RakeTaskImpl>
|
|
16
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
|
17
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
|
18
|
-
<RakeTaskImpl id="i18nize">
|
|
19
|
-
<subtasks>
|
|
20
|
-
<RakeTaskImpl description="Auto-translate missing I18n keys using DeepL (usage: rake 'i18nize:translate[cs]')" fullCommand="i18nize:translate[to_locale]" id="translate[to_locale]" />
|
|
21
|
-
<RakeTaskImpl description="" fullCommand="i18nize:translate" id="translate" />
|
|
22
|
-
</subtasks>
|
|
23
|
-
</RakeTaskImpl>
|
|
24
|
-
<RakeTaskImpl description="Build and install i18nize-0.4.0.gem into system gems" fullCommand="install" id="install" />
|
|
25
|
-
<RakeTaskImpl id="install">
|
|
26
|
-
<subtasks>
|
|
27
|
-
<RakeTaskImpl description="Build and install i18nize-0.4.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
|
28
|
-
</subtasks>
|
|
29
|
-
</RakeTaskImpl>
|
|
30
|
-
<RakeTaskImpl description="Create tag v0.4.0 and build and push i18nize-0.4.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
|
31
|
-
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
|
32
|
-
<RakeTaskImpl id="rubocop">
|
|
33
|
-
<subtasks>
|
|
34
|
-
<RakeTaskImpl description="Autocorrect RuboCop offenses (only when it's safe)" fullCommand="rubocop:autocorrect" id="autocorrect" />
|
|
35
|
-
<RakeTaskImpl description="Autocorrect RuboCop offenses (safe and unsafe)" fullCommand="rubocop:autocorrect_all" id="autocorrect_all" />
|
|
36
|
-
<RakeTaskImpl description="" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
|
37
|
-
</subtasks>
|
|
38
|
-
</RakeTaskImpl>
|
|
39
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
|
40
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
|
41
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
|
42
|
-
<RakeTaskImpl id="release">
|
|
43
|
-
<subtasks>
|
|
44
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
|
45
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
|
46
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
|
47
|
-
</subtasks>
|
|
48
|
-
</RakeTaskImpl>
|
|
49
|
-
</subtasks>
|
|
50
|
-
</RakeTaskImpl>
|
|
51
|
-
</option>
|
|
52
|
-
</component>
|
|
53
|
-
</module>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="MaterialThemeProjectNewConfig">
|
|
4
|
-
<option name="metadata">
|
|
5
|
-
<MTProjectMetadataState>
|
|
6
|
-
<option name="migrated" value="true" />
|
|
7
|
-
<option name="pristineConfig" value="false" />
|
|
8
|
-
<option name="userId" value="-151e60b4:18eb353ec10:-7ffc" />
|
|
9
|
-
</MTProjectMetadataState>
|
|
10
|
-
</option>
|
|
11
|
-
</component>
|
|
12
|
-
</project>
|