Better character replacement for URLSegment #1002

Open
SewerHrehorowicz opened this Issue Apr 24, 2014 · 5 comments

6 participants

@SewerHrehorowicz

Diactric signs, such as ęółąśłżźć are deleted, and they should be replaced by euoslzzc. I don't know how it looks in other languages, but it works like that in Polish.

@tractorcow tractorcow added this to the 3.2 alpha 1 milestone May 7, 2014
@tractorcow

This sounds like a good idea.

Here's an example of a replacement chart that we could consider as an option. https://github.com/EllisLab/CodeIgniter/blob/develop/application/config/foreign_chars.php

@simonwelsh

If you have iconv installed, you can use:

SS_Transliterator:
  use_iconv: true
@Craftnet

Hi, now for polish signs I use this code:

//Znaki PL w URLSegment - dodajemy w Class w Page.php
public function generateURLSegment($title){
        $arg1 = array('ą', 'Ą', 'ć', 'Ć', 'ę', 'Ę', 'ł', 'Ł', 'ń', 'Ń', 'ó', 'Ó', 'ś', 'Ś', 'ź', 'Ź', 'ż', 'Ż' );
        $arg2 = array('a', 'a', 'c', 'c', 'e', 'e', 'l', 'l', 'n', 'n', 'o', 'o', 's', 's', 'z', 'z', 'z', 'z' );
        $title = str_replace ( $arg1, $arg2, $title );
        $filter = URLSegmentFilter::create();
        $t = $filter->filter($title);

        // Fallback to generic page name if path is empty (= no valid, convertable characters)
        if(!$t || $t == '-' || $t == '-1') $t = "page-$this->ID";

        // Hook for extensions
        $this->extend('updateURLSegment', $t, $title);

        return $t;
    }

And yes, I think too that this good idea

Sorry for my weak English

@tractorcow tractorcow modified the milestone: 4.0, 3.2 alpha 1 Jun 16, 2015
@tractorcow

Changing to 4.0 since there's no fix in time for 3.2.

@chillu chillu added the affects/v4 label Jun 2, 2016
@dhensby
SilverStripe Ltd. member

I think "use iconv" is a suitable solution here... Is anyone going to take this on or shall we close it?

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