문제

I have a file called _catalog-extend.scss. When I open this file I see in de the code a hardcoded 'Price'.

  //
//  Price box
//  _____________________________________________
.product-info-main .price-box {
    width: 100%;
    float: left;
    padding-left: 40%;
    min-height: 60px;
    line-height: 60px;
    position: relative;
    justify-content: flex-start;

    // Price label content: 
    &:before {
        content: 'Price';
        position: absolute;
        left: 0;
        min-height: 60px;
        width: 40%;
        line-height: 60px;
        text-transform: uppercase;
        font-weight: bold;
        color: $text__color;
    }

But how can I translate this piece "content: 'Price';" for a multistore?

도움이 되었습니까?

해결책

You cannot translate content in CSS files.

The easiest way around this is to translate the text in the template and use the attr() function to retrieve the translated value:

Add a data attribute:

data-label="<?= $escaper->escapeHtml(__('Price')); ?>"

And access this in your CSS:

content: attr(data-label)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top