Documentation
¶
Overview ¶
Package translit provides transliteration transformer. See subpackages for language-specific transformers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface { // Transformer returns/builds a "fresh" transliteration transformer. Transformer() transform.Transformer }
Factory represents pre-compiled tree builder/factory.
func Map ¶
Map pre-compiles string-to-string transliteration rule map into transformer factory.
Example ¶
package main import ( "fmt" "github.com/mxmCherry/translit" "golang.org/x/text/transform" ) func main() { // pre-compile a transformer factory from rule map; // this is recommended to be a global variable in your own package: custom := translit.Map( map[string]string{ "л": "l", "Л": "L", "ля": "lya", "Ля": "Lya", }, ) // get a "fresh" transformer (can be done for each transliteration instead of tr.Reset()): tr := custom.Transformer() var s string tr.Reset() // reset transformer state before usage - it is stateful and non-thread-safe s, _, _ = transform.String(tr, "Л - л") fmt.Println(s) // L - l tr.Reset() // reset transformer state before usage - it is stateful and non-thread-safe s, _, _ = transform.String(tr, "Ля-лЯ-ля") fmt.Println(s) // Lya-lЯ-lya - no rule for upper-case "Я", so it's not converted }
Output: L - l Lya-lЯ-lya
Directories
¶
Path | Synopsis |
---|---|
internal
|
|
transformer
Package transformer implements a transliteration golang.org/x/text/transform.Transformer.
|
Package transformer implements a transliteration golang.org/x/text/transform.Transformer. |
tree
Package tree defines a byte-to-byte-slice tree and implements some basic operations for it.
|
Package tree defines a byte-to-byte-slice tree and implements some basic operations for it. |
tree/maptree
Package maptree provides a tree implementation with map-based children lookup.
|
Package maptree provides a tree implementation with map-based children lookup. |
Package ruicao provides Russian romanization transliterator, as defined in ICAO standard.
|
Package ruicao provides Russian romanization transliterator, as defined in ICAO standard. |
Package uknational provides Ukrainian romanization transliterator, as defined in http://zakon.rada.gov.ua/laws/show/55-2010-%D0%BF
|
Package uknational provides Ukrainian romanization transliterator, as defined in http://zakon.rada.gov.ua/laws/show/55-2010-%D0%BF |
Click to show internal directories.
Click to hide internal directories.