Magento2: Ability to add Translation for CMS page and CMS block

Created on 13 Dec 2012  路  6Comments  路  Source: magento/magento2

As all know in magento .phtml we can translate text by using

__('text to translate'); ?>

but it is not possible to do in cms pages and blocks

if we can use following directive in cms page or static block

{{translate text="text to translate"}}

then it will be very useful and store owner can work with very less block and pages instead of duplicating same block or page for multiple stores where text change required.

if we add this functionality to magento core then it can be very useful.

Ref : http://www.lotusseedsdesign.com/blog/extend-the-use-of-links-phtml

Most helpful comment

For the record, there is natively the trans CMS directive, at least since version 2.0.0, eg :

{{trans "Email:"}}

or

{{trans
        'Forgot your account password? Click <a href="%reset_url">here</a> to reset it.'

        reset_url="$this.getUrl($store,'customer/account/createPassword/',[_query:[id:$customer.id,token:$customer.rp_token],_nosid:1])"
    |raw}}

All 6 comments

Hello. For this you should rather create separate blocks and assign them to proper store views. What is the advantage of your approach?

When we have more stores its hectic to make same change in all blocks just for text when html is same

at that time this approach can be useful. for html changes old approch is always there.

Hello. This is not currently planned. We encourage you to contribute code to improve it. Maybe with custom variables functionality?

@mage2-team i made some code to add this as a feature. should i open a new issue or can you reopen this one so i can submit a pull request? keep rocking, v2 looks amazing.

For the record, there is natively the trans CMS directive, at least since version 2.0.0, eg :

{{trans "Email:"}}

or

{{trans
        'Forgot your account password? Click <a href="%reset_url">here</a> to reset it.'

        reset_url="$this.getUrl($store,'customer/account/createPassword/',[_query:[id:$customer.id,token:$customer.rp_token],_nosid:1])"
    |raw}}

Is the {{trans directive documented somewhere on this matter?

Was this page helpful?
0 / 5 - 0 ratings