Magento 2 货币符号未显示

Magento 2 Currency symbol is not showing

我有 2 家英语和阿拉伯语商店。默认商店是阿拉伯语,默认货币是 SAR。货币符号在英语商店中显示正常,但在阿拉伯语商店中没有显示。它只在产品列表页面和单个产品页面上显示 44 这样的价格。

我修好了。 发布我的答案可能会对某人有所帮助。

编辑此文件。

vendor\magento\zendframework1\library\Zend\Locale\Data\ar_SA.xml

并删除以下代码。

<numbers>
<currencyFormats numberSystem="latn">
<currencyFormatLength>
<currencyFormat type="standard">
<pattern>¤#0.00</pattern>
</currencyFormat>
</currencyFormatLength>
</currencyFormats>
</numbers>

更新的答案 ========

我有更好的解决方案,而不是编辑核心文件,你可以用观察者来完成。

Vendor/Module/etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="currency_display_options_forming">
        <observer name="change_currency_position" instance="Vendor\Module\Model\Observer\ChangeCurrencyPosition" />
    </event>
</config>

和观察者文件。

use Magento\Framework\Event\ObserverInterface;
class ChangeCurrencyPosition implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $currencyOptions = $observer->getEvent()->getCurrencyOptions();
        $currencyOptions->setData('position', \Magento\Framework\Currency::RIGHT);
        return $this;
    }
}

需要将 'position' 更改为 RIGHT。

如果@Ask4Tec 的解决方案不起作用

试试这个

从 en.xml 文件复制货币和数字块并将其粘贴到 ar_SA.xml 文件中 清理并刷新缓存 硬刷新后检查

更新 ar_SA.xml 如下:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ldml SYSTEM "../../common/dtd/ldml.dtd">
<!-- Copyright © 1991-2013 Unicode, Inc.
CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)
For terms of use, see http://www.unicode.org/copyright.html
-->
<ldml>
    <identity>
        <version number="$Revision: 9287 $"/>
        <generation date="$Date: 2013-08-28 21:32:04 -0500 (Wed, 28 Aug 2013) $"/>
        <language type="ar"/>
        <territory type="SA"/>
    </identity>
    <dates>
        <calendars>
            <calendar type="islamic">
                <dateTimeFormats>
                    <availableFormats>
                        <dateFormatItem id="Md" draft="contributed">M/d</dateFormatItem>
                        <dateFormatItem id="MEd" draft="contributed">E, M/d</dateFormatItem>
                        <dateFormatItem id="MMMd" draft="contributed">MMM d</dateFormatItem>
                        <dateFormatItem id="MMMEd" draft="contributed">E, MMM d</dateFormatItem>
                    </availableFormats>
                </dateTimeFormats>
            </calendar>
        </calendars>
    </dates>
    <numbers>
        <symbols numberSystem="latn">
            <decimal>.</decimal>
            <group>,</group>
            <list>;</list>
            <percentSign>%</percentSign>
            <plusSign>+</plusSign>
            <minusSign>-</minusSign>
            <exponential>E</exponential>
            <superscriptingExponent>×</superscriptingExponent>
            <perMille>‰</perMille>
            <infinity>∞</infinity>
            <nan>NaN</nan>
        </symbols>
        <decimalFormats numberSystem="latn">
            <decimalFormatLength>
                <decimalFormat>
                    <pattern>#,##0.###</pattern>
                </decimalFormat>
            </decimalFormatLength>
        </decimalFormats>
        <currencyFormats numberSystem="latn">
            <currencyFormatLength>
                <currencyFormat type="standard">
                    <pattern>¤#,##0.00</pattern>
                </currencyFormat>
                <currencyFormat type="accounting">
                    <pattern>¤#,##0.00;(¤#,##0.00)</pattern>
                </currencyFormat>
            </currencyFormatLength>
            <unitPattern count="one">{0} {1}</unitPattern>
            <unitPattern count="other">{0} {1}</unitPattern>
        </currencyFormats>
        <currencies>
            <currency type="USD">
                <displayName>US Dollar</displayName>
                <displayName count="one">US dollar</displayName>
                <displayName count="other">US dollars</displayName>
                <symbol>$</symbol>
            </currency>
        </currencies>
    </numbers>
</ldml>

这是 2.4.3 中的错误:

src\vendor\magento\module-directory\Model\Currency.php

注释掉这些行:

if ($this->canUseNumberFormatter($options)) {
    return $this->formatCurrency($price, $options);
}

然后:

php -dmemory_limit=6G bin/magento setup:upgrade
php -dmemory_limit=6G bin/magento setup:di:compile
php -dmemory_limit=6G bin/magento setup:static-content:deploy -f
php -dmemory_limit=6G bin/magento cache:flush

编辑核心不好,我们可以创建偏好。