afragen/translations-updater

该框架为您提供了从公共仓库自动解耦WordPress插件或主题的语言包更新的功能。

dev-develop 2020-06-24 02:11 UTC

This package is auto-updated.

Last update: 2024-09-24 10:57:11 UTC


README

描述

此框架允许对托管在GitHub、Bitbucket、GitLab或Gitea上的公共仓库中的WordPress插件或主题进行解耦语言包更新。

URI应指向包含翻译文件的仓库。请参考GitHub Updater Translations作为示例。它使用Language Pack Maker创建。该仓库必须是公开的。

用法

通过Composer安装: composer require afragen/translations-updater:dev-master

发布前使用以下命令 composer require afragen/translations-updater:dev-<branch> 目前为 dev-master

require_once __DIR__ . '/vendor/autoload.php'; 添加到主插件文件或主题的functions.php文件中。

需要一个以下格式的配置数组。所有数组元素都是必需的。

add_action( 'admin_init', function() {
	$config = [
		'git'       => '(github|bitbucket|gitlab|gitea)',
		'type'      => '(plugin|theme)',
		'slug'      => 'my-repo-slug',
		'version'   => 'my-repo-version', // Current version of plugin|theme.
		'languages' => 'https://my-path-to/language-packs',
	];

	( new \Fragen\Translations_Updater\Init() )->run( $config );
} );

如果您想删除与此框架关联的选项表中存储的数据,您需要执行以下命令。

( new \Fragen\Translations_Updater\Init() )->delete_cached_data();

EDD软件许可使用

如果您使用此框架与EDD软件许可一起使用,您需要更新到EDD软件许可示例代码中更新器的最新版本,以确保存在适当的行为钩子。

您需要在设置数组中添加两个类似以下的关键/值对,

'git'       => 'github',
'languages' => 'https://github.com/<USER>/my-language-pack',

您需要将以下命令包含到引导文件中以激活更新器。

( new \Fragen\Translations_Updater\Init( __NAMESPACE__ ) )->edd_run();

插件

您必须在您的 EDD_SL_Plugin_Updater 设置中添加两个额外的键/值对到设置数组。该数组将从 edd-sample-plugin.php 文件中的类似以下内容。

	$edd_updater = new EDD_SL_Plugin_Updater( EDD_SAMPLE_STORE_URL, __FILE__, array(
			'version'   => '1.0',                // current version number
			'license'   => $license_key,         // license key (used get_option above to retrieve from DB)
			'item_name' => EDD_SAMPLE_ITEM_NAME, // name of this plugin
			'author'    => 'Pippin Williamson',  // author of this plugin
			'beta'      => false,
			'git'       => 'bitbucket',
			'languages' => 'https://bitbucket.org/afragen/test-language-pack',
		)

主题

您必须在您的 EDD_Theme_Updater_Admin 设置中添加两个额外的键/值对到设置数组。该数组将从 edd-sample-theme/updater/theme-updater.php 文件中的类似以下内容。

$updater = new EDD_Theme_Updater_Admin(

	// Config settings
	$config = array(
		'remote_api_url' => 'https://easydigitaldownloads.com', // Site where EDD is hosted
		'item_name'      => 'Theme Name', // Name of theme
		'theme_slug'     => 'theme-slug', // Theme slug
		'version'        => '1.0.0', // The current version of this theme
		'author'         => 'Easy Digital Downloads', // The author of this theme
		'download_id'    => '', // Optional, used for generating a license renewal link
		'renew_url'      => '', // Optional, allows for a custom license renewal link
		'beta'           => false, // Optional, set to true to opt into beta versions
		'git'            => 'github',
		'languages'      => 'https://github.com/<USER>/my-language-pack',
	),
	...