Interscript can be used as a Ruby Gem library to be integrated with other Ruby applications.
You need to make sure your Gemfile contains the following lines:
source "https://rubygems.org"
gem "interscript", "~>2.0"In your codebase, if you don’t do Bundler.require, you will need to add the
following line:
require "interscript"To list all available maps, one must execute the following code:
maps = Interscript.mapsmaps will be an array containing all Interscript maps by their name.
To transliterate test using a given map, like bas-rus-Cyrl-Latn-2017-bss,
one must execute:
cache = {}
input = "Хелло"
output = Interscript.transliterate("bas-rus-Cyrl-Latn-2017-bss",
input,
cache)You should preserve the cache variable for performance reasons. It is optional,
you don’t need to (but should) supply it.
If performance is of utmost performance for your application and you want to
sacrifice a little bit of loading time for much better performance, you can use
Interscript::Compiler::Ruby instead of Interscript::Interpreter (which is
used by default).
require "interscript/compiler/ruby"
cache = {}
input = "Хелло"
output = Interscript.transliterate("bas-rus-Cyrl-Latn-2017-bss",
input,
cache,
compiler: Interscript::Compiler::Ruby)