Setup Advanced Logger Configuration
To prevent all messages below a certain level to be logged, a special logger name default is available. The following is an example logger configuration to use to avoid all messages in the logs up to emergency level:
emergency:
- default
Configure External Logger
The Smartling Connector can be extended through actions and filters, but also by modifying its configuration. This approach is useful, for example, if you want to write logs to a database or network, or add support for your Custom Post Type (CPT). This requires Smartling Connector v 1.1.11 and newer.
- Create a folder under wp-content/plugins/.
- For example:
mkdir wp-content/plugins/smartling-external-logger
- For example:
- Download this demo file to the folder: smartling-external-logger.php.
- On WordPress, select My Sites > Network Admin > Plugins (
/wp-admin/network/plugins.php?plugin_status=all
) - Click the Network Activate link below Smartling Logger Extender.
- Check the log file to view results.
$ tail -f /var/www/html/wp-content/plugins/smartling-connector/logs/error-logfile
error-logfile[2016-06-30 12:42:13] 577513a520fac ERROR: Test error message at 12:42:13pm
[2016-06-30 12:42:26] 577513b2204f5 ERROR: Test error message at 12:42:26pm
[2016-06-30 12:43:29] 577513f1b14b5 ERROR: Test error message at 12:43:29pm
How to Rewrite URLs in Content
When using the standard configuration of the WordPress Connector, URLs that are embedded in captured content are not localized. Examples:
Click <a href ="http://www.website.com/">here</a>.
Click <a href="/other/page/">there</a>.
You can implement custom rules to change how URLs are handled. For example, you might want to localize a URL as shown below.
Source String | Target String |
... /somewhere/hello-en-US.pdf ... |
... /somewhere/hello-de-DE.pdf ... |
When you install this sample plugin into WordPress, all valid URLs ending with "en-US.pdf" will be changed to end with "target-language-code.pdf" when the connector applies the translated content to posts or pages.
Sample plug-in: url-rewrite-example.php
See example results in the table below.
Source Strings | Target Strings |
<a href="/somewhere/hello-en-US.pdf"> click here </a> |
<a href="/somewhere/hello-de-DE.pdf"> click here </a> |
a href="/somewhere/wrong-hello-en-US.pdf" |
a href="/somewhere/wrong-hello-en-US.pdf" |
<a href="/undefinedwhere/nohello-en-US.pdf"> click here </a> |
<a href="/undefinedwhere/nohello-de-DE.pdf"> click here </a> |
href="/one-more-wrong-hello.pdf" |
href="/one-more-wrong-hello.pdf" |
/one-more-wrong-hello.pdf |
/one-more-wrong-hello.pdf |
<a href="/undefinedwhere/no-en-US.pdf"> click here </a> |
<a href="/undefinedwhere/no-de-DE.pdf"> click here </a> |