Git Product home page Git Product logo

transliterate's Introduction

Transliterate

Небольшой пакет для транслитерации кирилицы 💩

Дисклеймер

Работать - работает. Сорян, если что не так.

Умеет:

  • строку в url ['type' => 'url']
  • строку в имя файла ['type' => 'filename']

Установка:

composer require elforastero/transliterate
//config/app.php

'providers' => [
  //...
  ElForastero\Transliterate\TransliterationServiceProvider::class,
],

'aliases' => [
  //...
  'Transliterate' => ElForastero\Transliterate\TransliterationFacade::class,
],

Использование:

use Transliterate;
...

$string = '\'"#^_^ Если б мишки были пчёлами, то они бы нипочем, никогда и не подумали так высо́ко строить дом.';

$string = Transliterate::make($string);
// Esli b mishki bili pchyolami to oni bi nipochem nikogda i ne podumali tak visoko stroit dom

$string = Transliterate::make($string, ['type' => 'url', 'lowercase' => true]);
// esli-b-mishki-bili-pchyolami-to-oni-bi-nipochem-nikogda-i-ne-podumali-tak-visoko-stroit-dom

$string = Transliterate::make($string, ['type' => 'filename', 'lowercase' => true]);
// esli_b_mishki_bili_pchyolami_to_oni_bi_nipochem_nikogda_i_ne_podumali_tak_visoko_stroit_dom

$string = Transliterate::make($string, ['type' => 'url', 'lowercase' => true, 'map' => 'gost2000']);
// esli-b-mishki-by'li-pchyolami-to-oni-by'-nipochem-nikogda-i-ne-podumali-tak-vy'soko-stroit`-dom

Доступные параметры:

[
  'type' => 'url',
  // 'url', 'filename' или 'text'. Первым заменяем пробелы на '-', вторым на '_'.
  // По дефолту 'text', который ничего не заменяет.
  
  'lowercase' => true, // Преобразовать строку в нижний регистр.
  'map' => 'gost2000', // Транслитерация по ГОСТ 7.79-2000.
]

Дополнительно

// Получить карту транслитерации, используемую по-умолчанию
Transliteration::getDefaultMap();

// Карта по ГОСТ 2000
Transliteration::getGost2000Map();

transliterate's People

Contributors

elforastero avatar benyazi avatar

Watchers

James Cloos avatar  avatar

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.