Conversation
src/OrchardCore.Modules/OrchardCore.Liquid/Filters/TransliterateFilter.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Liquid/Filters/TransliterateFilter.cs
Show resolved
Hide resolved
|
You remind me of the work that I did in Orchard Core Contrib (OCC) https://github.com/OrchardCoreContrib/OrchardCoreContrib/tree/main/src/OrchardCoreContrib.ContentLocalization.Abstractions/Transliteration 2 years ago Please show me some usage examples before I review this |
|
See the PR description for examples. |
Thanks Zoltan, seems I'm blind at the beginning :) @urbanit, how has the script been specified in your case? If you look into the related repo or the demo https://www.youtube.com/watch?v=MEmNL5tzezA, you will notice that we used a sort of script to transliterate |
|
He's back! (never left our hearts though) |
|
Added:
|
There was a problem hiding this comment.
Also add a note about the defaults changing like this to the v3 release notes, both for slugify and Media Slugify.
There was a problem hiding this comment.
@urbanit are you aware of this comment of mine?
When you're done addressing all feedback of a review, click "Re-request review" in the top-right corner for each reviewer, so they know that you're done.
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
Co-authored-by: Zoltán Lehóczky <zoltan.lehoczky@lombiq.com>
Add transliterate Liquid Filter
Based on https://github.com/orgs/OrchardCMS/discussions/10748 and fixes #4151 and fixes #4874
Summary
Introduces a new transliterate Liquid filter to the OrchardCore.Liquid module. It converts Unicode text (e.g. Greek,
Cyrillic, Arabic, Chinese, etc.) into its closest ASCII/Latin representation using the
https://github.com/anyascii/anyascii library.
Changes
Usage
Apply the filter to any string value in a Liquid template:
{{ "Ελληνικά" | transliterate }}
{# Output: Ellinika #}
{{ "Привет мир" | transliterate }}
{# Output: Privet mir #}
{{ "日本語" | transliterate }}
{# Output: Ri Ben Yu #}
Chaining with slugify
A common use case is generating URL slugs from non-Latin content — transliterate first, then slugify:
{{ ContentItem.DisplayText | transliterate | slugify }}
This is especially useful for auto-generating URL aliases for content items with titles in non-Latin scripts.