phrase 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/phrase/api/client.rb +6 -2
- data/lib/phrase/tool.rb +1 -0
- data/lib/phrase/tool/commands/push.rb +15 -1
- data/lib/phrase/tool/encoding_detector.rb +15 -0
- data/lib/phrase/version.rb +1 -1
- metadata +21 -20
data/README.md
CHANGED
data/lib/phrase/api/client.rb
CHANGED
@@ -203,9 +203,9 @@ private
|
|
203
203
|
def set_form_data(request, params, separator='&')
|
204
204
|
request.body = params.map do |key, value|
|
205
205
|
if value.instance_of?(Array)
|
206
|
-
value.map {|value_item| "#{
|
206
|
+
value.map {|value_item| "#{escaped(key.to_s)}=#{escaped(value_item.to_s)}"}.join(separator)
|
207
207
|
else
|
208
|
-
"#{
|
208
|
+
"#{escaped(key.to_s)}=#{escaped(value.to_s)}"
|
209
209
|
end
|
210
210
|
end.join(separator)
|
211
211
|
request.content_type = 'application/x-www-form-urlencoded'
|
@@ -214,4 +214,8 @@ private
|
|
214
214
|
def parsed(raw_data)
|
215
215
|
JSON.parse(raw_data)
|
216
216
|
end
|
217
|
+
|
218
|
+
def escaped(value)
|
219
|
+
CGI::escape(value)
|
220
|
+
end
|
217
221
|
end
|
data/lib/phrase/tool.rb
CHANGED
@@ -10,6 +10,7 @@ class Phrase::Tool
|
|
10
10
|
autoload :Formats, 'phrase/tool/formats'
|
11
11
|
autoload :Commands, 'phrase/tool/commands'
|
12
12
|
autoload :TagValidator, 'phrase/tool/tag_validator'
|
13
|
+
autoload :EncodingDetector, 'phrase/tool/encoding_detector'
|
13
14
|
autoload :Locale, 'phrase/tool/locale'
|
14
15
|
|
15
16
|
def initialize(argv)
|
@@ -78,7 +78,7 @@ private
|
|
78
78
|
tagged = " (tagged: #{@tags.join(", ")})" if @tags.size > 0
|
79
79
|
print_message "Uploading #{file}#{tagged}..."
|
80
80
|
locale = @locale || detect_locale_name_from_file_path(file)
|
81
|
-
api_client.upload(file,
|
81
|
+
api_client.upload(file, file_content(file), @tags, locale)
|
82
82
|
print_message "OK".green
|
83
83
|
rescue Exception => e
|
84
84
|
print_error "Failed"
|
@@ -87,6 +87,20 @@ private
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
def file_content(file)
|
91
|
+
content = File.open(file).read
|
92
|
+
content = utf16_to_utf8(content) if file_seems_to_be_utf16?(file)
|
93
|
+
content
|
94
|
+
end
|
95
|
+
|
96
|
+
def utf16_to_utf8(string)
|
97
|
+
string.encode("UTF-8", "UTF-16")
|
98
|
+
end
|
99
|
+
|
100
|
+
def file_seems_to_be_utf16?(file)
|
101
|
+
Phrase::Tool::EncodingDetector.file_seems_to_be_utf16?(file)
|
102
|
+
end
|
103
|
+
|
90
104
|
def file_valid?(filepath)
|
91
105
|
extension = filepath.split('.').last
|
92
106
|
ALLOWED_FILE_TYPES.include?(extension)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
class Phrase::Tool::EncodingDetector
|
4
|
+
def self.file_seems_to_be_utf16?(file)
|
5
|
+
file_seems_to_be_utf16_be?(file) or file_seems_to_be_utf16_le?(file)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.file_seems_to_be_utf16_be?(file)
|
9
|
+
IO.read(file, 2).bytes.to_a == [0xFE, 0xFF]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.file_seems_to_be_utf16_le?(file)
|
13
|
+
IO.read(file, 2).bytes.to_a == [0xFF, 0xFE]
|
14
|
+
end
|
15
|
+
end
|
data/lib/phrase/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phrase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70346162428660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70346162428660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: addressable
|
27
|
-
requirement: &
|
27
|
+
requirement: &70346162428200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.2.8
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70346162428200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: colorize
|
38
|
-
requirement: &
|
38
|
+
requirement: &70346162427820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70346162427820
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: json
|
49
|
-
requirement: &
|
49
|
+
requirement: &70346162427360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70346162427360
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70346162426940 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70346162426940
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: i18n
|
71
|
-
requirement: &
|
71
|
+
requirement: &70346162426520 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70346162426520
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: webmock
|
82
|
-
requirement: &
|
82
|
+
requirement: &70346162426100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70346162426100
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: vcr
|
93
|
-
requirement: &
|
93
|
+
requirement: &70346162425680 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70346162425680
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: timecop
|
104
|
-
requirement: &
|
104
|
+
requirement: &70346162425260 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70346162425260
|
113
113
|
description: phrase allows you to edit translations in-place on the page itself. More
|
114
114
|
information at phraseapp.com
|
115
115
|
email:
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/phrase/tool/commands/show_help.rb
|
150
150
|
- lib/phrase/tool/commands/show_version.rb
|
151
151
|
- lib/phrase/tool/config.rb
|
152
|
+
- lib/phrase/tool/encoding_detector.rb
|
152
153
|
- lib/phrase/tool/formats.rb
|
153
154
|
- lib/phrase/tool/formats/base.rb
|
154
155
|
- lib/phrase/tool/formats/gettext.rb
|