URL Slug and german Umlaute

Seems like the automatic URL Generation is now not converting the Umlaute correct anymore. Is this a Bug or a Feature :smiley: now K3 makes of the Word “Bücher” now “bucher” and in K2 it was correct and made “buecher”

Compare between K2 and K3

Edit: and sorry again for the “spamming” but there are so much questions since I start the Upgrade.

1 Like

Looks like this is an effect of the slugify.js library used in the Panel, see the charMap in the linked file.

I created an issue on GitHub:

All right, good to know.

It’s not just a problem in the js implementation. We removed the umlaut translator, because that only works for German, but not for Turkish for example. We need to create a feature first to offer localized slug translators before we can introduce umlaut conversion again.

1 Like

Will be fixed in 3.2

1 Like

i’m using an english panel installation, do i need to tell the generator somehow to use the german umlaut translation? my URLs are still being generated as “/huttengaudi” instead of “/huettengaudi”

You can set the slug language in your config:

(Make sure to update to 3.2.x if you haven’t yet)

2 Likes

amazing, thank you!

I don’t understand how I can set the slugs to convert all German umlauts properly. Could somebody tell me exactly where I need to set what?

Following the example in the docs, I set

// site/config/config.php
'slugs' => 'de'

and this actually turns Hosenträger into hosentraeger as intended, but it leaves Bügelfalte as bugelfalte. How can I make sure that ü turns into ue?

This is not a multilanguage setup.

Thanks!

See here: https://getkirby.com/docs/reference/system/options/slugs

Yes, that was the doc example I was referring to. Still, it’s not obvious for me what to do with that information. Are you referring to the snippet

Str::$language = [
  'ß' => 'sz' 
];

?

If so, where do I need to place this? There is not further information in the docs, just this standalone snippet.

That should into the config.php, you can put it at the top.

Just like that:

// site/config/config.php

<?php

return [

  Str::$language = [
    'ü' => 'ue'
  ]

]

?

Does not seem to do anything.

No, outside of and before the return statement.

And this is supposed to change the slugs only?

It still does not do anything, I just put it outside of and before the return statement. Do I need to put something in place of $language or leave this in as a variable?

Hm, for me Umlaute work even without any additional setting.

Ok, I now tested this myself and it works if I put this

 Str::$language = [
    'ü' => 'op'
  ];

into a plugin instead of in the config.

It still does not work. Not sure if I misunderstand something in general. Here’s what I did:

I created this plugin file:

// site/plugins/trych/index.php
<?php

Kirby::plugin('trych/formatting', [
  Str::$language = [
    'ü' => 'op'
  ]
]);

I am starting to suspect that my issue actually is that I am dealing with a field slug() method (is that maybe different from a url slug?).

In my template I am using the slug method like this:

$kirby->users()->first()->name()->slug();  // turns Müller into muller, not mueller or mopller

Any further ideas?

Nope, just


<?php
// site/plugins/trych/index.php

  Str::$language = [
    'ü' => 'op'
];

Simple plugin without the plugin wrapper.

Still does not work.

Just to be extra sure: Am I understanding you right, that this simple plugin – without any other changes in the config or anything else – is supposed to alter the method field()->slug() in a way that for a name: Müller text field it will return mueller?

I thought we were talking about the Panel generating the slugs when creating a new page all the time… I haven’t tested the field slug() method.

But the replacements for me with the slug method as well, e.g. in album.txt

name: Jörgen Müller

And this replacement list:

Str::$language = [
    'ü' => 'op',
    'ö' => 'schlop',
    'ä' => 'bah',
];
<?php echo $page->name()->slug() ?>

Result: jschloprgen-mopller

But even when I only use 'slugs' => 'de' in config (without the replacement array), a string

Jörgen Müller Übermuth Händler

gives me

'joergen-mueller-uebermuth-haendler`.

What is your Kirby version? Single language/multi-language?