File tree Expand file tree Collapse file tree 3 files changed +33
-8
lines changed
Expand file tree Collapse file tree 3 files changed +33
-8
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,28 @@ The second change to National 2010 is that we try to restore soft signs and apos
7272
7373This feature is experimental and can be disabled by setting ` apostrophes ` to ` false ` .
7474
75+ #### Convenience mappings
76+ Another modification was to provide the following mappings:
77+
78+ * c → ц
79+ * q → щ
80+ * w → ш
81+ * x → х
82+
83+ Note that these mappings are phonetically inaccurate. However, using them still has a few advantages:
84+
85+ * Every letter of the Latin alphabet is covered
86+ * When the user types * ch* , we can map the first letter to * ц* , then replace it by * ч*
87+ * * w* has a similar shape to * ш*
88+ * * q* and * w* are located next to each other on the English keyboard, * щ* is therefore easy to find
89+ * * x* has the same shape as its Cyrillic counterpart
90+
7591### Credits
7692The rules and examples were adapted from the following libraries:
7793
7894* [ translit-english-ukrainian] ( https://github.com/MarkovSergii/translit-english-ukrainian )
7995* [ translit-ua] ( https://github.com/dchaplinsky/translit-ua )
96+ * [ translit.net] ( http://translit.net/ )
8097
8198## Licence
8299translit-scala is licensed under the terms of the Apache v2.0 licence.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ object Ukrainian extends Language {
1212 'g' -> 'ґ' ,
1313 'h' -> 'г' ,
1414 'i' -> 'і' ,
15+ 'j' -> 'й' ,
1516 'k' -> 'к' ,
1617 'l' -> 'л' ,
1718 'm' -> 'м' ,
@@ -24,8 +25,14 @@ object Ukrainian extends Language {
2425 'u' -> 'у' ,
2526 'v' -> 'в' ,
2627 'y' -> 'и' ,
27- 'j' -> 'й' ,
28- 'z' -> 'з'
28+ 'z' -> 'з' ,
29+
30+ // Mappings for more convenient typing. Allows us to cover every letter of
31+ // the Latin alphabet
32+ 'c' -> 'ц' ,
33+ 'q' -> 'щ' ,
34+ 'w' -> 'ш' ,
35+ 'x' -> 'х'
2936 )
3037
3138 val biGrams = Map (
@@ -117,10 +124,6 @@ object Ukrainian extends Language {
117124 val result = if (text(ofs - 2 ).isUpper) cyrillic.toUpper else cyrillic
118125
119126 (0 , result)
120- } else if ('c' == text(ofs - 1 ).toLower) {
121- // Replace Latin `c` to avoid confusion as its Cyrillic counterpart has a
122- // different byte code
123- (0 , 'ø' )
124127 } else {
125128 (0 , text(ofs - 1 ))
126129 }
Original file line number Diff line number Diff line change @@ -246,14 +246,14 @@ class UkrainianSpec extends FunSuite {
246246 }
247247
248248 test(" s vs c" ) {
249- assert(Ukrainian .latinToCyrillic(" vlacnym" ) == " влаøним " )
249+ assert(Ukrainian .latinToCyrillic(" vlacnym" ) == " влацним " )
250250 assert(Ukrainian .latinToCyrillic(" vlasnym" ) == " власним" )
251251 }
252252
253253 test(" Offsets" ) {
254254 assert(Ukrainian .latinToCyrillicOfs(" shch" , 0 ) == (0 , 'с' ))
255255 assert(Ukrainian .latinToCyrillicOfs(" shch" , 1 ) == (- 1 , 'ш' ))
256- assert(Ukrainian .latinToCyrillicOfs(" shch" , 2 ) == (0 , 'ø ' ))
256+ assert(Ukrainian .latinToCyrillicOfs(" shch" , 2 ) == (0 , 'ц ' ))
257257 assert(Ukrainian .latinToCyrillicOfs(" shch" , 3 ) == (- 2 , 'щ' ))
258258 assert(Ukrainian .latinToCyrillicOfs(" yeshch" , 5 ) == (- 2 , 'щ' ))
259259
@@ -273,4 +273,9 @@ class UkrainianSpec extends FunSuite {
273273
274274 assert(Ukrainian .latinToCyrillicOfs(" zgh" , 2 ) == (- 1 , 'г' ))
275275 }
276+
277+ test(" Convenience mappings" ) {
278+ assert(Ukrainian .latinToCyrillic(" Puzata Xata" ) == " Пузата Хата" )
279+ assert(Ukrainian .latinToCyrillic(" cqwx" ) == " цщшх" )
280+ }
276281}
You can’t perform that action at this time.
0 commit comments