localization

This commit is contained in:
Pau Capó 2017-03-15 13:14:35 +01:00
parent 67981c517d
commit 40513e3169
8 changed files with 337 additions and 29 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*~

View file

@ -36,7 +36,7 @@ class Gitea_Options {
function options_post() { function options_post() {
if (isset($_GET['force-check'])) { if (isset($_GET['force-check'])) {
Gitea_Updater::getInstance()->get_gitea_all(); Gitea_Updater::getInstance()->get_all();
set_site_transient('update_plugins', null); set_site_transient('update_plugins', null);
set_site_transient('update_themes', null); set_site_transient('update_themes', null);
} }
@ -69,8 +69,6 @@ class Gitea_Options {
</div> </div>
<?php else : ?> <?php else : ?>
<a href="#" id="show-tokens" class="dashicons dashicons-visibility"></a>
<form action="<?=admin_url('options-general.php?page=gitea-updater')?>" method="post" class="box access"> <form action="<?=admin_url('options-general.php?page=gitea-updater')?>" method="post" class="box access">
<div class="title"> <div class="title">
@ -149,7 +147,7 @@ class Gitea_Options {
<label><?=__('Repository URL', 'gitea')?></label> <label><?=__('Repository URL', 'gitea')?></label>
</th> </th>
<td> <td>
<input type="text" name="gitea_install[url]" placeholder="https://host/org/repo or https://host/org/repo.git"> <input type="text" name="gitea_install[url]" placeholder="<?=__('https://host/org/repo or https://host/org/repo.git', 'gitea')?>">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -174,8 +172,9 @@ class Gitea_Options {
</div> </div>
<div class="times"> <div class="times">
plugins: <?=date('d/m/Y H:i:s', get_option('gitea_plugins_updated'))?> <?=__('Plugins', 'gitea')?>: <?=date('d/m/Y H:i:s', get_option('gitea_plugins_updated'))?>
themes: <?=date('d/m/Y H:i:s', get_option('gitea_themes_updated'))?> <br>
<?=__('Themes', 'gitea')?>: <?=date('d/m/Y H:i:s', get_option('gitea_themes_updated'))?>
</div> </div>
<?php /* <textarea style="width:100%" rows="2" onfocus="this.rows=30;" onblur="this.rows=2;" readonly><?php var_dump($repositories); ?></textarea> */ ?> <?php /* <textarea style="width:100%" rows="2" onfocus="this.rows=30;" onblur="this.rows=2;" readonly><?php var_dump($repositories); ?></textarea> */ ?>
@ -213,7 +212,7 @@ class Gitea_Options {
$repo = str_replace('.git', '', trim($url['path'], '/')); $repo = str_replace('.git', '', trim($url['path'], '/'));
$updater = Gitea_Updater::getInstance(); $updater = Gitea_Updater::getInstance();
$package = $updater->get_gitea_url($host, $repo, '/archive/master.zip', $data['access_token']); $package = $updater->get_url($host, $repo, '/archive/master.zip', $data['access_token']);
if ($data['type'] == 'plugin') { if ($data['type'] == 'plugin') {

View file

@ -6,6 +6,7 @@ Description: Plugins updater
Version: 0.1.1 Version: 0.1.1
Author: Pau Capó Author: Pau Capó
Author URI: http://www.paucapo.com Author URI: http://www.paucapo.com
Text Domain: gitea
Gitea Host: https://git.paucapo.com Gitea Host: https://git.paucapo.com
Gitea URI: wp/gitea-updater Gitea URI: wp/gitea-updater
*/ */
@ -40,6 +41,8 @@ class Gitea_Updater {
function __construct() { function __construct() {
add_action('plugins_loaded', array($this, 'plugins_loaded'));
Gitea_Options::getInstance(); Gitea_Options::getInstance();
// plugins checks // plugins checks
@ -55,12 +58,16 @@ class Gitea_Updater {
} }
function get_gitea_all() { function plugins_loaded() {
$this->get_gitea_plugins(); load_plugin_textdomain('gitea', FALSE, basename( dirname( __FILE__ ) ) . '/languages/');
$this->get_gitea_themes();
} }
function get_gitea_plugins() { function get_all() {
$this->get_plugins();
$this->get_themes();
}
function get_plugins() {
$this->plugins = array(); $this->plugins = array();
$plugins = get_plugins(); $plugins = get_plugins();
@ -72,13 +79,13 @@ class Gitea_Updater {
$slug = trim(dirname($plugin_slug), '/'); $slug = trim(dirname($plugin_slug), '/');
$file = basename($plugin_slug); $file = basename($plugin_slug);
$host = $this->get_gitea_host($plugin['Gitea Host']); $host = $this->get_host($plugin['Gitea Host']);
$repo = $plugin['Gitea URI']; $repo = $plugin['Gitea URI'];
$local_version = strtolower($plugin['Version']); $local_version = strtolower($plugin['Version']);
$url = $this->get_gitea_url($host, $repo, '/raw/master/'.$file); $url = $this->get_url($host, $repo, '/raw/master/'.$file);
if ($url != false) { if ($url != false) {
$new_version = $this->get_gitea_version($url, 'plugin'); $new_version = $this->get_version($url, 'plugin');
$new_version = $new_version ? $new_version : $local_version; $new_version = $new_version ? $new_version : $local_version;
} }
@ -96,7 +103,7 @@ class Gitea_Updater {
'url' => $host.$repo, 'url' => $host.$repo,
'local_version' => $local_version, 'local_version' => $local_version,
'new_version' => $new_version, 'new_version' => $new_version,
'package' => $this->get_gitea_url($host, $repo, '/archive/master.zip'), 'package' => $this->get_url($host, $repo, '/archive/master.zip'),
); );
$this->plugins[$slug] = $gitea; $this->plugins[$slug] = $gitea;
@ -109,7 +116,7 @@ class Gitea_Updater {
} }
function get_gitea_themes() { function get_themes() {
$this->themes = array(); $this->themes = array();
$themes = wp_get_themes(); $themes = wp_get_themes();
@ -120,13 +127,13 @@ class Gitea_Updater {
// this is a gitea theme // this is a gitea theme
$slug = $theme->stylesheet; $slug = $theme->stylesheet;
$host = $this->get_gitea_host($theme->get('Gitea Host')); $host = $this->get_host($theme->get('Gitea Host'));
$repo = $theme->get('Gitea URI'); $repo = $theme->get('Gitea URI');
$local_version = strtolower($theme->get('Version')); $local_version = strtolower($theme->get('Version'));
$url = $this->get_gitea_url($host, $repo, '/raw/master/style.css'); $url = $this->get_url($host, $repo, '/raw/master/style.css');
if ($url != false) { if ($url != false) {
$new_version = $this->get_gitea_version($url, 'plugin'); $new_version = $this->get_version($url, 'plugin');
$new_version = $new_version ? $new_version : $local_version; $new_version = $new_version ? $new_version : $local_version;
} }
@ -143,7 +150,7 @@ class Gitea_Updater {
'url' => $theme->get('AuthorURI'),//$host.$repo, 'url' => $theme->get('AuthorURI'),//$host.$repo,
'local_version' => $local_version, 'local_version' => $local_version,
'new_version' => $new_version, 'new_version' => $new_version,
'package' => $this->get_gitea_url($host, $repo, '/archive/master.zip'), 'package' => $this->get_url($host, $repo, '/archive/master.zip'),
); );
$this->themes[$slug] = $gitea; $this->themes[$slug] = $gitea;
@ -156,11 +163,11 @@ class Gitea_Updater {
} }
function get_gitea_host($host) { function get_host($host) {
return rtrim($host, '/').'/'; return rtrim($host, '/').'/';
} }
function get_gitea_token($host, $repo) { function get_token($host, $repo) {
$options = Gitea_Options::get(); $options = Gitea_Options::get();
$token = ''; $token = '';
@ -176,17 +183,17 @@ class Gitea_Updater {
return !empty($token) ? $token : false; return !empty($token) ? $token : false;
} }
function get_gitea_url($host, $repo, $args = '', $access_token = false) { function get_url($host, $repo, $args = '', $access_token = false) {
if ($access_token === false) { if ($access_token === false) {
$access_token = $this->get_gitea_token($host, $repo); $access_token = $this->get_token($host, $repo);
if (!$access_token) return false; if (!$access_token) return false;
} }
return $host.'api/v1/repos/'.$repo.$args.'?access_token='.$access_token; return $host.'api/v1/repos/'.$repo.$args.'?access_token='.$access_token;
} }
function get_gitea_file($url) { function get_file($url) {
$request = wp_remote_get($url); $request = wp_remote_get($url);
if (is_wp_error($request) || 200 != wp_remote_retrieve_response_code($request)) { if (is_wp_error($request) || 200 != wp_remote_retrieve_response_code($request)) {
@ -197,9 +204,9 @@ class Gitea_Updater {
return $request; return $request;
} }
function get_gitea_version($url, $type) { function get_version($url, $type) {
$request = $this->get_gitea_file($url); $request = $this->get_file($url);
if (!$request) return false; if (!$request) return false;
@ -236,7 +243,7 @@ class Gitea_Updater {
function pre_set_site_transient_update_plugins($transient) { function pre_set_site_transient_update_plugins($transient) {
// check if some plugin needs update // check if some plugin needs update
$this->get_gitea_plugins(); $this->get_plugins();
foreach ($this->plugins as $plugin => $git_plugin) { foreach ($this->plugins as $plugin => $git_plugin) {
@ -254,7 +261,7 @@ class Gitea_Updater {
function pre_set_site_transient_update_themes($transient) { function pre_set_site_transient_update_themes($transient) {
// check if some theme needs update // check if some theme needs update
$this->get_gitea_themes(); $this->get_themes();
foreach ($this->themes as $theme => $git_theme) { foreach ($this->themes as $theme => $git_theme) {

BIN
languages/gitea-ca.mo Normal file

Binary file not shown.

100
languages/gitea-ca.po Normal file
View file

@ -0,0 +1,100 @@
msgid ""
msgstr ""
"Project-Id-Version: Gitea Updater\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-15 12:02+0000\n"
"PO-Revision-Date: 2017-03-15 12:10+0000\n"
"Last-Translator: Pau Capó <pau.capo@gmail.com>\n"
"Language-Team: Catalan\n"
"Language: ca\n"
"Plural-Forms: nplurals=2; plural=n != 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco - https://localise.biz/"
#: gitea-options.php:78
msgid ""
"The access token from a repository always have priority over the global."
msgstr "El token d'accés d'un repositori sempre té prioritat envers el global."
#: gitea-options.php:131
msgid ""
"Only with <code>http://</code> or <code>https://</code> links, It's not "
"working with <code>ssh://</code> links!"
msgstr ""
"Només enllaços <code>http://</code> o <code>https://</code>, Els enllaços "
"<code>ssh://</code> no funcionen!"
#: gitea-options.php:140
msgid "Plugins"
msgstr "Extensions"
#: gitea-options.php:141
msgid "Themes"
msgstr "Temes"
#. Author of the plugin
msgid "Pau Capó"
msgstr "Pau Capó"
#: gitea-options.php:64
msgid "Install Results"
msgstr "Resultats de la instal·lació"
#: gitea-options.php:75
msgid "Access Tokens"
msgstr "Tokens d'accés"
#: gitea-options.php:90
msgid "Global Access Token"
msgstr "Token d'accés global"
#: gitea-options.php:103 gitea-options.php:155
msgid "Access Token"
msgstr "Token d'accés"
#: gitea-options.php:117
msgid "Save Changes"
msgstr "Guarda els canvis"
#: gitea-options.php:118
msgid "Reset Cache"
msgstr "Reinicia cache"
#: gitea-options.php:127
msgid "Install from URL"
msgstr "Instal·la de URL"
#: gitea-options.php:136
msgid "Type"
msgstr "Tipus"
#: gitea-options.php:147
msgid "Repository URL"
msgstr "URL del repositori"
#: gitea-options.php:150
msgid "https://host/org/repo or https://host/org/repo.git"
msgstr "https://host/org/repo o https://host/org/repo.git"
#: gitea-options.php:164
msgid "Install Now"
msgstr "Instal·la"
#: gitea-options.php:240
msgid "Return"
msgstr "Torna"
#. Name of the plugin
msgid "Gitea Updater"
msgstr "Gitea Updater"
#. Description of the plugin
msgid "Plugins updater"
msgstr "Plugins updater"
#. URI of the plugin
#. Author URI of the plugin
msgid "http://www.paucapo.com"
msgstr "http://www.paucapo.com"

BIN
languages/gitea-es_ES.mo Normal file

Binary file not shown.

102
languages/gitea-es_ES.po Normal file
View file

@ -0,0 +1,102 @@
msgid ""
msgstr ""
"Project-Id-Version: Gitea Updater\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-15 12:02+0000\n"
"PO-Revision-Date: 2017-03-15 12:05+0000\n"
"Last-Translator: Pau Capó <pau.capo@gmail.com>\n"
"Language-Team: Spanish (Spain)\n"
"Language: es-ES\n"
"Plural-Forms: nplurals=2; plural=n != 1\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco - https://localise.biz/"
#. Name of the plugin
msgid "Gitea Updater"
msgstr "Gitea Updater"
#. Description of the plugin
msgid "Plugins updater"
msgstr "Plugins updater"
#. URI of the plugin
#. Author URI of the plugin
msgid "http://www.paucapo.com"
msgstr "http://www.paucapo.com"
#. Author of the plugin
msgid "Pau Capó"
msgstr "Pau Capó"
#: gitea-options.php:150
msgid "https://host/org/repo or https://host/org/repo.git"
msgstr "https://host/org/repo o https://host/org/repo.git"
#: gitea-options.php:64
msgid "Install Results"
msgstr "Resultados de la instalación"
#: gitea-options.php:75
msgid "Access Tokens"
msgstr "Tokens de acceso"
#: gitea-options.php:78
msgid ""
"The access token from a repository always have priority over the global."
msgstr ""
"El token de acceso de un repositorio siempre tiene prioridad por encima del "
"global."
#: gitea-options.php:90
msgid "Global Access Token"
msgstr "Token de acceso global"
#: gitea-options.php:103 gitea-options.php:155
msgid "Access Token"
msgstr "Token de acceso"
#: gitea-options.php:117
msgid "Save Changes"
msgstr "Guardar cambios"
#: gitea-options.php:118
msgid "Reset Cache"
msgstr "Reiniciar cache"
#: gitea-options.php:127
msgid "Install from URL"
msgstr "Instalar de URL"
#: gitea-options.php:131
msgid ""
"Only with <code>http://</code> or <code>https://</code> links, It's not "
"working with <code>ssh://</code> links!"
msgstr ""
"Solo enlaces <code>http://</code> o <code>https://</code>, no funciona con "
"enlaces <code>ssh://</code>!"
#: gitea-options.php:136
msgid "Type"
msgstr "Tipo"
#: gitea-options.php:140
msgid "Plugins"
msgstr "Plugins"
#: gitea-options.php:141
msgid "Themes"
msgstr "Temas"
#: gitea-options.php:147
msgid "Repository URL"
msgstr "URL del repositorio"
#: gitea-options.php:164
msgid "Install Now"
msgstr "Instalar"
#: gitea-options.php:240
msgid "Return"
msgstr "Volver"

99
languages/gitea.pot Normal file
View file

@ -0,0 +1,99 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-03-15 12:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
"Language: \n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco - https://localise.biz/"
#: gitea-options.php:64
msgid "Install Results"
msgstr ""
#: gitea-options.php:75
msgid "Access Tokens"
msgstr ""
#: gitea-options.php:78
msgid ""
"The access token from a repository always have priority over the global."
msgstr ""
#: gitea-options.php:90
msgid "Global Access Token"
msgstr ""
#: gitea-options.php:103 gitea-options.php:155
msgid "Access Token"
msgstr ""
#: gitea-options.php:117
msgid "Save Changes"
msgstr ""
#: gitea-options.php:118
msgid "Reset Cache"
msgstr ""
#: gitea-options.php:127
msgid "Install from URL"
msgstr ""
#: gitea-options.php:131
msgid ""
"Only with <code>http://</code> or <code>https://</code> links, It's not "
"working with <code>ssh://</code> links!"
msgstr ""
#: gitea-options.php:136
msgid "Type"
msgstr ""
#: gitea-options.php:140
msgid "Plugins"
msgstr ""
#: gitea-options.php:141
msgid "Themes"
msgstr ""
#: gitea-options.php:147
msgid "Repository URL"
msgstr ""
#: gitea-options.php:150
msgid "https://host/org/repo or https://host/org/repo.git"
msgstr ""
#: gitea-options.php:164
msgid "Install Now"
msgstr ""
#: gitea-options.php:240
msgid "Return"
msgstr ""
#. Name of the plugin
msgid "Gitea Updater"
msgstr ""
#. Description of the plugin
msgid "Plugins updater"
msgstr ""
#. URI of the plugin
#. Author URI of the plugin
msgid "http://www.paucapo.com"
msgstr ""
#. Author of the plugin
msgid "Pau Capó"
msgstr ""