missing_translation 0.4.2 → 0.4.3

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: dba71d70e2fdfd447e9970d93b7df7fb48c15d1ebc0786faa42485ffb69fd2cd
4
- data.tar.gz: 335d390b416fa5e6df1f69391d5c34a55740bef4f889705ff72083af2e4c6d9f
3
+ metadata.gz: 2e00668d1dfa29df132609998dc9c40870e98742ddf0668104e5e3c0bcb02cc7
4
+ data.tar.gz: cea48544560f29f23388bacfe985a5e05d087d016f51d0238b2fea567832acad
5
5
  SHA512:
6
- metadata.gz: 3e932a04547c8e79061f6c85f8931b886f912ba455155c706a6cce5bb292bb528587c326440f370388115bac9b0aebccd6f2013faca13a5a7229706e35276d4d
7
- data.tar.gz: d02468ccc06101f8a3259e7f253283e80b30612abc1f3604b9fa77a39b14c90295d4250d603ba71e383cfb0d51523b3c94a511924036f644d00f57c1060a4d7f
6
+ metadata.gz: 467063d7284b642f397d4538c50f543279441df730543e84991fb3de958b06158228a0c29e0d4af005861be510087704ad58886d4903ec4a19475d2d939c57fc
7
+ data.tar.gz: ebbe9512404ff7fd103fa07fb3b9f2c5853eacfef39f331c3c9e2fddf133781734b152b921571ad48c3473b24f974908ba8d10a5e67f3dd8724324e7ed9a269e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- missing_translation (0.4.2)
4
+ missing_translation (0.4.3)
5
5
  httparty (~> 0.18)
6
6
  thor (~> 1.1)
7
7
 
@@ -20,7 +20,9 @@ module MissingTranslation
20
20
  end
21
21
 
22
22
  desc "upload", 'Upload file in locale folder to missing translation'
23
+ method_option :locale, type: :string, default: nil, desc: "Locale to download"
23
24
  def upload
25
+ locale = options[:locale]
24
26
  file_extension = ""
25
27
  config_folder = "./config/locales/#{file_extension}/*.yml"
26
28
  file_pathnames = Dir[config_folder]
@@ -29,13 +31,17 @@ module MissingTranslation
29
31
  configuration = Configuration.new
30
32
  api = MissingTranslationApi.new(configuration.config[:key])
31
33
  file_pathnames.each do |pathname|
34
+ next if locale.present? && !pathname.include?("#{locale}.yml")
35
+ p "Uploading #{pathname}"
32
36
  file = MissingTranslation::TranslationFile.new(pathname)
33
37
  api.upload(file.language, file.group, file.to_json, "yaml")
34
38
  end
35
39
  end
36
40
 
37
41
  desc "download", "Download all file from missing translation"
42
+ method_option :locale, type: :string, default: nil, desc: "Locale to download"
38
43
  def download
44
+ locale = options[:locale]
39
45
  MissingTranslation::Cli.new().sort
40
46
  return if MissingTranslation::Util.uncommitted_changes?
41
47
 
@@ -45,6 +51,7 @@ module MissingTranslation
45
51
  response = api.download("yaml")
46
52
  response.each do |f|
47
53
  file = MissingTranslation::TranslationFile.new
54
+ file.locale_prefix = configuration.config[:locale_prefix] || false
48
55
  file.group = f["group"]
49
56
  file.language = f["language"]
50
57
  file.translations = f["keys"]
@@ -42,11 +42,15 @@ module MissingTranslation
42
42
 
43
43
  def write(directory)
44
44
  return nil unless translations
45
+
45
46
  filename = [group, language, "yml"].compact.reject{|s| s.size <= 0}.join('.')
46
47
  filepath = "#{directory}/#{filename}"
47
48
  p "Writing file #{filepath}..."
48
-
49
- File.write(filepath, translations.to_yaml)
49
+ if locale_prefix && translations.keys.length >= 1 && translations.keys.first != language
50
+ File.write(filepath, {language => translations}.to_yaml)
51
+ else
52
+ File.write(filepath, translations.to_yaml)
53
+ end
50
54
  MissingTranslation::Util.sort_file(filepath)
51
55
  end
52
56
 
@@ -6,14 +6,9 @@ module MissingTranslation
6
6
 
7
7
  def self.uncommitted_changes?
8
8
  status = `git status --porcelain`
9
- return false if $CHILD_STATUS.success? && status.empty?
10
-
11
- error = if $CHILD_STATUS.success?
12
- "You have uncommitted code. Please commit or stash your changes before continuing"
13
- else
14
- "You do not have Git installed. Please install Git, and commit your changes before continuing"
15
- end
16
- p error
9
+ return false if status.empty?
10
+
11
+ puts "You have uncommitted code. Please commit or stash your changes before continuing"
17
12
  true
18
13
  end
19
14
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MissingTranslation
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: missing_translation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Clercin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor