Manual
Author: | LiveWords (profile at wordpress.org) |
WordPress version required: | 4.7.5 |
WordPress version tested: | 4.8.1 |
Plugin version: | 1.0.3 |
Added to WordPress repository: | 26-07-2017 |
Last updated: | 26-07-2017
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 0 |
Rated by: | 0 |
Plugin URI: | http://www.livewords.com/ |
Total downloads: | 678 |
Active installs: | 10+ |
Click to start download |
FAQ
Installation Instructions
Overview
This plugin leverages the functionality of the WPML plugin. WPML is therefore dependent on it.
When the user sends a request for a translation, a request with an xml body is send to Livewords Flow.
`xml
post
1
http://livewords-plugin.local?p=1
translate_posts||translate_taxonomies
en
post
Mon, 03 Apr 2017 13:09:31 +0000
<custom-attributes>
<custom-attribute attribute-id="livewords:target-lang">
<value>nl</value>
<value>de</value>
</custom-attribute>
</custom-attributes>
</livewords:meta>
<wp:post_id>1</wp:post_id>
<wp:post_name><![CDATA[Translatable post name]]></wp:post_name>
<wp:post_type><![CDATA[post]]></wp:post_type>
<wp:postmeta key="key1">
<wp:meta_key><![CDATA[key1]]></wp:meta_key>
<wp:meta_value><![CDATA[Translatable value]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta key="key2">
<wp:meta_key><![CDATA[key2]]></wp:meta_key>
<wp:meta_value><![CDATA[Translatable value]]></wp:meta_value>
</wp:postmeta>
<title>Post title</title>
<content:encoded><![CDATA[Translatable body content]]></content:encoded>
<excerpt:encoded><![CDATA[Translatable excerpt]]></excerpt:encoded>
<wp:post_name><![CDATA[Translatable post name]]></wp:post_name>
<taxonomies>
<![CDATA[List of taxonomies]]>
</taxonomies>
`
This request comprises:
- livewords:meta
- livewords:labels
- livewords:label: The specific post type.
- livewords:id: The ID of the post
- livewords:action: Either ‘translate_posts’ or ‘translate_taxonomies’. The desired action. When the translated item is pushed back, the plugin determines the desired action based on this value.
- livewords:default-language: The WPML selected source language.
- custom-attributes
- custom-attribute attribute-id=”livewords:target-lang”.
- value: A list of target languages. These are the WPML target language by default, but can also be selected for each post by the admin user.
- content:encoded: Translatable content body.
- excerpt:encoded: Translatable excerpt.
- wp:post_name: Translatable name of the post
- wp:postmeta key=”key”: Key value pairs with translatable values. Which keys are sent is configured in the Custom Fields section of the plugin. Since keys are not unique in any way, this is not 100% guaranteed to work: selected key A may mean something else in another post.
After receiving the push back from Livewords Flow, the desired action is derived from the xml. Each post has translated posts as applied by WPML. If there is a translation post for the received target language, that post is updated with the translated content.
If the target post does not exist, the source post is duplicated with the correct language and linked to the source post, after which it is updated with the received translation.
Bulk translations work the same way as single requests, but with more items packed into a single request.
Taxonomies pack a request like
xml
<wp:term>
<wp:term_id><![CDATA[1]]></wp:term_id>
<wp:term_taxonomy><![CDATA[post_tag]]></wp:term_taxonomy>
<wp:term_slug><![CDATA[term-slug]]></wp:term_slug>
<wp:term_parent><![CDATA[]]></wp:term_parent>
<wp:term_name><![CDATA[translatable content]]></wp:term_name>
</wp:term>
Taxonomies can only be sent in bulk.
This plugin does not introduce any new database tables.
InstallationThe plugin is installed by placing the Livewords Flow directory in the /wp-content/plugins/ directory. Activate the plugin in the plugin section when logged into the backend.
Custom fieldsThis query creates a list of custom fields
sql
SELECT * FROM $wpdb->posts P
INNER JOIN $wpdb->postmeta PM ON PM.post_id = P.ID
WHERE PM.meta_key NOT LIKE '\_%'
AND (PM.meta_value IS NOT NULL AND PM.meta_value != '')
AND P.post_status != 'auto-draft'
AND P.post_type != 'revision'
AND P.post_type != 'acf'
GROUP BY PM.meta_value
ORDER BY PM.meta_key
So, every post is considered and inner joined based on post meta. This way, we can filter out meta keys starting with an underscore, null values, posts that are a revision or auto-draft, and posts of the ‘acf’ type, introduced by the popular Advanced Custom Fields plugin.
There are scenarios in which the plugin cannot handle the received translation. In that case, the error is written to system.log (there is no specific error.log), and put in the response body.
Then the system exits, giving a 200 response code, mainly to keep Livewords Flow from trying the same push again.
Post log
Every post has a small log with info on sent and received requests info and a timestamp. The plugin uses update_post_meta for this, so the log is saved with the post as meta data and does not introduce a new database table.
Log file
Have a look in livewords/system.log (in the installation directory) after sending a request for a complete xml structure of both the request and the received translation.
A system.log file is keeping track of all requests sent and received, as well as any errors that have occurred. The file will truncate to 4MB. Here is a list of the various log entries:
* Failed to parse request body: thrown when the plugin is unable to parse the xml.
* No action could be found: thrown when one of the two actions is not found.
* New status of post %s id %s: shows the new post status.
* Starting taxonomies for lang %s: starting translation of taxonomies in language l.
* Target post did not exist. Creating…: printed when the plugin tries to create a new linked post.
* Callback request received: general notice that a push from Livewords Flow has been received.
* Please provide a locale: thrown when push from Livewords Flow did not contain a locale.
* The requested locale ‘%s’ is the same as the default locale: thrown when the target locale is the same as the source locale.
For now, the plugin only supports content that is a post or custom post type, and taxonomies. All other types of content, such as widgets and strings, are currently not supported.