商店视图中的Magento 2错误的语言环境(错误的翻译)

我有下一个问题。
我有2个网站(德国和奥地利)。
网站有商店(德国商店和 奥地利商店)。
每个商店有2个商店视图( German-DE </ code>, German-EN </ code>, Austria-DE </ code>, Austria- EN </ code>)。
German商店及其商店视图 German-DE </ code>是默认的商店和商店视图。</ p>

现在解决问题。 一般来说,我需要有下一个翻译:
德国-DE-德国语言</ code>;
德国-EN-英语</ code>;
Austria-DE - 德国 language </ code>;
Austria-EN - 英语</ code>; </ p>

在管理面板中,我为区域设置做了设置( Stores&gt; Configuration&gt ; General&gt; </ code>):所有英语语言库视图都有 en_US </ code>语言环境,所有德语语言库视图都有 de_DE </ code>语言环境。</ p>

http://joxi.ru/L21PjnVT8nvPJm </ p>

但是 ,在德国商店所有商店的意见都有正确的翻译,但在奥地利翻译不起作用...一般奥地利商店有默认商店视图奥地利EN </ code>和所有商店的意见都有英文翻译。 当我将默认商店视图切换到Austria-DE时,所有奥地利商店视图都将转换为德语。 我尝试使用 Magento \ Framework \ Translate </ code> </ p>

  public function __construct(
\ Magento \ Framework \ App \)在某些控制器的前端获取语言环境 Action \ Context $ context,
\ Magento \ Framework \ View \ Result \ PageFactory $ resultPageFactory,
\ Magento \ Framework \ Translate $ translate

{
$ this-&gt; resultPageFactory = $ resultPageFactory; \ n $ this-&gt; translate = $ translate;
parent :: __ construct($ context);
}

公共函数execute()
{
var_dump($ this-&gt; translate-&gt; getLocale ());
die;

返回$ this-&gt; resultPageFactory-&gt; create();
}
</ code> </ pre>

和奥地利 - DE我得到 en_US </ code>,当在这个商店视图的语言环境中设置 de_DE </ code>。
请帮我弄清楚是什么问题。</ p>
</ DIV>

展开原文

原文

I have next problem. I have 2 websites (German and Austria). Websites have stores (German store and Austria store). Each store have 2 store views (German-DE, German-EN, Austria-DE, Austria-EN). German store and it's store view German-DE is the default store and store view.

Now to the problem. Generally I need to have next translations: Germany-DE - Germany language; Germany-EN - English language; Austria-DE - Germany language; Austria-EN - English language;

In admin panel i made settings for Locale(Stores > Configuration > General >): all English language store views have en_US locale and all Germany language store views have de_DE locale.

http://joxi.ru/L21PjnVT8nvPJm

But, in Germany store all store views have right translation, but in Austria translation do not work... Generally Austria store have default store view Austria-EN and all store views have english translation. When I switch default store view to Austria-DE, all Austria store views will translate to German. I try to get locale on frontend in some controller using Magento\Framework\Translate

public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $resultPageFactory,
    \Magento\Framework\Translate $translate
)
{
    $this->resultPageFactory = $resultPageFactory;
    $this->translate = $translate;
    parent::__construct($context);
}

public function execute()
{
    var_dump($this->translate->getLocale());
    die;

    return $this->resultPageFactory->create();
}

and in Austria-DE I get en_US when in locale of this store view is set de_DE. Please help me to figure it out what is the problem.

1个回答



您是否尝试过运行:</ p>

  bin / magento setup:static-content:  deploy de_DE 
</ code> </ pre>

非默认商店可能没有部署它。</ p>
</ div>

展开原文

原文

Have you tried running:

bin/magento setup:static-content:deploy de_DE

Possibly the non default stores didn't get it deployed.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问