i18n-cli 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n-cli/i18n-cli.rb +35 -3
- data/lib/i18n-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a4db81c1979060bfd755699771db45916dab306dfd45b969988b54949f0e0ab
|
4
|
+
data.tar.gz: 1f4b3d4f0470ccba81fc394a27688940f3e3869283c32c99a485afba08f62676
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc5f7260d3690fcfd4def06a24d1e04029b5cf1ec7a6561140f2f234570133b0578fb0854f7b8625137165bc57135dfe6f584b3f1e657cb50c1594ba012336de
|
7
|
+
data.tar.gz: 566179d7147d4119d13d357a8a25c0a6e7c297c32707fdca479faa4dabd10c30b379134e96fb036c8eeef69b1bd01b4ea6f00e57f9f37a2e4933f9246684d8e2
|
data/lib/i18n-cli/i18n-cli.rb
CHANGED
@@ -18,6 +18,8 @@ module I18n
|
|
18
18
|
apply
|
19
19
|
when 'commit'
|
20
20
|
commit
|
21
|
+
when 'build'
|
22
|
+
build
|
21
23
|
else
|
22
24
|
help
|
23
25
|
end
|
@@ -32,7 +34,8 @@ module I18n
|
|
32
34
|
metadata: {
|
33
35
|
cliVersion: VERSION,
|
34
36
|
projectName: project_name,
|
35
|
-
|
37
|
+
buildFolder: './',
|
38
|
+
version: '0.1',
|
36
39
|
}
|
37
40
|
}
|
38
41
|
|
@@ -51,7 +54,7 @@ module I18n
|
|
51
54
|
|
52
55
|
localization_hash = {
|
53
56
|
strings: keys_hash,
|
54
|
-
version: localization_lock_hash['metadata']['version']
|
57
|
+
version: localization_lock_hash['metadata']['version'],
|
55
58
|
}
|
56
59
|
|
57
60
|
file_content = JSON.pretty_generate(localization_hash)
|
@@ -81,7 +84,8 @@ module I18n
|
|
81
84
|
metadata: {
|
82
85
|
cliVersion: VERSION,
|
83
86
|
projectName: localization_lock_hash['metadata']['projectName'],
|
84
|
-
|
87
|
+
buildFolder: localization_lock_hash['metadata']['buildFolder'],
|
88
|
+
version: "#{version_split[0]}.#{version_split[1].to_i + 1}",
|
85
89
|
}
|
86
90
|
}
|
87
91
|
|
@@ -91,12 +95,40 @@ module I18n
|
|
91
95
|
apply
|
92
96
|
end
|
93
97
|
|
98
|
+
def build
|
99
|
+
localization_lock_hash = JSON.parse(File.open(LOCALIZATION_LOCK_FILE, &:read))
|
100
|
+
|
101
|
+
build_folder = localization_lock_hash['metadata']['buildFolder']
|
102
|
+
|
103
|
+
if !File.directory?(build_folder)
|
104
|
+
puts "Build folder '#{build_folder}' doesn't exists"
|
105
|
+
return
|
106
|
+
end
|
107
|
+
|
108
|
+
FileUtils.rm_f(Dir.glob("#{build_folder}/*"))
|
109
|
+
|
110
|
+
version = localization_lock_hash['metadata']['version']
|
111
|
+
all_languages = localization_lock_hash['data'].keys
|
112
|
+
|
113
|
+
localization_lock_hash['data'].each do |language_name, language_data|
|
114
|
+
file_path = File.join(build_folder, "#{language_name}.json")
|
115
|
+
file_content = {
|
116
|
+
strings: language_data,
|
117
|
+
allLanguages: all_languages,
|
118
|
+
version: version,
|
119
|
+
}
|
120
|
+
|
121
|
+
File.open(file_path, 'w') {|f| f.write(JSON.pretty_generate(file_content))}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
94
125
|
def help
|
95
126
|
puts %(
|
96
127
|
Commands:
|
97
128
|
- init \t [project-name] [language-1] [language-2] ... [language-n]
|
98
129
|
- apply \t Create localization.json file to edit localizations
|
99
130
|
- commit \t Update .localization.lock with the localization.json updates
|
131
|
+
- build \t generate each language localization file
|
100
132
|
)
|
101
133
|
end
|
102
134
|
end
|
data/lib/i18n-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Prestes Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|