将动态值传递到 Laravel 中的本地化 JSON 文件

Pass dynamic value to localization JSON file in Laravel

在我的 Laravel 应用程序中,我使用 JSON 文件而不是 PHP 文件进行本地化。我正在关注此 docs 并寻找一种传递动态值的方法。

i18nReact中,是这样做的...

ja.json

{
    "searchResultText":"{{count}} 件表示. ({{rangeStart}} - {{rangeEnd}})"
}

在 JSX 中使用它时...

i18n.t('searchResultText', {count: data.count, rangeStart: data.rangeStart, rangeEnd: data.rangeEnd});

但是如何从 blade 模板传递动态值以及如何在 JSON 文件中使用它?

Laravel版本:5.4

ja.json

{
    "searchResultText":":count 件表示. (:rangeStart - :rangeEnd)"
}

在blade模板中

{{ __('searchResultText', ['count' => 'Dynamic count value here', 'rangeStart' => 'Dynamic rangeStart value here', 'rangeEnd' => 'Dynamic rangeEnd value here']) }}

此处如何将 动态值传递给 Laravel

中的本地化 JSON 文件

en.json

{ "Welcome to our website, :Name": "Bienvenue sur notre site, :Name" }

ru.json

{ "Welcome to our website, :Name": "Добро пожаловать на наш сайт, :Name" }

blade.php

{{ __('Welcome to our website, :Name', ['name' => 'amanda']) }}