ios_xliff_localizer 0.1.2 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc82ab9e8057981b41f2c2c8ea60cca0a60792e2
4
- data.tar.gz: 9203aca580a12ae91a8f8c648bc97568704406db
3
+ metadata.gz: 580fc46578f6523b45a0af2b5c33022fe453e793
4
+ data.tar.gz: 54b4d397f71b8c12d5ff91a8205b93b4631bed37
5
5
  SHA512:
6
- metadata.gz: 64f8b232d7605c6478ec1e215fa812e6a8d67cb5f785c67e6421038f7480a6530ebdb8e13e55686d6014e92c3b767fab34034a3b821a0cea1e47ee803e373fa3
7
- data.tar.gz: 99a2e5eb13ed00c1ad43bf498eca9f24480af868045984ec059e649b9e1f2c8adbca06732fce35471bde05c95354f84baaf69fd6847581b8a1e0b627b9877f59
6
+ metadata.gz: b28608c76ad8fcb2757a98a9756812980891235b97696eaf13b7d59a25becfdb8176caa1d2396f13f54f59b0639458ce5e09252075648cd57dbe1844b9abca10
7
+ data.tar.gz: d0587112768331ec0440ca190ae66c9599a0fcc3dbe9e3df9b06ac0246c439e4ed62dbf3a1f4523afebd47e6533a95fff29bcd8615dac0eca7c1216becdf83ef
@@ -1,13 +1,65 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
3
4
  require 'ios_xliff_localizer'
4
5
 
5
- if ARGV[0] == nil
6
- IOSXliffLocalizer::help
7
- return
6
+ Options = Struct.new(:analyze, :xliff, :dictionary, :key, :lang)
7
+
8
+ class Parser
9
+ def self.parse options = ["-h"]
10
+
11
+ args = Options.new()
12
+
13
+ opt_parser = OptionParser.new do |opts|
14
+ # IOSXliffLocalizer.version
15
+ opts.banner = "iOS xliff localizer v.#{IOSXliffLocalizer.version}\n\nFormat:\nios_xliff_localizer -x FILE_PATH.xliff -d DICTIONARY_FILE.csv -k DICTIONARY_KEY -l LANGUAGE \n\nUsage: \n For inspect your .csv file execute: ios_xliff_localizer -a csv_file\n For convert your file execute: ios_xliff_localizer -x xliff_file csv_file SOURCE_FIELD TARGET_FIELD\n\nExamples:\n You have file (dictionary.csv) with 5 fields: android, ios, en, ru, fr\n And you need convert ios into russian language. Your command will be:\n ios_xliff_localizer -a dictionary.csv ios ru\n\nAfter processing tool create xliff_file_name with postfix 'out' which you can import in your ios project in xCode\nFailed keys will write into special file. failed_keys_[TARGET_FIELD].cvs\n\n"
16
+
17
+ opts.on("-h", "--help", "Prints this help") do
18
+ puts opts
19
+
20
+ exit
21
+ end
22
+
23
+ opts.on("-a", "--analyze file.csv", "Path to file which need analyze") { |file| args.analyze = file }
24
+ opts.on("-d", "--dictionary file.csv", "dictionary.csv which you want to use") { |file| args.dictionary = file }
25
+
26
+ opts.on("-k", "--key KEY_NAME", "Key, which you want to use (ios or android or something else). You can use analyze function to get all avaliable keys.") { |key| args.key = key }
27
+ opts.on("-l", "--language LANGUAGE", "Language, which you want to use. Use analyse to get all avaliable languages.") { |lang| args.lang = lang }
28
+
29
+ #
30
+ opts.on("-v","--version", "Show current version") do
31
+ puts "v.#{IOSXliffLocalizer.version}"
32
+
33
+ exit
34
+ end
35
+ opts.on("-x", "--xliff file.xliff", "xliff-file which you want proccessing") { |file| args.xliff = file }
36
+ end
37
+
38
+ begin
39
+ opt_parser.parse! options
40
+ missing = []
41
+
42
+ missing.push 'analyze' if args.find { |e| e != nil } == nil
43
+
44
+ unless args[:analyze]
45
+ mandatory = [:xliff, :dictionary, :key, :lang]
46
+ missing = mandatory.select{ |param| args[param].nil? }
47
+ end
48
+
49
+ raise OptionParser::MissingArgument.new(missing.join(', ')) unless missing.empty?
50
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::InvalidOption.superclass
51
+ puts $!.to_s
52
+
53
+ exit
54
+ end
55
+ return args
56
+ end
8
57
  end
9
- if ARGV[1] == nil
10
- IOSXliffLocalizer::CSVEngine.analyse_csv ARGV[0]
58
+
59
+ options = Parser.parse ARGV.empty? ? %w[-h] : ARGV
60
+
61
+ unless options[:analyze] == nil
62
+ IOSXliffLocalizer.analyse_csv options[:analyze]
11
63
  else
12
- IOSXliffLocalizer::CSVEngine.convert ARGV[0], ARGV[1], ARGV[2], ARGV[3]
64
+ IOSXliffLocalizer.convert options[:xliff], options[:dictionary], options[:key], options[:lang]
13
65
  end
@@ -1,46 +1,13 @@
1
1
  require_relative 'ios_xliff_localizer/csv_engine.rb'
2
+ require_relative 'ios_xliff_localizer/version.rb'
2
3
 
3
4
  module IOSXliffLocalizer
4
5
 
5
- VERSION = "0.1.2"
6
-
7
- def self.help
8
- puts "ios_xliff_localizer v.#{VERSION}"
9
- puts "Localizer for ios application. Create xliff-file to import in your project with translate values from dictionary (csv)"
10
- puts "\n"
11
- puts "Warning! If xliff file don't have target language, it will convert into english target language."
12
- puts "\n"
13
- puts "Usage:"
14
- puts " For inspect your .csv file execute: \n ios_xliff_localizer csv_file\n\n"
15
- puts " For convert your file execute: \n ios_xliff_localizer xliff_file csv_file SOURCE_FIELD TARGET_FIELD"
16
- puts "\n"
17
- puts "Examples:"
18
- puts " You have file (dictionary.csv) with 5 fields: android, ios, en, ru, fr"
19
- puts " And you need convert ios into russian language\n\n"
20
- puts " Your command will be:"
21
- puts " ios_xliff_localizer xliff_file_name dictionary_file_name ios ru\n\n"
22
- puts " Description:"
23
- puts " ios_xliff_localizer - gem name"
24
- puts " xliff_file_name - path to your .xliff file"
25
- puts " dictionary_file_name - path to your .csv file"
26
- puts " ios - source field. Field in dictionary which tool will use to find in xliff file"
27
- puts " ru - target field. Field in dictionary which tool will use to set in xliff file"
28
- puts "\n"
29
- puts " After processing tool create xliff_file_name with postfix 'out'\n which you can import in your ios project in xCode"
30
- puts "\n"
31
- puts " Failed keys will write into special file. failed_keys_[TARGET_FIELD].cvs"
32
- end
33
-
34
6
  def self.analyse_csv path
35
7
  CSVEngine.analyse_csv path
36
8
  end
37
9
 
38
10
  def self.convert *args
39
- if args.count < 4
40
- puts "Not enought params!\n\n"
41
- IOSXliffLocalizer::help
42
- return
43
- end
44
11
  CSVEngine.convert args[0], args[1], args[2], args[3]
45
12
  end
46
13
  end
@@ -16,10 +16,8 @@ module IOSXliffLocalizer
16
16
 
17
17
  def self.convert *params
18
18
 
19
- if params.count != 4
20
- puts "Not enought params!"
21
- return
22
- end
19
+ puts params
20
+ return
23
21
 
24
22
  xliff_file = params[0]
25
23
  csv_file = params[1]
@@ -0,0 +1,20 @@
1
+ require 'singleton'
2
+
3
+ module IOSXliffLocalizer
4
+
5
+ class Version
6
+ include Singleton
7
+
8
+ MAJOR = '0'
9
+ MINOR = '2'
10
+ PATCH = '1'
11
+
12
+ def current_version
13
+ [MAJOR, MINOR, PATCH].join(".")
14
+ end
15
+ end
16
+
17
+ def self.version
18
+ Version.instance.current_version
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_xliff_localizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Torlopov
@@ -21,6 +21,7 @@ files:
21
21
  - bin/ios_xliff_localizer
22
22
  - lib/ios_xliff_localizer.rb
23
23
  - lib/ios_xliff_localizer/csv_engine.rb
24
+ - lib/ios_xliff_localizer/version.rb
24
25
  homepage: https://github.com/Torlopov-Andrey/ios_xliff_localizer.git
25
26
  licenses:
26
27
  - MIT
@@ -41,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
42
  version: '0'
42
43
  requirements: []
43
44
  rubyforge_project:
44
- rubygems_version: 2.6.8
45
+ rubygems_version: 2.6.12
45
46
  signing_key:
46
47
  specification_version: 4
47
48
  summary: Localizer for xCode projects. Localize .xliff by mapping xliff and cvs dictionary.