Skip to content

Instantly share code, notes, and snippets.

@romul
Created February 10, 2011 12:37
Show Gist options
  • Save romul/820448 to your computer and use it in GitHub Desktop.
Save romul/820448 to your computer and use it in GitHub Desktop.
Refinery CMS: Transliterate page titles in URLs

Ты не знаешь как включить транслитерацию URL в Refinery CMS 0.9.9, а русские символы в виде шестнадцатеричных последовательностей в URL тебя бесят? Тогда ты нашёл нужный gist.

Включить транслитерацию достаточно не сложно, после кропотливого изучения кода ;-)

Итак:

  1. Установи и подключи gem russian

  2. Создай initializer со следующим содержимым:

     # Добавить поддержку русского языка в Bobosa
     russian_approximation = Russian::Transliteration::LOWER.merge(Russian::Transliteration::UPPER)
     Babosa::Characters.add_approximations(:russian, russian_approximation)
     # Задать русскую транслитерацию по умолчанию
     FriendlyId::Configuration::DEFAULTS.merge!(:ascii_approximation_options => :russian)
     # Активировать транслитерацию
     RefinerySetting.set(:approximate_ascii, true)
    
  3. На всякий случай проверь, что RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => "pages") возвращает true. Эту настройку также можно задать в админке.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment