Laravel 中 i18n t() 函数的等价函数是什么?

What's the equivalent function of i18n t() function in Laravel?

i18next中,人们将t()函数定义为翻译实用程序,vue有vue-i18n,react i18n也有​​这样的东西。

我的问题来了,Laravel中等效的t()函数是什么?

在 Laravel 中,您可以使用 __ 辅助函数。

根据 Laravel 文档:

You may retrieve lines from language files using the __ helper function. The __ method accepts the file and key of the translation string as its first argument. For example, let's retrieve the welcome translation string from the resources/lang/messages.php language file:

echo __('messages.welcome');

echo __('I love programming.');

If you are using the Blade templating engine, you may use the {{ }} syntax to echo the translation string or use the @lang directive:

{{ __('messages.welcome') }}

@lang('messages.welcome')

参考: Laravel -> Localization -> Retrieving Translation Strings

trans('messages.welcome')trans_choice('messages.apples', 10)@lang('messages.welcome')

TO 在 blade 中显示,将那些在 {{ }} 中显示,如 {{ trans('messages.welcome') }}

要在 blade 中显示其中包含的 html 使用 {!! !!} 就像 {!! trans('messages.welcome') !!}

https://laravel.com/docs/master/localization

https://laravel.com/docs/master/localization#pluralization

https://laravel.com/docs/master/localization#retrieving-translation-strings