missing_translation 0.4.1 → 0.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0d7abeda779628c842a69fbddd073eaa39e2fc2b3a82f51c96679d20deedbd0
4
- data.tar.gz: 0deb15104834f00d0bc5e84679ae862a1dcc554b8975ab3d350d9459321cc541
3
+ metadata.gz: 2e00668d1dfa29df132609998dc9c40870e98742ddf0668104e5e3c0bcb02cc7
4
+ data.tar.gz: cea48544560f29f23388bacfe985a5e05d087d016f51d0238b2fea567832acad
5
5
  SHA512:
6
- metadata.gz: 144e61987c30565c1e902fcb06c1de9012bc31894608676999f3681ded6f427599cba102b6b861a664aac237767adbf42ff776b2a775304eeb528483889fb58d
7
- data.tar.gz: acdea8167618117706a904f4c123e47908e5e679828d70889781faa29b26768d155d64f3f7541a74a9611084357650b08addaec9c77d68aa0ce96aad07dfd903
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.1)
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.1"
4
+ VERSION = "0.4.3"
5
5
  end
@@ -20,6 +20,7 @@ class MissingTranslationApi
20
20
  end
21
21
 
22
22
  def upload(language, group, keys, content_type = "yaml")
23
+ p "Pushing #{keys.count} keys on #{group} for #{language}"
23
24
  self.class.post("/translations/import", @options.merge({
24
25
  body: {
25
26
  content_type: content_type,
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.1
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