i18n-cli 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 492de4c62d7f8086ea5c757c5e6bca0573d87d76c8f5c192c65571e7476a9e87
4
- data.tar.gz: 8c76f2b04d4008390e61ed1822dec6b99b7af6786e5e1e49c364ae0783835c98
3
+ metadata.gz: 3a4db81c1979060bfd755699771db45916dab306dfd45b969988b54949f0e0ab
4
+ data.tar.gz: 1f4b3d4f0470ccba81fc394a27688940f3e3869283c32c99a485afba08f62676
5
5
  SHA512:
6
- metadata.gz: 29b266f09542aff6a34fa6d45eb9d1bbf8d53d6d397e3277a5027dc9c652838173db0f932806b35151f868f2f1e43dc89b1aedba140275306cdfc4c90a002e2e
7
- data.tar.gz: 537d650df6a5c8e4d13a36a46e06138ab6a2d7d1b6c8b3075437047165eb0ab695532081a8a134f86627c23012ba9bdaf1d84d72ae65f8511acf6060bbaad9a4
6
+ metadata.gz: cc5f7260d3690fcfd4def06a24d1e04029b5cf1ec7a6561140f2f234570133b0578fb0854f7b8625137165bc57135dfe6f584b3f1e657cb50c1594ba012336de
7
+ data.tar.gz: 566179d7147d4119d13d357a8a25c0a6e7c297c32707fdca479faa4dabd10c30b379134e96fb036c8eeef69b1bd01b4ea6f00e57f9f37a2e4933f9246684d8e2
@@ -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
- version: "0.1"
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,12 +84,42 @@ module I18n
81
84
  metadata: {
82
85
  cliVersion: VERSION,
83
86
  projectName: localization_lock_hash['metadata']['projectName'],
84
- version: "#{version_split[0]}.#{version_split[1].to_i + 1}"
87
+ buildFolder: localization_lock_hash['metadata']['buildFolder'],
88
+ version: "#{version_split[0]}.#{version_split[1].to_i + 1}",
85
89
  }
86
90
  }
87
91
 
88
92
  file_content = JSON.pretty_generate(new_localization_lock_hash)
89
93
  File.write(LOCALIZATION_LOCK_FILE, file_content)
94
+
95
+ apply
96
+ end
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
90
123
  end
91
124
 
92
125
  def help
@@ -95,6 +128,7 @@ Commands:
95
128
  - init \t [project-name] [language-1] [language-2] ... [language-n]
96
129
  - apply \t Create localization.json file to edit localizations
97
130
  - commit \t Update .localization.lock with the localization.json updates
131
+ - build \t generate each language localization file
98
132
  )
99
133
  end
100
134
  end
@@ -1,3 +1,3 @@
1
1
  module I18n
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.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: 2023-12-18 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler