0

For instance name = Florian Müllner, want name to be Florian MUllner How to covert name with accented characters in Liquid?

Read the replace doc, but was not able to figure out. How to use?

2 Answers2

1

This is my very very dirty solution and far from complete (but works for my needs) with no plugins in Jekyll:

{% assign text = 'Müller Pérez' %}
{% include normalize_text.html %}

and the included file works as a function:

{% assign text = text | replace: 'á', 'a' | replace: 'é', 'e'  | replace: 'í', 'i'  | replace: 'ó', 'o'  | replace: 'ú', 'u' %}
{% assign text = text | replace: 'à', 'a' | replace: 'è, 'e'  | replace: 'ì', 'i'  | replace: 'ò', 'o'  | replace: 'ù', 'u' %}
{% assign text = text | replace: 'ä', 'a' | replace: 'ë', 'e'  | replace: 'ï', 'i'  | replace: 'ö', 'o'  | replace: 'ü', 'u' %}
{% assign text = text | replace: 'â', 'a' | replace: 'ê, 'e'  | replace: 'î', 'i'  | replace: 'ô', 'o'  | replace: 'û', 'u' %}
kinsay
  • 29
  • 4
0

You can use replace like this.

{% assign text = 'Florian Müllner' | replace: "ü", "U" %}
DVS
  • 326
  • 1
  • 7
  • It would be a temporary fix, it would fail if the value of text changes. Need something more dynamic –  Jan 05 '21 at 08:54
  • That's how the replace string filter works. – DVS Jan 05 '21 at 08:56
  • Then you need to handleize the text. Please try this code. {% assign text = 'Florian Müllner' | handleize | capitalize | replace: '-',' ' %} – DVS Jan 05 '21 at 09:02
  • handleize won't convert accent characters, need an answer somewhat mentioned in this: https://stackoverflow.com/a/37511463/14673850 –  Jan 05 '21 at 09:11