Giter VIP home page Giter VIP logo

entity_xliff_ftp's Introduction

Entity XLIFF FTP Build Status Code Climate Test Coverage Dependency Status

Entity XLIFF FTP is a Drupal extension that introduces a localization workflow whereby editors or administrators can push XLIFF files to a remote server via SFTP, then pull down processed XLIFF files when they're ready (either manually, or automatically on cron).

This extension was designed specifically to work with SDL WorldServer, but can theoretically be used with any FTP server or FTP-enabled translation management system.

Installation

  1. Install this module and its dependency, Composer Manager, via drush: drush dl entity_xliff_ftp composer_manager
  2. Enable Composer Manager: drush en composer_manager
  3. Then enable this module: drush en entity_xliff_ftp
  4. Composer Manager may automatically download and enable requisite PHP libraries, but if not, run drush composer-manager install or drush composer-manager update.

More information on installing and using Composer Manager is available on GitHub.

Configuration

  1. To access configuration pages, grant the "administer entity xliff" permission to all roles appropriate for your site and use-case.
  2. Configure FTP credentials at /admin/config/services/entity-xliff-ftp.
  3. On the same page, configure the "target root path" and the "source root path"
    1. The target root path is the path on the remote FTP server where files will be pushed from Drupal. Within this folder, XLIFF files will be pushed into sub-folders whose naming convention is like so: en_to_de, where en is the source language and de is the target language. Both are the language codes associated with the language in Drupal.
    2. The source root path is the path on the remote FTP server where this module will assume processed or translated XLIFFs are placed. On cron, or when manually triggered through the UI, this module will search this root within sub-folders whose naming convention is like so: de, where de is the target language, also the language code associated with the language in Drupal.

For example

remote-ftp-structure

A remote server set up with a folder structure above would yield the following configurations:

  • Target root path: Clients/Marketing/Drupal/target
  • Source root path: Clients/Marketing/Drupal/source

Usage

Pushing content to the remote server

Entity XLIFF, a dependency of this module, creates an "XLIFF" local task on all entities that are known to be translatable (for example at /node/1/xliff). By default, XLIFF files can be downloaded or uploaded individually for each language.

entity-xliff-ui

This module adds a fieldset to this page called "Remote file sync integration," which shows a select list of target languages. Choose the languages you would like this entity translated into, then press "push to remote server" to upload XLIFF files to your configured remote server.

In the future, this module may introduce Actions and/or Rules integration along with Views Bulk Operations integration to perform the same task on a large number of entities simultaneously.

Pulling translated content from the remote server

This module exposes a simple admin UI that exposes "pending" and "processed" XLIFFs, located at /admin/config/regional/translate/entity-xliff-ftp.

remote-file-sync-ui

Pending projects are sets of XLIFFs representing an entity that are ready on the remote server, but have not yet been pulled into Drupal (meaning, the translated XLIFFs are sitting in the "source root path" on the remote server.

Processed projects are XLIFFs that have recently been pulled into Drupal. This module knows which XLIFFs have already been imported because it moves imported files on the remote server from the configured "source root path" to a sub-directory called "processed."

If you're actively working on a project or need to import a project immediately, you can select pending projects in the aforementioned admin UI and click the "process selected projects" button to run a manual import.

Automation

This module also provides two methods to automate syncing/importing processed XLIFF files from the remote server to Drupal.

On cron: By default, this module will attempt to pull all available XLIFFs from the remote server on cron. If you wish to control how often this task is run, independent of how often you run your Drupal cron task, use a module like Elysia Cron.

Web service call: For more advanced workflows, this module opens up a web service endpoint that can be hit remotely in order to trigger, on an ad-hoc basis, the same process that's triggered on cron. For example, in your translation management system, you could add a workflow action to the end of a process that pings this web service endpoint, immediately pulling in content to Drupal. Endpoint details follow:

POST /sync-xliffs-from-remote?key=[cron_key]

A request body can be sent conditionally to process only a subset of entities and languages that are available on the remote server. It takes the following form:

[{
    "entityType": "node",
    "entityId": 123,
    "languages": [
        "zh-cn",
        "de",
        "ja"
    ]
}, {
    "entityType": "taxonomy_term",
    "entityId": 456,
    "languages": [
        "es"
    ]
}]

Responses:

  • 200 OK: Processing occurred without issue.
  • 400 Bad Request: A request body was provided but formatted incorrectly.
  • 403 Forbidden: Either no key was provided, or the key provided is invalid.
  • 405 Method Not Allowed: The request used an unsupported method. Use POST.
  • 500 Internal Server Error: An error occurred while processing XLIFFs.

Please note

This module and its underlying dependencies are still under active development. Use at your own risk with the intention of finding and filing bugs.

entity_xliff_ftp's People

Contributors

iameap avatar jkopel avatar angrytoast avatar

Watchers

Joel avatar  avatar James Cloos avatar  avatar Thomas Wagner avatar Eric F avatar  avatar  avatar Laud Tetteh avatar Angela Wilson avatar Isaac Cheung avatar Blake L. avatar Shannon Dunn avatar

entity_xliff_ftp's Issues

Better error handling

We've not been doing any exception catching during development, but things are starting to settle down now and we should start preparing the module for production use.

Consequently, we should start catching Entity API exceptions and logging warnings or errors in watchdog / possibly setting message, rather than letting the exception bubble up.


Moved from tableau-mkt-archived/entity_xliff#57
/cc @iamEAP

Explore batching imports

If a large number of files need to be processed at any given time, it's very common for the process to timeout. Rather than performing XLIFF imports synchronously, perhaps it would be better to do them asynchronously or through a batch process.

This might also work around some issues with workbench moderation where some node saves happen at the end of a process, rather than during the initial save.

Support alternate source languages

Eggs'n'Cereal now supports alternate source languages via constructor configuration...Entity XLIFF provides the function entity_xliff_get_serializer().

We should take advantage / add support.

Full support for PHP7

Problem / motivation

We rely on phpseclib to communicate with remote hosts over S/FTP. Unfortunately, we're pinned to an old version of the library which predates composer/packagist support. It also used a deprecated method for declaring a constructor.

If you use this module on PHP7, you will likely see deprecated constructor warnings while using remote server integration features.

Proposed resolution

Pin ourselves to at least v2.0.0 of phpseclib and update all usages of its classes to account for new names/namespacing.

Integrate with Views Bulk Operations

Would be lovely to be able to create a Views Bulk Operations view of translatable entities, check off a few entities, select the desired target languages, and click a button to push all XLIFFs to the remote server.

Update web service endpoint with ability to process only a subset of XLIFFs

Related to #14, another potential optimization is to allow the web service endpoint to take a JSON request body specifying entity types, entity IDs, and languages to be processed.

This could potentially defer the need to batch things until things get very big.

Proposed JSON body format:

An array of entity objects to be processed. Each entity consists of an entityType key (whose value is a string representing the Drupal entity type), an entityID key (whose value is an integer representing the Drupal entity ID), and a languages key (whose value represents an array of Drupal languages).`

POST /sync-xliffs-from-remote?key=[cron_key]
Request Body Example:

[{
    "entityType": "node",
    "entityId": 123,
    "languages": [
        "zh-cn",
        "de",
        "ja"
    ]
}, {
    "entityType": "taxonomy_term",
    "entityId": 456,
    "languages": [
        "es"
    ]
}]

In the above example, 4 XLIFF files would be processed for two entities.

If no body is specified, then the current behavior would continue (processing everything available).

No changes to the response format or response codes.

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.