Ad

Is There A Way To Use Prepend With Shopify's Language Translation?

'Currently I want to display View All "Collection Title". I do this successfully using the prepend. However, when creating a shopify theme one of the requirements is language support / translation.

<div class="collection-cta">{{ product_collection.title | prepend: 'View All ' | link_to: product_collection.url }}</div>

I am having trouble figuring how how to prepend the shopify translation markup.

{{ 'collections.general.view_all' | t }}

This outputs the View All text translation correctly, but getting to work inside of prepend:'' has proven to be problematic. I haven't been able to find strong documentation on this so any perspective would be great.

Ad

Answer

How about this?

<a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="{{product_collection.url }}">{{product_collection.title}} {{ 'collections.general.view_all' | t }}</a>

No need to use link_to... I'm not entirely clear on the inner workings of liquid, but it does expect a certain number of arguments... adding prepend and the translation tag may have thrown it.

So split it all out - and it should work.

Ad
source: stackoverflow.com
Ad