dalibor / cyrillizer Goto Github PK
View Code? Open in Web Editor NEWCharacter conversion from latin to cyrillic and vice versa
Character conversion from latin to cyrillic and vice versa
"J".to_cyr have to be "Дж"
but now it is "J"
Error translating combination "ля" in word "для". Now: "dlя", expected: "dlya"
The gem throws stack level too deep error from time to time.
ActionView::Template::Error (stack level too deep):
cyrillizer (0.1.0) lib/cyrillizer/converter.rb:27
I am using it here:
class String
def parameterize_string
self.to_lat.parameterize
end
end
When someone does not want to use YAML alphabet provided by the gem. Or, when someone wants to use their own alphabet for conversion.
Я я Ч ч Щ щ Ш ш ь Ь ъ Ъ Ю ю are missing
I think you should sort the hash over the length:
def to_cyr
a=alphabet.invert.sort_by{ |k,v| k.length }.reverse.to_h
code(self.dup,a)
end
Currently it happens that for instance nj
get translaterated as нј
instead of њ
becausej
comes before it in the alphabet hash and it gets replaced by the same looking but different character, such as this:
from = "j"
bytes = Array (1 element)
[0] = 106
to = "ј"
bytes = Array (2 elements)
[0] = 209
[1] = 152
after which gsub('nj'..)
doesn't produce anything.
Sorting the array differently gets rid of this problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.