Coder Social home page Coder Social logo

greybax / cyrillic-to-translit-js Goto Github PK

View Code? Open in Web Editor NEW
141.0 5.0 44.0 866 KB

Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa

Home Page: https://greybax.github.io/cyrillic-to-translit-js

License: MIT License

JavaScript 79.00% HTML 19.65% TypeScript 1.34%
cyrillic translit translate converting-cyrillic-symbols translit-js str translation transliteration translations cirilica

cyrillic-to-translit-js's Introduction

cyrillic-to-translit-js

install size NPM version NPM Downloads/month Build Status Coveralls Status

Lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa

Demo page

Install

npm install --save cyrillic-to-translit-js

Simple to use

import CyrillicToTranslit from 'cyrillic-to-translit-js';

const cyrillicToTranslit = new CyrillicToTranslit();

cyrillicToTranslit.transform('Какая-то строка', '_').toLowerCase();

Constructor

  • { preset: 'ru' } or empty - transliteration preset for Russian language.
  • { preset: 'uk' } - transliteration preset for Ukranian language (see PR #27).
  • { preset: 'mn' } - transliteration preset for Mongolian language (see PR #142).

transform()

Convert Cyrillic symbols to Translit

cyrillicToTranslit().transform(input, spaceReplacement);

  • input - string which should be transformed
  • spaceReplacement - symbol for space replacement

reverse()

Convert Translit symbols to Cyrillic

cyrillicToTranslit().reverse(input, spaceReplacement);

  • input - string which should be transformed
  • spaceReplacement - symbol for space replacement

Examples

  • transform()
  cyrillicToTranslit().transform('Привет Мир!');

  >Privet Mir!
  cyrillicToTranslit().transform('привет мир!', "_")

  >privet_mir!
  cyrillicToTranslit({ preset: "uk" }).transform('привіт світе!', "_")

  >pryvit_svite!
  • reverse()
  cyrillicToTranslit().reverse("ulitsa Soyuza Pechatnikov")

 >улица Союза Печатников
  cyrillicToTranslit({ preset: "uk" }).reverse("Rozghon Uliana i Harashchenko Khrystyna")

  >Розгон Уляна і Гаращенко Христина

Typescript

Typescript supports starting form v2.0.0. See definitions here

Credits

Why I've done this plugin?

https://alfilatov.com/posts/cyrillic-to-translit-js-library-for-converting-cyrillic-symbols-to-translit-and-vice-versa/

License

MIT © Aleksandr Filatov alfilatov.com

cyrillic-to-translit-js's People

Contributors

dependabot[bot] avatar evenfrost avatar greenkeeper[bot] avatar greenkeeperio-bot avatar greybax avatar igorkamyshev avatar justinwoodring avatar nitruxa avatar nykula avatar renovate-bot avatar sasha-kir avatar sime1 avatar tengis avatar uqe avatar vasergen avatar wclr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cyrillic-to-translit-js's Issues

TypeScript types

Please add typescript support for this library. I can't find @types/cyrillic-to-translit-js

The symbols which "cyrillic-to-translit-js' do not replace

Hi guys, I've found the bug:
The symbols ь ъ ы э х will be not replaced.

I've solved this problem, maybe it can help someone.

return cyrillicToTranslit()
    .transform(string)
    .replace(/ь?ъ/gi, '')
    .replace(/э/gi, 'e')
    .replace(/ы/gi, 'i')
    .replace(/х/gi, 'h')

An in-range update of mocha is breaking the build 🚨

Version 3.5.3 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.5.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.5.3

3.5.3 / 2017-09-11

🐛 Fixes

  • #3003: Fix invalid entities in xUnit reporter first appearing in v3.5.1 (@jkrems)
Commits

The new version differs by 3 commits.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of coveralls is breaking the build 🚨

Version 2.13.2 of coveralls just got published.

Branch Build failing 🚨
Dependency coveralls
Current Version 2.13.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As coveralls is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 3 commits.

  • 5ebe57f bump version
  • 428780c Expand allowed dependency versions to all API compatible versions (#172)
  • eb1b723 Update Mocha link (#169)

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

More languages support

Now, this repo supports Russian and Ukrainian languages. But I believe that we can add more language for support.

If you want to propose support for a new language let's discuss it here.

Реализовать обратимую транслитерацию "яролит"

Привет! Возможно, заинтересует такой вариант транслита:

https://программирование-по-русски.рф/яролит.яргт/

В принципе уже есть исходники библиотечки js вот тут

https://bitbucket.org/budden/ppr/src/master/static/jarolit/яролит.js

Которая подключается дедовским способом без npm.
Можно было бы сделать режим для вашей библиотечки. По первой ссылке - объяснение, почему такой транслит правильный.

An in-range update of should is breaking the build 🚨

Version 13.1.1 of should was just published.

Branch Build failing 🚨
Dependency should
Current Version 13.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

should is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 2 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

reverse translit

Are any ways to use reverse translit?
pryvit_svite => привіт світе

Детальная инструкция по использованию

Здравствуйте. Подскажите как правильно использовать библиотеку? Мне нужно применить ее в тайпскрипте. Делаю так:
import cyrillicToTranslit from 'cyrillic-to-translit-js'; - вроде в ТС можно использовать только именованный импорт, но подключить по другому не получается
import * as cyrillicToTranslit from 'cyrillic-to-translit-js';
import {cyrillicToTranslit} from 'cyrillic-to-translit-js';
Если подключить как в первом варианте, то хотя бы ошибки нет на этом этапе. Дале делают так

const transliter = new cyrillicToTranslit();
transliter.transform('тесет', "-")

Получаю ошибку
cyrillic_to_translit_js_1.default is not a constructor
Я так понимаю, что дело в неправильном импорте. Вы не могли бы подсказать как правильно использовать библиотеку в ТС. Можно добавить инструкцию, а то там пропущена часть с созданием экземпляра класса, хотя про конструктор информация есть, хотелось бы более полного описания

An in-range update of mocha is breaking the build 🚨

Version 3.5.1 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.5.1

3.5.1 / 2017-09-09

📰 News

  • 📣 Mocha is now sponsoring PDXNode! If you're in the Portland area, come check out the monthly talks and hack nights!

🐛 Fixes

  • #2997: Fix missing xit export for "require" interface (@solodynamo)
  • #2957: Fix unicode character handling in XUnit reporter failures (@jkrems)

🔩 Other

Commits

The new version differs by 14 commits.

  • 4070a44 Release v3.5.1
  • 466ba73 update CHANGELOG.md for v3.5.1 [ci skip]
  • 1cc0fc0 import/require xit, fixes #2972
  • 74fa66f update nyc to latest; remove workaround in travis script
  • aa52933 update coveralls strategy; closes #2984
  • 73a5338 Spelling (#2981)
  • 9f403bf Add utils.escape tests and fix unicode escaping
  • 800acbc whitelist "developer-experience" tag for stalebot [ci skip]
  • 5895671 Added issue, pull request templates. (#2869)
  • 075bd51 Merge pull request #2918 from mochajs/no-shell-test
  • 8710438 Work around Node 0.10 Windows flake when testing
  • 13b8340 Ensure that compiler lookup works and not just that transpilation works (#2922)
  • 26d337a Add tests for double-star behavior
  • c0e6b68 Eliminate glob.sh

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Can't build with "Create React App" for production

When I'am trying to compile my CRA Application for production build I got an error:

reating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

        ./node_modules/cyrillic-to-translit-js/CyrillicToTranslit.js:77 

Read more here: http://bit.ly/2tRViJ9

Написал вам письмо

Пожалуйста, проверьте свой ящик (включая спам). Я отправил письмо с вопросом.

Update demo page

Add ability for switching between ‘transform’ and ‘reverse’ methods in UI

Fix tests

> [email protected] test /home/rof/src/github.com/greybax/cyrillic-to-translit-js
> tsc && tslint *.ts && mocha && npm run size

cyrillic-to-translit-js-tests.ts:4:5 - error TS2351: This expression is not constructable.
Type 'typeof import("/home/rof/src/github.com/greybax/cyrillic-to-translit-js/CyrillicToTranslit")' has no construct signatures.

4 new CyrillicToTranslit().transform("привет мир!");
      ~~~~~~~~~~~~~~~~~~

cyrillic-to-translit-js-tests.ts:5:5 - error TS2351: This expression is not constructable.
Type 'typeof import("/home/rof/src/github.com/greybax/cyrillic-to-translit-js/CyrillicToTranslit")' has no construct signatures.

5 new CyrillicToTranslit().transform("привет мир!", "_");
      ~~~~~~~~~~~~~~~~~~

cyrillic-to-translit-js-tests.ts:6:5 - error TS2351: This expression is not constructable.
Type 'typeof import("/home/rof/src/github.com/greybax/cyrillic-to-translit-js/CyrillicToTranslit")' has no construct signatures.

6 new CyrillicToTranslit({ preset: "uk" }).transform("привіт світе!", "_");
      ~~~~~~~~~~~~~~~~~~


Found 3 errors.

npm ERR! Test failed.  See above for more details.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Несовместимость с правилами транслитерации яндекса

Мытищи конвертится как mitishchi, а по правилам яндекса ( https://yandex.ru/support/nmaps/app_transliteration.html ) должно быть mytischi.

Проверял тут https://greybax.github.io/cyrillic-to-translit-js

Если это ломает совместимость, может добавить какой-нить параметр-флаг в конфиг?

An in-range update of should is breaking the build 🚨

Version 13.2.2 of should was just published.

Branch Build failing 🚨
Dependency should
Current Version 13.2.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

should is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).
  • coverage/coveralls: First build on greenkeeper/should-13.2.2 at 100.0% (Details).

Commits

The new version differs by 9 commits.

  • 031b8e6 Release 13.2.2
  • 6db456c Merge branch 'master' of github.com:shouldjs/should.js
  • 1ab1661 Add note about TS
  • 889e22e Merge pull request #171 from jsoref/spelling
  • 79ec809 Spelling fixes
  • 0abf2d5 Merge pull request #167 from lumaxis/bugfix/typescript-error
  • d1e9efe Fix TypeScript compiler issue with fulfilled assertion
  • 9dcde0f Merge pull request #164 from chris-grabcad/UpdateDefinitionsOfTrueAndFalseInTypings
  • 7917c9c Add optional message to [Tt]rue and [Ff]alse so they can be used in typecript tests

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

es6 syntax in npm package

Hi. You use the new syntax in the NPM package, which is not automatically compiled by Babel. Therefore, it cannot work correctly on older versions of browsers.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Update npm

The library has a lot of dependencies after adding browserify. I've seen a fixing commit. But it's still not in npm.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

develop logo

Originally I've developed this project like a simple js function, but now it's more than function. This is the library with pretty solid logic underhood.

I believe that's a good time to create a logo for this repo :)

Typescript implicitly any

A new expression whose target does not have a constructor signature is implicitly of type any.
const cyrillicToTranslit = new CyrillicToTranslit();
It's more correct to write:
const cyrillicToTranslit = CyrillicToTranslit();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.