When using Laravel together with twig, this extension adds support for specific functionality to @miyagi/core.
In your templates, you might want to use translations with dot notation like {{ trans('foo.bar') }}
or {{ trans_choice('foo.bar', 2) }}
.
By using this extension, miyagi
can load the translations from your localization files and use these.
By default the english localilzation files are used, which can be overwritten though.
See Usage for more information.
NOTE: If you need to add additional filters, functions or tags, please refer to the miyagi documentation.
This extension adds mocking to functions like csrf_field
or asset
, so miyagi
does not throw an error when using these in your templates.
npm i --save-dev @miyagi/twig-laravel
or
yarn add -D @miyagi/twig-laravel
Add the extension to your .miyagi.js
like this:
module.exports = {
extensions: [[require('@miyagi/twig-laravel'), {
engine: Twig // optional, only necessary if you extended Twig in your configuration file,
// the `locales` object is optional, the values below are the default values
locales: {
rootFolder: "resources/lang",
lang: "en",
}
}]],
...
}