Browse Source

Tweak Text::slug() to generate output closer to Inflector::slug().

ADmad 10 years ago
parent
commit
5b97ec3db1
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/Utility/Text.php
  2. 1 1
      tests/TestCase/Utility/TextTest.php

+ 2 - 2
src/Utility/Text.php

@@ -28,7 +28,7 @@ class Text
      *
      * @param string $defaultTransliteratorId Transliterator identifer string.
      */
-    public static $defaultTransliteratorId = 'Any-Latin; Latin-ASCII';
+    public static $defaultTransliteratorId = 'Latin-ASCII';
 
     /**
      * Generate a random UUID version 4
@@ -879,7 +879,7 @@ class Text
 
         $quotedReplacement = preg_quote($options['replacement'], '/');
         $map = [
-            '/[^\sa-zA-Z0-9]/mu' => ' ',
+            '/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
             '/[\s]+/mu' => $options['replacement'],
             sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
         ];

+ 1 - 1
tests/TestCase/Utility/TextTest.php

@@ -1606,7 +1606,7 @@ podeís adquirirla.</span></p>
             ],
             [
                 'A æ Übérmensch på høyeste nivå! И я люблю PHP! есть. fi ¦', [],
-                'A-ae-Ubermensch-pa-hoyeste-niva-I-a-lublu-PHP-est-fi'
+                'A-ae-Ubermensch-pa-hoyeste-niva-И-я-люблю-PHP-есть-fi'
             ],
             [
                 'Äpfel Über Öl grün ärgert groß öko', [],