Coder Social home page Coder Social logo

loco-adapter's Introduction

Adapter for Loco

Latest Version Total Downloads

This is an PHP-translation adapter for Loco (Localise.biz).

Install

composer require php-translation/loco-adapter
Symfony bundle

If you want to use the Symfony bundle you may activate it in kernel:

// app/AppKernel.php

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

If you have one Loco project per domain you may configure the bundle like this:

# /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.

If you just doing one project and have tags for all your translation domains you may use this configuration:

# /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']

This will produce a service named php_translation.adapter.loco that could be used in the configuration for the Translation Bundle.

If you need to override the HTTPlug client:

# /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

By default it will use the discovery feature of HTTPlug.

Documentation

Read our documentation at http://php-translation.readthedocs.io.

Contribute

Do you want to make a change? Pull requests are welcome.

loco-adapter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

loco-adapter's Issues

Delete does not really delete

The adapter is using the Translation API to delete translations. This empties the translation message but doesn't delete the asset. Is this the desired behavior? Would it make more sense to use the Asset API?

I will be glad to make a PR if we decide to switch to the Asset API.

$this->client->translations()->delete($project->getApiKey(), $key, $locale);

missing domains or locales

Currently i can configure locales for translation and domains fΓΌr project.
If i configure "fr, "en" and i use "it", it will raise an exception. Project for "%s" domain was not found.
I expected that it will ignore every locale it's not configured for, and the same for domains.

Generate assets ID from source key

Hi !

First of all, thank you for your work !
Context : Today, i started to install php-translation/symfony-bundle and php-translation/loco-adapter on a project where we, as developers, were doing only french translations with .yml files. But for now, we need to focus on i18n. So, we'll use Loco to have a clean UI for future translators.


I wanted to know if there is a way to get assets ID created from source keys with the API of Loco. I didn't found any info. It works using import form on the UI of Loco but there's no option for the API.

I may have missed something. ^^

image

It looks like this #189

Thank you !

Publish Loco adapter on http://symfony.sh/

It would be nice to make the Adapters installable by Symfony Flex. For that we need to move TranslationAdapterLocoBundle to let Flex understands it's a bundle, and add it automatically in bundles.php.

Fuzzy translations are not considered as exportable

Hi !

I've seen that "Fuzzy" translations are not exported.
Should we consider it as normal ? Should we make it as configurable through the Symfony Bundle ?
Depending on environment (development, production, etc.) we would want to keep translations or not if the status changes.

Thank you ! πŸ˜„

Command translation:download downloads translation in xliff format rather than the one already used

In my testing setup I was using yml for storing my translations but the translation:download command downloaded xlf files. Expected behaviour would be to replace the contents of the yml file.

Now, the order of translations - both in yml and xlf format is hard to predict.
I guess that symfony somehow prioritizes xliff files above yml, as xliff is the recommended format.

Let me know if that's an expected behaviour.

An easy fix for that would be to add an option where user can specify desired format.

domains config not working

In the Readme.md is an option which describes to use the domains configuration to use tags for domains. This isn't really an option at the moment (afaik) because tags aren't created from the api.
This results in an issue where translations without tags are created on loco and existing translations are added to wrong/all domains locally when running the translation:sync command.

Considering symfony/http-client instead of Httplug

As we now support Symfony >=5.0, we could migrate from Httplug to symfony/http-client. It will remove an external dependency (if you're using php-translation/symfony-bundle).

Symfony HTTP Client offers same features as Httplug, full support of HTTP protocol, many clients per application by configuration, ...

WDYT @Nyholm @odolbeau?

EDIT: Main discussion will be here, after decision we will open or not issues on other adapters repositories.

Syncing untranslated strings makes them become blank text

  1. I have 8 untranslated headings
  2. I press "Sync selected translations to SaaS"
  3. My translation file is filled with: translation.key: ""
  4. Untranslated strings disappear on the website

I would rather expect these strings to be, by default, the same as the key.
Also, the fallback language will not work in this case.

What is the expected scenario here?

No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation"

Maybe this is a known issue. I use:

php-translation/extractor            1.1.1                     Extract translations form the source code
php-translation/loco-adapter         0.3.1                     Adapter for loco.
php-translation/symfony-bundle       0.3.6
php-translation/symfony-storage      0.2.2                     A translation file storage using Symfony translation component.

Error I get:

[2017-07-14 15:35:51] [hostname:vagrant] [region:pl] [request_id:???] request.INFO: Matched route "php_translation_profiler_translation_edit". {"route":"php_translation_profiler_translation_edit","route_parameters":{"_controller":"Translation\\Bundle\\Controller\\SymfonyProfilerController::editAction","token":"44dfc5","_route":"php_translation_profiler_translation_edit"},"request_uri":"http://web-local.***dev.com/app_dev.php/44dfc5/translation/edit?message_id=plmessagesmeta_keywords","method":"GET"} []
[2017-07-14 15:35:52] [hostname:vagrant] [region:pl] [request_id:???] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-07-14 15:35:53] [hostname:vagrant] [region:pl] [request_id:???] request.CRITICAL: Uncaught PHP Exception Http\Discovery\NotFoundException: "No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter"." at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php line 27 {"exception":"[object] (Http\\Discovery\\NotFoundException(code: 0): No HTTPlug clients found. Make sure to install a package providing \"php-http/client-implementation\". Example: \"php-http/guzzle6-adapter\". at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php:27, Http\\Discovery\\Exception\\DiscoveryFailedException(code: 0): Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors\n - Puli Factory is not available\n\n at /vagrant/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41)"} []
[2017-07-14 15:35:59] [hostname:vagrant] [region:pl] [request_id:???] request.INFO: Matched route "php_translation_profiler_translation_sync". {"route":"php_translation_profiler_translation_sync","route_parameters":{"_controller":"Translation\\Bundle\\Controller\\SymfonyProfilerController::syncAction","token":"44dfc5","_route":"php_translation_profiler_translation_sync"},"request_uri":"http://web-local.***dev.com/app_dev.php/44dfc5/translation/sync","method":"POST"} []
[2017-07-14 15:36:00] [hostname:vagrant] [region:pl] [request_id:???] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-07-14 15:36:00] [hostname:vagrant] [region:pl] [request_id:???] request.CRITICAL: Uncaught PHP Exception Http\Discovery\NotFoundException: "No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter"." at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php line 27 {"exception":"[object] (Http\\Discovery\\NotFoundException(code: 0): No HTTPlug clients found. Make sure to install a package providing \"php-http/client-implementation\". Example: \"php-http/guzzle6-adapter\". at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php:27, Http\\Discovery\\Exception\\DiscoveryFailedException(code: 0): Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors\n - Puli Factory is not available\n\n at /vagrant/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41)"} []
[2017-07-14 15:36:18] [hostname:vagrant] [region:pl] [request_id:???] request.INFO: Matched route "php_translation_profiler_translation_sync". {"route":"php_translation_profiler_translation_sync","route_parameters":{"_controller":"Translation\\Bundle\\Controller\\SymfonyProfilerController::syncAction","token":"44dfc5","_route":"php_translation_profiler_translation_sync"},"request_uri":"http://web-local.***dev.com/app_dev.php/44dfc5/translation/sync","method":"POST"} []
[2017-07-14 15:36:18] [hostname:vagrant] [region:pl] [request_id:???] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-07-14 15:36:18] [hostname:vagrant] [region:pl] [request_id:???] request.CRITICAL: Uncaught PHP Exception Http\Discovery\NotFoundException: "No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter"." at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php line 27 {"exception":"[object] (Http\\Discovery\\NotFoundException(code: 0): No HTTPlug clients found. Make sure to install a package providing \"php-http/client-implementation\". Example: \"php-http/guzzle6-adapter\". at /vagrant/vendor/php-http/discovery/src/HttpClientDiscovery.php:27, Http\\Discovery\\Exception\\DiscoveryFailedException(code: 0): Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors\n - Puli Factory is not available\n\n at /vagrant/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41)"} []

Asset not translated in this locale

Hi,

In HttpApi.php line 187:
Asset not translated in this locale

I have this error when trying to remove obsolete translations.
As far as I understand, the API response is that the translation does not exist and an error is thrown.
There is no reason to throw that error. This is the expected behaviour.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.