php-translation/loco-adapter

0.11.2 2022-07-18 15:18 UTC

This package is auto-updated.

Last update: 2024-09-18 20:14:44 UTC


README

Latest Version Total Downloads

这是PHP-translation适配Loco(Localise.biz)的一个适配器。

安装

composer require php-translation/loco-adapter
Symfony包

如果您想使用Symfony包,可以在kernel中激活它

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Translation\PlatformAdapter\Loco\Bridge\Symfony\TranslationAdapterLocoBundle(),
    );
}

如果您每个域有一个Loco项目,可以这样配置包

# /app/config/config.yml
translation_adapter_loco:
  index_parameter: 'id' # 'text' or 'name'. Leave blank for "auto"  See https://localise.biz/api/docs/export/exportlocale
  projects:
    messages:
      api_key: 'foobar'
    navigation:
      api_key: 'bazbar'
      status: '!untranslated,!rejected' # if you want filter on loco translations statuses. By default only 'translated' translations are pulled.

如果您只有一个项目并且所有翻译域都有标记,可以使用此配置

# /app/config/config.yml
translation_adapter_loco:
  index_parameter: 'id' # 'text' or 'name'. Leave blank for "auto"  See https://localise.biz/api/docs/export/exportlocale
  projects:
    acme:
      api_key: 'foobar'
      domains: ['messages', 'navigation']

这将产生一个名为php_translation.adapter.loco的服务,该服务可用于Translation Bundle的配置中。

如果需要覆盖HTTPlug客户端

# /app/config/config.yml
translation_adapter_loco:
  httplug_client: httplug.client.loco
  # You can even customize the message and uri factory
  # httplug_message_factory: null
  # httplug_uri_factory: null

httplug:
  clients:
    loco:
      factory: 'httplug.factory.guzzle6'
      plugins:
        - httplug.plugin.content_length
        - httplug.plugin.logger
      config:
        timeout: 2

默认情况下,它将使用HTTPlug的发现功能。

文档

请参阅我们的文档:http://php-translation.readthedocs.io.

贡献

您想要做出更改吗?欢迎提交拉取请求。