kurtsson / jekyll-multiple-languages-plugin

I18n support for Jekyll and Octopress
MIT License
922 stars 203 forks source link

Translate and filter not possible #181

Closed sedrubal closed 3 years ago

sedrubal commented 3 years ago

For the RSS feed I need to pipe the translated string through |xml_escape. Before using jekyll-multiple-languages-plugin, I had this:

<title>{{ post.title | xml_escape }}</title>

Now I'm searching for a solution like:

<title>{% t post.title | xml_escape %}</title>

But this results in an empty string.

shushugah commented 3 years ago

would this work?

{% assign post_title = t post.title %}
<title>{% post_title | xml_escape %}</title>
sedrubal commented 3 years ago

would this work?

{% assign post_title = t post.title %}
<title>{% post_title | xml_escape %}</title>

No this does not work, neither. It's still empty.

shushugah commented 3 years ago

My bad, it should be

{% assign post_title = t post.title %}
<title>{{ post_title | xml_escape }}</title>

and can you confirm that {% t post.title %} is not empty in first place?

sedrubal commented 3 years ago

This does not work neither.

I have:

<title>{%- t post.title -%}</title>

which prints the title but without xml_espace.

{% assign post_title = t post.title %}
{{ post_title }}

This does print nothing. It seems, t does not work with assign. Thus

{% assign post_title = t post.title %}
<title>{{ post_title | xml_escape }}</title>

Is empty, too.

shushugah commented 3 years ago

this for sure would work tho, and seems to be issue...with chaining liquid filters, something I admittedly don't understand very well

{% capture yolo %}{% t post.title %}{% endcapture %}
<title>{{ yolo | xml_escape }}</title>
sedrubal commented 3 years ago

Thank you, this works for me.