Ruslan Ulanov’s Codeshack

The developer’s notebook

Cyr2Lat Slugs – WordPress Plugin

10 comments

На русском читайте ниже…

If you happen to write Word Press posts in one of the Cyrillic-based languages (i.e. Russian, Bulgarian, Ukrainian, Belarusian, etc.) and are using post’s title in Permalinks then you know that your post’s URL will become an unreadable mash of encoded characters (like %45%f0%…)

I got finally tired of changing encoded slugs to their latin equivalents on my son’s blog, and started looking for ways to automate this process. The Cyrillic Slugs plug-in written by Petko Bossakov was my only alternative at the time in WordPress plug-in repository. Unfortunatelly that plug-in didn’t work for me, since Cyrillic Slugs expects the page to be written in Windows-1251 encoding, and my blog uses WP’s default/recommended UTF-8. Hence Cyr2Lat Slugs plug-in was born.

Here’s a sample that illustrates what this plug-in does.

Before Cyr2Lat Slugs:

  1. You write a post with title “Пример заголовка”
  2. WordPress creates permalink like this:
    http://www.myblog.com/2008/12/19/%d0%bf%d1%80%d…b2%d0%ba%d0%b0

After Cyr2Lat Slugs:

  1. You write a post with title “Пример заголовка”
  2. WordPress creates permalink like this:
    http://www.myblog.com/2008/12/19/primer-zagolovka

Cyr2Lat Slugs is based on Petko’s original idea and uses one of his functions, but otherwise is written in a more contemporary, object-oriented fashion. It also uses strtr function instead of str_replace which should be much faster.

Please note that you have to save post (click Save or Publish button) for slug conversion to take place!

Version: 1.0
Requirements: WP 2.3+ (WP MU compatible)
Author: Ruslan Ulanov
License: GPL

Download Cyr2Lat Slugs plug-in now.

Installation:

  1. Copy file cyr2lat-slugs.php to folder wp-content/plugins/ on your server.
  2. Activate Cyr2Lat Slugs in Plugins menu of your blog’s admin interface.
  3. You’re done. There are no options to configure.

Comments are welcome (moderated, no spam please).

 
#
*In Russian*

Cyr2Lat Slugs это плагин для платформы Word Press, который переводит русские буквы в заголовке поста в латиницу (транслит), тем самым делая URL читаемым и доступным для поисковиков.

Продемонстрируем работу плагина Cyr2Lat Slugs на примере.

До установки Cyr2Lat Slugs:

  1. Вы пишете пост с заголовком “Пример заголовка”
  2. WordPress создает для него пермалинк:
    http://www.myblog.com/2008/12/19/%d0%bf%d1%80%d…b2%d0%ba%d0%b0

После установки Cyr2Lat Slugs:

  1. Вы пишете пост с заголовком “Пример заголовка”
  2. WordPress создает для него пермалинк:
    http://www.myblog.com/2008/12/19/primer-zagolovka

Примечание: Пост необходимо сохранить (нажать кнопку Save или Publish), чтобы заголовок был переведен в латиницу!

Версия: 1.0
Требования: WP 2.3+ (работает в WP MU)
Автор: Руслан Уланов
Лицензия: GPL

Загрузить Cyr2Lat Slugs.

Установка:

  1. Скопируйте файл cyr2lat-slugs.php в папку wp-content/plugins/ на сервере.
  2. Активируйте Cyr2Lat Slugs в меню Plugins административного интерфейса вашего блога.
  3. Готово. Больше ничего конфигурировать не надо.

Комментарии приветствуются (но модерируются, для отсеивания спама).

Written by Ruslan Ulanov

December 10th, 2008 at 7:41 pm

Posted in PHP

Tagged with

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

10 Responses to 'Cyr2Lat Slugs – WordPress Plugin'

Subscribe to comments with RSS or TrackBack to 'Cyr2Lat Slugs – WordPress Plugin'.

  1. hi. Thanks for plugin

    perfect.

    Regards

    You are welcome

    Ruslan

    baron

    12 Dec 08 at 4:54 am

  2. Unfortunally, this plugin doesn’t work on re-publishing old posts…

    Anyway, thank you very much!

    Eugene,

    Yes, once permalink is created my plug-in will not touch it (otherwise it wouldn’t be a permalink). Though, I might consider creating a separate button in the editor to force update of the permalink. Thanks for the idea.

    Ruslan

    Eugene

    21 Mar 09 at 1:53 am

  3. Hello,
    I just downloaded your plugin and will give it a try.
    I would like to ask – is there a way to change the transliteration rules (to correspond the Bulgarian alphabet)

    Thank you.

    Hi Dimitre,
    Currently there is no admin interface for changing transliteration rules (a good idea though), but you can open the PHP file in your favorite text editor and make the changes if you like.

    Ruslan.

    Dimitre

    7 Apr 09 at 11:47 pm

  4. Хорошо что еще кто-то делает оригинальные сайты. Спасибо за информацию, очень интересно.

    Illiblyneew

    12 May 09 at 11:18 am

  5. Интересный блог, побольше бы таких

    Steptacramp

    12 May 09 at 7:31 pm

  6. Побольше бы и таких сайтов

    JatBoodssnins

    13 May 09 at 8:02 am

  7. Скажите а материалы с Вашего сайта можно у себя размещать?

    Greehorgops

    14 May 09 at 7:50 am

  8. Можно. Я не жадный. :)

    rusgrafx

    21 May 09 at 6:54 pm

  9. Все-таки хорошее изобретение – блог. Казалось бы обычный сайт, но поменяли подачу информации, отдали вебсайт в руки толькоодного человека и сразу открылась еще одна новая грань общения со всем миром. :)

  10. Спасибо за то что написали про это, давно ищу подобное

    MamyGreespemy

    9 Oct 09 at 6:12 pm

Leave a Reply