braunstetter/translated-forms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

braunstetter/translated-forms

Composer 安装命令:

composer require braunstetter/translated-forms

包简介

Translate your forms. Simple and easy.

README 文档

README

Scrutinizer Code Quality Build Status License

This bundle gives you a translated option for your Symfony forms. So when you switch languages your forms are translated and work just fine.

It is assumed that you are using the KNP Doctrine Behaviours for your translations.

Installation

composer require braunstetter/translated-forms

Usage

Once installed this bundle lets you set an option inside your form parameter array:

public function configureOptions(OptionsResolver $resolver): void
{
    $resolver->setDefaults([
        'translated' => true
    ]);
}

When this is set to true your form will react to the current locale inside your request object.

It is important to use Proxy Translations to allow this bundle to read data by a magic method.

Why should you use this bundle?

There is the popular a2lix/translation-form-bundle. It is actively maintained and if you like it - you can stick to it.

But to use a2lix/translation-form-bundle there is some CSS and Javascript required. Also, it comes with a dedicated FormType. So you have to wrap every field inside this FormType. It provides these clickable tabs for every single translated field, which is not so handy, when you just want to translate your whole form.

braunstetter/translated-forms will just work fine with all your Symfony forms. No extra CSS no Javascript no extra FormType to implement. Your forms stay the same. Just switch the languages and even nested forms are translated.

Custom Traits

Knp Doctrine Behaviours brings some Traits to your translatable Entities and your translations.

By default, it assumes you put the translation Entity into the same folder as the translatable. This gets quite messy, as soon as you translate a lot.

So braunstetter/translated-forms bundle delivers two traits. TranslatableTrait and TranslationTrait.

They work just the same way as the default one's form KNP (in fact they use it under the hood), but they put translations into a Translation folder - and they implement the magic __call method which is required for this bundle to translate your forms.

How does this magic happen?

Reading the data (mapDataToForms)

If enabled this bundle sets a new data mapper to your forms.

The default data mapper of the Symfony form component does not work with magic properties - the data mapper of this bundle does.

Writing the data (mapFormsToData)

When data of a form is going to be saved - this data mapper tries to save it the normal way.

If the field of the base entity is not writeable directly it is going to pick the current translation and is writing it into it.

braunstetter/translated-forms 适用场景与选型建议

braunstetter/translated-forms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 286 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 04 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「form」 「translate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 braunstetter/translated-forms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 braunstetter/translated-forms 我们能提供哪些服务?
定制开发 / 二次开发

基于 braunstetter/translated-forms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 286
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-04-25