srbovanje 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8585bfc72a559e745f7462a5013b39a895ff3706
4
- data.tar.gz: 5635dad2e00b862cee73aae52dafc5646983a7ba
2
+ SHA256:
3
+ metadata.gz: 9351fb2b851d7e159a9a63bfd5aaff6919cc2f7053611f3b5e3aeb10534d19b0
4
+ data.tar.gz: 796729f730d2fb9b8543ef41daa19c847671a5eef9932b430e68648a4d285388
5
5
  SHA512:
6
- metadata.gz: 42f900a613b43bdab1b67906fbb2f70a238376619aa4576502e8369a530611599c9633953cb4461b431fce3b07d9391065d4abfcfac26603875b78d4411c3fbd
7
- data.tar.gz: a9cd31e141d928ec2a1d5e3680b8ec0442e861d001345ad277054c93e072a9049d44daad057c1c081c5cafaec47e608f194a13dbade7b65571652f8be971ae85
6
+ metadata.gz: a3e19ef6cd872795828934f031c82e008d8a63082b665541b7c45c566221f048272e0ff87c5e44452e78b189d6a53e887ebfdca2642ea278e7b8e9b9baef160c
7
+ data.tar.gz: 53381427a41bec21bf586c3c3054e93df5fb3fc58ffaae5b5f4ff9251d5ded2949a81aabe807d4aa2bad046dd5b45dadced21804d0824638884819a746ccff80
data/README.md CHANGED
@@ -16,7 +16,7 @@ U Gemfile projekta dodajte:
16
16
  >> "Ђурђевак".latinicom
17
17
  => "Đurđevak"
18
18
 
19
- >> "Ђурђевак".latinicom :ascii
19
+ >> "Ђурђевак".latinicom_ascii
20
20
  => "DJurdjevak"
21
21
 
22
22
  Ako zatreba, tu je i niz sa slovima abecede:
@@ -25,25 +25,29 @@ Ako zatreba, tu je i niz sa slovima abecede:
25
25
  => ["A", "B", "C", "Č", "Ć", "D", "DŽ", "Đ", "E", "F", "G", "H", "I", "J", "K", "L", "LJ", "M", "N", "NJ", "O", "P", "R", "S", "Š", "T", "U", "V", "Z", "Ž"]
26
26
 
27
27
 
28
- Ako koristite Srbovanje uz Rails dobićete setovana pravila za preslovnjavanja
28
+ Ako koristite Srbovanje uz Rails dobićete setovana pravila za preslovljavanja
29
29
  koje koristi i18n gem, tako da će npr. parameterize raditi pravilnije:
30
30
 
31
31
  ## bez Srbovanja
32
32
 
33
33
  >> "Karađorđeva šnicla".parameterize
34
34
  => "karadordeva-snicla"
35
-
35
+
36
36
  >> "Шабан Шаулић".parameterize
37
37
  => ""
38
38
 
39
39
  ## uz Srbovanje
40
-
40
+
41
41
  >> "Karađorđeva šnicla".parameterize
42
42
  => "karadjordjeva-snicla"
43
43
 
44
44
  >> "Шабан Шаулић".parameterize
45
45
  => "saban-saulic"
46
46
 
47
+ ## Slični projekti
48
+
49
+ * [Byk](https://github.com/topalovic/byk) - zavidno brža varijanta zahvaljujući C ekstenziji
50
+ * [preslovi](https://github.com/dejan/preslovi) - go paket i šel komanda
47
51
 
48
52
  ## MIT Licence
49
53
 
@@ -1 +1 @@
1
- I18n.backend.store_translations(:sr, :i18n => {:transliterate => {:rule => Srbovanje::latinica_map(:ascii) }})
1
+ I18n.backend.store_translations(:sr, :i18n => {:transliterate => {:rule => Srbovanje::LATINICA_ASCII_MAP }})
@@ -2,102 +2,110 @@
2
2
 
3
3
  module Srbovanje
4
4
 
5
- def abeceda
6
- %w(A B C Č Ć D DŽ Đ E F G H I J K L LJ M N NJ O P R S Š T U V Z Ž)
7
- end
5
+ ABECEDA = %w(A B C Č Ć D DŽ Đ E F G H I J K L LJ M N NJ O P R S Š T U V Z Ž)
6
+
7
+ LATINICA_FULL_MAP = {
8
+ 'а' => 'a',
9
+ 'А' => 'A',
10
+ 'б' => 'b',
11
+ 'Б' => 'B',
12
+ 'в' => 'v',
13
+ 'В' => 'V',
14
+ 'г' => 'g',
15
+ 'Г' => 'G',
16
+ 'д' => 'd',
17
+ 'Д' => 'D',
18
+ 'ђ' => 'đ',
19
+ 'Ђ' => 'Đ',
20
+ 'е' => 'e',
21
+ 'Е' => 'E',
22
+ 'ж' => 'ž',
23
+ 'Ж' => 'Ž',
24
+ 'з' => 'z',
25
+ 'З' => 'Z',
26
+ 'и' => 'i',
27
+ 'И' => 'I',
28
+ 'ј' => 'j',
29
+ 'Ј' => 'J',
30
+ 'к' => 'k',
31
+ 'К' => 'K',
32
+ 'л' => 'l',
33
+ 'Л' => 'L',
34
+ 'љ' => 'lj',
35
+ 'Љ' => 'LJ',
36
+ 'м' => 'm',
37
+ 'М' => 'M',
38
+ 'н' => 'n',
39
+ 'Н' => 'N',
40
+ 'њ' => 'nj',
41
+ 'Њ' => 'NJ',
42
+ 'о' => 'o',
43
+ 'О' => 'O',
44
+ 'п' => 'p',
45
+ 'П' => 'P',
46
+ 'р' => 'r',
47
+ 'Р' => 'R',
48
+ 'с' => 's',
49
+ 'С' => 'S',
50
+ 'т' => 't',
51
+ 'Т' => 'T',
52
+ 'ћ' => 'ć',
53
+ 'Ћ' => 'Ć',
54
+ 'ц' => 'c',
55
+ 'Ц' => 'C',
56
+ 'у' => 'u',
57
+ 'У' => 'U',
58
+ 'ф' => 'f',
59
+ 'Ф' => 'F',
60
+ 'х' => 'h',
61
+ 'Х' => 'H',
62
+ 'ч' => 'č',
63
+ 'Ч' => 'Č',
64
+ 'џ' => 'dž',
65
+ 'Џ' => 'DŽ',
66
+ 'ш' => 'š',
67
+ 'Ш' => 'Š'
68
+ }
69
+
70
+ LATINICA_ASCII_MAP = LATINICA_FULL_MAP.merge(
71
+ 'ћ' => 'c',
72
+ 'ć' => 'c',
73
+ 'ч' => 'c',
74
+ 'č' => 'c',
75
+ 'Ћ' => 'C',
76
+ 'Ć' => 'C',
77
+ 'Ч' => 'C',
78
+ 'Č' => 'C',
79
+ 'ж' => 'z',
80
+ 'ž' => 'z',
81
+ 'Ж' => 'Z',
82
+ 'Ž' => 'Z',
83
+ 'š' => 's',
84
+ 'ш' => 's',
85
+ 'Ш' => 'S',
86
+ 'Š' => 'S',
87
+ 'đ' => 'dj',
88
+ 'ђ' => 'dj',
89
+ 'Ђ' => 'DJ',
90
+ 'Đ' => 'DJ',
91
+ 'џ' => 'dz',
92
+ 'Џ' => 'DZ'
93
+ )
8
94
 
9
- def latinica_map(charset)
10
- charset.to_s == 'ascii' ? latinica_ascii_map : latinica_full_map
95
+ LATINICOM_REGEXP = Regexp.union(LATINICA_FULL_MAP.keys)
96
+
97
+ LATINICA_ASCII_REGEXP = Regexp.union(LATINICA_ASCII_MAP.keys)
98
+
99
+ def latinicom(text)
100
+ text.gsub(LATINICOM_REGEXP, LATINICA_FULL_MAP)
11
101
  end
12
102
 
13
- def latinica_full_map
14
- @@latinica_map ||= {
15
- 'а' => 'a',
16
- 'А' => 'A',
17
- 'б' => 'b',
18
- 'Б' => 'B',
19
- 'в' => 'v',
20
- 'В' => 'V',
21
- 'г' => 'g',
22
- 'Г' => 'G',
23
- 'д' => 'd',
24
- 'Д' => 'D',
25
- 'ђ' => 'đ',
26
- 'Ђ' => 'Đ',
27
- 'е' => 'e',
28
- 'Е' => 'E',
29
- 'ж' => 'ž',
30
- 'Ж' => 'Ž',
31
- 'з' => 'z',
32
- 'З' => 'Z',
33
- 'и' => 'i',
34
- 'И' => 'I',
35
- 'ј' => 'j',
36
- 'Ј' => 'J',
37
- 'к' => 'k',
38
- 'К' => 'K',
39
- 'л' => 'l',
40
- 'Л' => 'L',
41
- 'љ' => 'lj',
42
- 'Љ' => 'LJ',
43
- 'м' => 'm',
44
- 'М' => 'M',
45
- 'н' => 'n',
46
- 'Н' => 'N',
47
- 'њ' => 'nj',
48
- 'Њ' => 'NJ',
49
- 'о' => 'o',
50
- 'О' => 'O',
51
- 'п' => 'p',
52
- 'П' => 'P',
53
- 'р' => 'r',
54
- 'Р' => 'R',
55
- 'с' => 's',
56
- 'С' => 'S',
57
- 'т' => 't',
58
- 'Т' => 'T',
59
- 'ћ' => 'ć',
60
- 'Ћ' => 'Ć',
61
- 'ц' => 'c',
62
- 'Ц' => 'C',
63
- 'у' => 'u',
64
- 'У' => 'U',
65
- 'ф' => 'f',
66
- 'Ф' => 'F',
67
- 'х' => 'h',
68
- 'Х' => 'H',
69
- 'ч' => 'č',
70
- 'Ч' => 'Č',
71
- 'џ' => 'dž',
72
- 'Џ' => 'DŽ',
73
- 'ш' => 'š',
74
- 'Ш' => 'Š' }
103
+ def latinicom_ascii(text)
104
+ text.gsub(LATINICA_ASCII_REGEXP, LATINICA_ASCII_MAP)
75
105
  end
76
106
 
77
- def latinica_ascii_map
78
- @@latinica_ascii_map ||= latinica_full_map.merge(
79
- 'ћ' => 'c',
80
- 'ć' => 'c',
81
- 'ч' => 'c',
82
- 'č' => 'c',
83
- 'Ћ' => 'C',
84
- 'Ć' => 'C',
85
- 'Ч' => 'C',
86
- 'Č' => 'C',
87
- 'ж' => 'z',
88
- 'ž' => 'z',
89
- 'Ж' => 'Z',
90
- 'Ž' => 'Z',
91
- 'š' => 's',
92
- 'ш' => 's',
93
- 'Ш' => 'S',
94
- 'Š' => 'S',
95
- 'đ' => 'dj',
96
- 'ђ' => 'dj',
97
- 'Ђ' => 'DJ',
98
- 'Đ' => 'DJ',
99
- 'џ' => 'dz',
100
- 'Џ' => 'DZ')
107
+ def abeceda
108
+ ABECEDA
101
109
  end
102
110
 
103
111
  extend self
@@ -3,13 +3,13 @@
3
3
  String.class_eval do
4
4
 
5
5
  # Preslovljava na latinicu
6
- # Params:
7
- # +charset+:: ako je :ascii preslovljava u "ošišanu" latinicu.
8
- def latinicom(charset=:utf8)
9
- mapping = Srbovanje.latinica_map(charset)
10
- self.gsub(/.+?/) do |chr|
11
- mapping[chr] || chr
12
- end
6
+ def latinicom
7
+ Srbovanje.latinicom(self)
8
+ end
9
+
10
+ # Preslovljava na ASCII ("ošišanu") latinicu
11
+ def latinicom_ascii
12
+ Srbovanje.latinicom_ascii(self)
13
13
  end
14
14
 
15
15
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srbovanje
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2020-08-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: '"Ђурђевак".latinicom #=> "Đurđevak"'
13
+ description: Transliteracija ćirilice na latinicu i tzv. ASCII latinicu.
14
14
  email: desimic@gmail.com
15
15
  executables: []
16
16
  extensions: []
@@ -42,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.2.2
45
+ rubygems_version: 3.1.2
47
46
  signing_key:
48
47
  specification_version: 4
49
48
  summary: Transliteracija ćirilice na latinicu i tzv. ASCII latinicu.