message.class.php 4.7 KB
<?php
/**
 * Goodao Translate Automate
 * http://www.Goodao.cn/
 *
 * LICENSE
 *
 * @package    /license/ WP Translate
 * @copyright  Copyright (c) Goodao.cn
 * @license    http://www.Goodao.cn
 * @version    1.1
 * @date       2017-04-14
 */

class PrisnaWPTranslateAutomateMessage {

	private static $_list = array(

		/*
		 * Main Entries
		 */

		'plugin_title' => 'Goodao Translate Automate',

		'general_tab' => 'General',
		'settings_link' => 'Settings',
		
		'plugin_api_key_validate' => 'Invalid API key',
		
		'automate_to_title' => 'Languages',
		'automate_to_description' => 'Selects languages to translate the specified resources below.',
		
		'automate_source_value_sitemap_title' => 'Sitemap URL',
		'automate_source_value_sitemap_description' => 'Specifies the location of the sitemap. If the website doesn\'t currently have a sitemap, there are a number of plugins to create one:<br/><br /><a href="https://wordpress.org/plugins/search.php?q=sitemap" target="_blank">https://wordpress.org/plugins/search.php?q=sitemap</a>',

		'automate_source_value_url_title' => 'URL list',
		'automate_source_value_url_description' => 'Defines a list of the URLs to be automatically translated. One URL per line. URLs can be either absolute or relative path.',
		
		'automate_source_value_category_title' => 'Category',
		'automate_source_value_category_description' => 'Specifies a category to select the resources to translate.',
		
		'automate_retranslate_url_title' => 'Already translated URL behavior',
		'automate_retranslate_url_description' => 'Sets what kind of operation will be performed if a URL has been translated before. If <em>re-translate</em> is selected, then only non translated strings will translated.',
		'automate_retranslate_url_retranslate' => 'Re-translate',
		'automate_retranslate_url_skip' => 'Skip',
		
		'automate_summary' => 'Summary',
		
		'automate_source_title' => 'Resources',
		'automate_source_description' => 'Sets what kind of source will be used identify the list of URLs to translate.',
		'automate_source_sitemap' => 'Sitemap',
		'automate_source_url' => 'URL list',
		'automate_source_category' => 'Category',

		'automate_timeout_title' => 'Timeout',
		'automate_timeout_description' => 'Sets the maximum time a translation can take. After such time, the current resource will be skipped and the process will continue with the next one.',
		
		'automate_next' => 'Next',
		'automate_back' => 'Back',
		'automate_run' => 'Run',
		'automate_stop' => 'Stop',
		'automate_stopping' => 'Stopping',
		'automate_continue' => 'Continue',
		'automate_queued' => 'Queued',
		'automate_processing' => 'Processing',
		'automate_translating' => 'Translating',
		'automate_saving' => 'Saving',
		'automate_done' => 'Done',
		'automate_timed_out' => 'Timed out',
		'automate_loading' => 'Loading',
		'automate_saving_translations_from' => 'Saving translations from',
		'automate_language' => 'Language',
		'automate_resource' => 'Resource',
		'automate_url_behavior' => 'URL behavior',
		'automate_timeout' => 'Timeout',

		'automate_unit_ms' => 'seconds',
		
		'automate_skipped_url' => 'Skipped. This resource has been translated before.',
		'automate_hostname_match_error' => 'Skipped. Host name doesn\'t match: [0] != [1]',
		
		'key_not_found' => '<span style="color: red;">Message for "[0]" not found!</span>'

	);

	public static function getDirect($_key, $_domain=null) {

		if (is_null($_domain))
			$_domain = PrisnaWPTranslateAutomateConfig::getAdminLanguageDomain();
		
		return __($_key, $_domain);
		
	}
	
	public static function genPo() {
		
		foreach (self::$_list as $key => $message)
			if ($message != '') {
				$translated = str_replace('\'', '\\\'', self::get($key, array(), null, true));
				echo "echo _('$translated');\n";
			}
		
	}
	
	public static function get($_key, $_new_values_array=array(), $_domain=null, $_mo=false) {

		if (is_null($_domain))
			$_domain = PrisnaWPTranslateAutomateConfig::getAdminLanguageDomain();

		if (!is_array($_new_values_array))
			$_new_values_array = array($_new_values_array);

		if (array_key_exists($_key, self::$_list))
			$result = is_array(self::$_list[$_key]) ? self::$_list[$_key][0] : self::$_list[$_key];
		else
			$result = PrisnaWPTranslateCommon::mergeText(self::$_list['key_not_found'], $_key);
	
		$result = __($result, $_domain);
	
		if (count($_new_values_array) > 0)
			$result = PrisnaWPTranslateCommon::mergeText($result, $_new_values_array);
		
		// add images
		if (array_key_exists($_key, self::$_list) && is_array(self::$_list[$_key])) {
			$params = self::$_list[$_key];
			$params = array_splice($params, 1);
			$result = PrisnaWPTranslateCommon::mergeImages($result, $params, PRISNA_WP_TRANSLATE_IMAGES . '/admin/');
		}
		
		return $result;
	
	}

}

?>