include .mo file

This commit is contained in:
Tilman Kranz 2021-11-28 00:47:07 +01:00
parent 1c00192836
commit c543ac72dd
4 changed files with 47 additions and 30 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
lang/*.mo

Binary file not shown.

View File

@ -22,8 +22,8 @@ msgid "http://tk-sls.de/ref/gitlab-list-commits"
msgstr "http://tk-sls.de/ref/gitlab-list-commits"
#. Description of the plugin
msgid "Summary: Embed list of most recent commits to a Gitlab project from a Gitlab instance's public REST API. Example: Add [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 since=\"3 month\" max=5] for a list of at most 5 commits to that project that were made since at most 3 months ago."
msgstr "Zusammenfassung: Bette Liste der neuesten Commits eines Gitlab-Projektes ein, die mit Gitlabs REST API abgerufen wird. Beispiel: Füge folgenden Shortcode zu einem Artikel hinzu, um die letzten 5 Commits anzuzeigen, die nicht älter als 3 Monate sind: [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 since=\"3 month\" max=5]"
msgid "Summary: Embed list of most recent commits to a Gitlab project from a Gitlab instance's public REST API. Example: Add [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 commits=\"all\" since=\"3 month\" max=5 releases=\"latest\"] for a list of at most 5 commits to that project that were made since at most 3 months ago, followed by alink to the latest release of the project (if any). To disable the list of commits, set commits=\"none\". To generate a list of all releases, set releases=\"all\". To disable the list of releases, omit the \"releases\" attribute or set releases=\"none\"."
msgstr "Zusammenfassung: Bette Liste der neuesten Commits eines Gitlab-Projektes ein, die mit Gitlabs REST API abgerufen wird. Beispiel: Füge folgenden Shortcode zu einem Artikel hinzu, um die letzten 5 Commits anzuzeigen, die nicht älter als 3 Monate sind: [gitlab-list-commits url=https://tk-sls.de/gitlab project_id=42 since=\"3 month\" max=5]. Um die Liste der Commits zu deaktivieren: commits=\"none\". Um eine Liste von Releases hinzuzufügen: releases=\"all\". Um nur die neueste Release anzuzeigen: releases=\"latest\"."
#. Author of the plugin
msgid "Tilman Kranz"

View File

@ -47,6 +47,43 @@ class LinuxfooGitlab {
return sprintf(__('since %d %s ago', 'linuxfoo-gitlab'), $num, $unit);
}
static function format_commit($atts, $commit) {
$out = '';
preg_match('/^....-..-../', $commit->committed_date, $m);
$date = $m[0];
$title = htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE);
$out .=
$date.' '.
__('by', 'linuxfoo-gitlab').' '.$commit->author_name.
': '.
'<a href="'.$commit->web_url.'">'.$commit->short_id.'</a> '.$title;
return $out;
}
static function format_commit_stats($atts, $commits_count, $branch) {
$out = '';
if($commits_count==0) {
$out .=
__('No commits', 'linuxfoo-gitlab').
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
(is_null($atts['since']) ? '' : ' '.('since '.$atts['since'].' ago')).'.';
}
else {
$out .=
/* translators: %d: maximum number of commits displayed */
sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count).
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
(is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':';
}
return $out;
}
static function commits_list($atts, $project_url) {
$since = null;
@ -99,37 +136,18 @@ class LinuxfooGitlab {
else {
$commits_count = count($commits);
$commits_count = is_null($atts['max']) ? $commits_count : min($commits_count, $atts['max']);
$commits = array_slice($commits, 0, $commits_count);
if($commits_count==0) {
$out .=
'<span class="stats">'.
__('No commits', 'linuxfoo-gitlab').
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
(is_null($atts['since']) ? '' : ' '.('since '.$atts['since'].' ago')).'.'.
'</span>';
}
else {
$out .=
'<span class="stats">'.
/* translators: %d: maximum number of commits displayed */
sprintf(__('Last %d commits', 'linuxfoo-gitlab'), $commits_count).
(is_null($branch) ? '' : ' '.__('in branch', 'linuxfoo-gitlab').' "'.$branch.'"').
(is_null($atts['since']) ? '' : ' '.self::format_since($atts['since'])).':'.
'</span>'.
'<ul class="commits">';
$out .=
'<span class="stats">'.
self::format_commit_stats($atts, $commits_count, $branch).
'</span>';
if($commits_count>0) {
$out .= '<ul class="commits">';
foreach($commits as $commit) {
preg_match('/^....-..-../', $commit->committed_date, $m);
$date = $m[0];
$title = htmlspecialchars($commit->title, ENT_NOQUOTES|ENT_HTML5|ENT_SUBSTITUTE, 'UTF-8', FALSE);
$out .=
'<li>'.
$date.': <a href="'.$commit->web_url.'">'.$commit->short_id.'</a> '.$title.
'</li>';
$out .= '<li>'.self::format_commit($atts, $commit).'</li>';
}
$out .= '</ul>';