tbaronnat/translation-bundle

简单的翻译包系统,支持 Symfony 集成

安装: 0

依赖: 0

建议者: 0

安全: 0

星标: 0

分支: 0

类型:symfony-bundle

v2.0.0 2022-11-07 08:10 UTC

This package is not auto-updated.

Last update: 2024-09-26 16:31:52 UTC


README

首先,在主模板中使用 twig 函数来添加特定域的所有翻译

{{ js_translations(app.request.getLocale(), 'messages')|raw }}

然后,要翻译该域中的任何密钥,请使用 JavaScript 函数

在 messages.en.yml 中

message.hello: "Hello %name%"

然后,使用 JavaScript 进行翻译

const params = {"%name%": "Theo"};

let translation = TRANSLATIONS.trans('message.hello', params)

translation = "Hello Theo"