📜 ⬆️ ⬇️

syncTranslit plugin

Many web projects use friendly urls. For example, instead of the article id in the url, its text identifier (slug) is used. Usually slug is generated automatically on the server side when creating an article. But if you want to be able to set slug yourself (through the form) - you can use my syncTranslit plugin .

syncTranslit plugin


Publish an article from your blog . This plugin is designed for Ukrainian and Russian developers.
The main task of the plugin: generation of slug from the Cyrillic text. The plugin allows you to synchronize two fields on the form, with one field being the source of the data (for example, the title of the article), and the second (slug) receiving the translated text.
')

Using


We include the plugin file, call the syncTranslit method for the source element, and pass the destination parameter — the id of the destination element:

$( document ).ready( function (){
$( "#articleTitle" ).syncTranslit({destination: "slug" });
});



Demonstration of this example


Possible options


List of available options:



Example using other options: transliteration with conversion to upper case and using underscore to separate words:

$( document ).ready( function (){
$( "#articleTitle2" ).syncTranslit({
destination: "slug2" ,
caseStyle: "upper" ,
urlSeparator: "_"
});
});



Download syncTranslit plugin with Google Code
Project page on jQuery website

Source: https://habr.com/ru/post/73168/


All Articles