承接 wickedone/phrase-translation-provider 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wickedone/phrase-translation-provider

Composer 安装命令:

composer require wickedone/phrase-translation-provider

包简介

symfony phrase translation provider bridge

README 文档

README

symfony phrase translation provider bridge

infection codecov stable downloads license php

⚠️ this translation provider has been integrated into symfony starting at version 6.4. this repository will be archived once lts expires for symfony 5.4

installation

composer require wickedone/phrase-translation-provider

dsn example

PHRASE_DSN=phrase://PROJECT_ID:API_TOKEN@default?userAgent=myProject

dsn elements

  • PROJECT_ID: can be retrieved in phrase from project settings > API > Project ID
  • API_TOKEN: can be created in your phrase profile settings
  • default: endpoint, defaults to api.phrase.com

required dsn query parameters

  • userAgent: please read this for some examples.

see fine tuning your phrase api calls for additional dsn options

service phrase provider

in your services.yaml add the following to enable the phrase provider.

Symfony\Component\Translation\Bridge\Phrase\PhraseProviderFactory:
    tags: ['translation.provider_factory']
    arguments:
        $defaultLocale: '%kernel.default_locale%'
        $loader: '@translation.loader.xliff'
        $xliffFileDumper: '@translation.dumper.xliff'
        $cache: '@cache.app'

and in your translations.yaml you can add:

framework:
    translator:
        providers:
            phrase:
                dsn: '%env(PHRASE_DSN)%'
                domains: ~
                locales: ~

phrase locale names

translations being imported using the symfony xlf format in phrase, locales are matched on locale name in phrase. therefor it's necessary the locale names should be as defined in RFC4646 (e.g. pt-BR rather than pt_BR). not doing so will result in phrase creating a new locale for the imported keys.

locale creation

if you define a locale in your translation.yaml which is not configured in your phrase project, it will be automatically created. deletion of locales however, is (currently) not managed by this provider.

domains as tags

translations will be tagged in phrase with the symfony translation domain they belong to. check the wickedone/phrase-tag-bundle if you need help managing your tags in phrase

cache

the read responses from phrase are cached to speed up the read and delete method of this provider. therefor the factory should be initialised with a PSR-6 compatible cache adapter.

events

to enable you to perform post-processing on translation values and / or keys, two events are dispatched by this provider class.

PhraseReadEvent

after reading the catalogue from phrase, the resulting TranslatorBag is dispatched in a PhraseReadEvent prior to being returned from the read method.

PhraseWriteEvent

before writing the catalogue to phrase, the TranslatorBag is dispatched in a PhraseWriteEvent.

fine tuning your phrase api calls

you can fine tune the read and write methods of this provider by adding query parameters to your dsn configuration. general usage is read|write[option_name]=value

example: phrase://PROJECT_ID:API_TOKEN@default?read[encoding]=UTF-8&write[update_descriptions]=0

see tables below for available options and, if applicable, their default values.

read

in order to read translations from phrase the download locale call is made to the phrase api. this call provides the following options.

name type default value comment
branch string
include_empty_translations bool 1
exclude_empty_zero_forms bool
include_translated_keys bool
keep_notranslate_tags bool
format_options array enclose_in_cdata
encoding string
skip_unverified_translations bool
include_unverified_translations bool
use_last_reviewed_version bool
fallback_locale_enabled bool 0 when the fallback locale is enabled, caching responses from phrase will be disabled

write

in order to write translations to phrase the upload call is made to the phrase api. this call provides the following options.

name type default value comment
update_translations bool 1
update_descriptions bool
skip_upload_tags bool
skip_unverification bool
file_encoding string
locale_mapping array
format_options array
autotranslate bool
mark_reviewed bool

wickedone/phrase-translation-provider 适用场景与选型建议

wickedone/phrase-translation-provider 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.44k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 wickedone/phrase-translation-provider 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-28