@sarmay/converter

1.0.1 • Public • Published

@Sarmay/converter

English | 简体中文

This is a tool for converting between Kazakh Arabic, Cyrillic and Latin.

The following functions are temporarily realized: Arabic to Cyrillic, Cyrillic to Arabic, Arabic to Latin, Latin to Cyrillic

npm version Build Status Coverage Status install size GitHub issues GitHub forks GitHub stars

Installing

Using npm:

$ npm install @sarmay/converter

Using yarn:

$ yarn add @sarmay/converter

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/@sarmay/converter/dist/index.min.js"></script>

Using unpkg CDN:

<script src="https://unpkg.com/@sarmay/converter/dist/index.min.js"></script>

Example

Parameters: text to be converted, output type, input type (optional)

Parameters 1: <String>The text to be converted

Kazakh Arabic | Kazakh Cyrillic | Kazakh Latin

Parameters 2: <String>Type of output

Cyrillic | Arabic | Latin

Parameters 3: <String>Type of input (optional)

Cyrillic | Arabic | Latin

for Node

const converter = require('@sarmay/converter')
const value = converter('سالەم سارماي','Cyrillic','Arabic')
console.log(value)

for Vue

  • note: React / Angular As the same below
<template>
  <div>
    <textarea v-model="value" name="sarmay-ime" id="sarmay-ime" cols="30" rows="10" @keydown="keydownHandel"></textarea>
    <div>{{newValue}}</div>
  </div>
</template>
<script>
  import webIME from '@sarmay/web-ime'
  import converter from '@sarmay/converter'
  export default {
  data() {
    return {
      value: '',
      newValue: ''
    }
  },

  methods: {
    keydownHandel(event) {
      webIME('kz', event)
      this.newValue = converter(this.value,'Cyrillic','Arabic')
    }
  }
}
</script>

for Html script

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>@Sarmay/converter</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!--  load from unpkg -->
    <script src="https://unpkg.com/@sarmay/web-ime/dist/index.min.js"></script>
    <script src="https://unpkg.com/@sarmay/converter/dist/index.min.js"></script>
    <!--  or load from  jsdelivr
      <script src="https://cdn.jsdelivr.net/npm/@sarmay/web-ime/dist/index.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/@sarmay/converter/dist/index.min.js"></script>
    -->
  </head>
  <body>
    <div>
      <textarea name="values" id="values" cols="50" rows="10"></textarea>
      <div id="show"></div>
    </div>
    <script>
      var values = document.getElementById('values');
      var show = document.getElementById('show');
      values.addEventListener("keydown", function(event) {
         sarmayIme('kz', event);
         show.innerText = sarmayConverter(values.value,'Cyrillic','Arabic')
      });
    </script>
  </body>
</html>

License

MIT

Package Sidebar

Install

npm i @sarmay/converter

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

26.6 kB

Total Files

8

Last publish

Collaborators

  • sarmay