pseudolocalization 0.4.0 → 0.5.0
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 +5 -5
- data/lib/pseudolocalization.rb +22 -16
- data/lib/pseudolocalization/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b97967a1646541cff93df46f1fa9c826d348842344516343cfd17d86d8464301
|
4
|
+
data.tar.gz: a2209f17067aabeda5373723c1c6aae95ea022476659c1d0e460e1d055c8f29b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a6d988688b696fcb97227f7b77e7c939a4e8c5b35c4376ca78fdf1796d565978d6f2d895aa7b9015a216fee10e5415ea786ae285237984cd2b262fb66f0bf05
|
7
|
+
data.tar.gz: 66e67baf24e25a98df6caa37fd3c0bc19d5cafdd800e1ae024a6309db1618d2d319c46d4e8aeae6bcbe279dac67882b5576ffd82cfc9445d4deed4cb6662c828
|
data/lib/pseudolocalization.rb
CHANGED
@@ -3,8 +3,16 @@ require "pseudolocalization/version"
|
|
3
3
|
module Pseudolocalization
|
4
4
|
module I18n
|
5
5
|
class Backend
|
6
|
-
|
7
|
-
|
6
|
+
ESCAPED_CHARS = [
|
7
|
+
['<', '>'],
|
8
|
+
['{{', '}}'],
|
9
|
+
]
|
10
|
+
|
11
|
+
ESCAPED_PATTERNS = ESCAPED_CHARS.map do |(a, b)|
|
12
|
+
"#{a}.*?#{b}"
|
13
|
+
end
|
14
|
+
|
15
|
+
ESCAPED_REGEX = Regexp.new("(#{ESCAPED_PATTERNS.join('|')})")
|
8
16
|
|
9
17
|
VOWELS = %w(a e i o u y A E I O U Y)
|
10
18
|
|
@@ -98,21 +106,19 @@ module Pseudolocalization
|
|
98
106
|
def translate_string(string)
|
99
107
|
string = string.gsub(/&[a-z]+;/, ' ')
|
100
108
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if char == BRACKET_START
|
105
|
-
outside_brackets = false
|
106
|
-
char
|
107
|
-
elsif char == BRACKET_END
|
108
|
-
outside_brackets = true
|
109
|
-
char
|
110
|
-
elsif outside_brackets && LETTERS.key?(char)
|
111
|
-
ret = LETTERS[char]
|
112
|
-
ret = ret * 2 if VOWELS.include?(char)
|
113
|
-
ret
|
109
|
+
string.split(ESCAPED_REGEX).map do |part|
|
110
|
+
if part =~ ESCAPED_REGEX
|
111
|
+
part
|
114
112
|
else
|
115
|
-
char
|
113
|
+
part.chars.map do |char|
|
114
|
+
if LETTERS.key?(char)
|
115
|
+
value = LETTERS[char]
|
116
|
+
value = value * 2 if VOWELS.include?(char)
|
117
|
+
value
|
118
|
+
else
|
119
|
+
char
|
120
|
+
end
|
121
|
+
end.join
|
116
122
|
end
|
117
123
|
end.join
|
118
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pseudolocalization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Blais
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.7.3
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Internationalization development tool
|