@@ -1014,7 +1014,7 @@ public static function singular($value)
1014
1014
* @param string|null $language
1015
1015
* @return string
1016
1016
*/
1017
- public static function slug ($ title , $ separator = '- ' , $ language = 'en ' )
1017
+ public static function slug ($ title , $ separator = '- ' , $ language = 'en ' , $ dictionary = [ ' @ ' => ' at ' ] )
1018
1018
{
1019
1019
$ title = $ language ? static ::ascii ($ title , $ language ) : $ title ;
1020
1020
@@ -1023,10 +1023,14 @@ public static function slug($title, $separator = '-', $language = 'en')
1023
1023
1024
1024
$ title = preg_replace ('![ ' .preg_quote ($ flip ).']+!u ' , $ separator , $ title );
1025
1025
1026
- // Replace @ with the word 'at'
1027
- $ title = str_replace ('@ ' , $ separator .'at ' .$ separator , $ title );
1026
+ // Replace dictionary words
1027
+ foreach ($ dictionary as $ key => $ value ) {
1028
+ $ dictionary [$ key ] = $ separator .$ value .$ separator ;
1029
+ }
1030
+
1031
+ $ title = str_replace (array_keys ($ dictionary ), array_values ($ dictionary ), $ title );
1028
1032
1029
- // Remove all characters that are not the separator, letters, numbers, or whitespace.
1033
+ // Remove all characters that are not the separator, letters, numbers, or whitespace
1030
1034
$ title = preg_replace ('![^ ' .preg_quote ($ separator ).'\pL\pN\s]+!u ' , '' , static ::lower ($ title ));
1031
1035
1032
1036
// Replace all separator characters and whitespace by a single separator
0 commit comments