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 +4 -4
- data/bin/ios_xliff_localizer +58 -6
- data/lib/ios_xliff_localizer.rb +1 -34
- data/lib/ios_xliff_localizer/csv_engine.rb +2 -4
- data/lib/ios_xliff_localizer/version.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580fc46578f6523b45a0af2b5c33022fe453e793
|
4
|
+
data.tar.gz: 54b4d397f71b8c12d5ff91a8205b93b4631bed37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b28608c76ad8fcb2757a98a9756812980891235b97696eaf13b7d59a25becfdb8176caa1d2396f13f54f59b0639458ce5e09252075648cd57dbe1844b9abca10
|
7
|
+
data.tar.gz: d0587112768331ec0440ca190ae66c9599a0fcc3dbe9e3df9b06ac0246c439e4ed62dbf3a1f4523afebd47e6533a95fff29bcd8615dac0eca7c1216becdf83ef
|
data/bin/ios_xliff_localizer
CHANGED
@@ -1,13 +1,65 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'optparse'
|
3
4
|
require 'ios_xliff_localizer'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
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
|
64
|
+
IOSXliffLocalizer.convert options[:xliff], options[:dictionary], options[:key], options[:lang]
|
13
65
|
end
|
data/lib/ios_xliff_localizer.rb
CHANGED
@@ -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
|
@@ -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
|
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.
|
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.
|