Doing i18n wrong
-
Hi,
I just tried to do a bit of translation for WooCommerce… and got stuck.
The place I stumbled upon is https://plugins.trac.wordpress.org/browser/woocommerce/trunk/includes/libraries/action-scheduler/classes/ActionScheduler_WPCLI_QueueRunner.php
Around line 30:
public function __construct( ActionScheduler_Store $store = null, ActionScheduler_FatalErrorMonitor $monitor = null, ActionScheduler_QueueCleaner $cleaner = null ) { if ( ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { throw new Exception( __( 'The ' . __CLASS__ . ' class can only be run within WP CLI.', 'action-scheduler' ) ); }To en English eye this may look normal. But this is impossible to translate into most languages.
You raise two strings for translation here:
“The ” Which in itself, without context means nothing, even when you add a space after it.And: “class can only be run within WP CLI.” But without any indication that a Class name will be injected before it.
Obviously, you need to tie this all together into one phrase that means something. And you know how to do it. Just scroll down to line 137-138, for instance:
/* translators: %s refers to the action ID */ WP_CLI::log( sprintf( __( 'Started processing action %s', 'action-scheduler' ), $action_id ) );This is so much better: a comment to the translator so they’ll know what’s being inserted. And then the whole phrase, so that the German can put their verb towards the end and the Russians can use the right forms of all words.
I hereby officially declare that I’m not ready to translate the short string “The”. Please fix it when you can.
The topic ‘Doing i18n wrong’ is closed to new replies.