diff --git a/include/pgettext.php b/include/pgettext.php
index 2e902a6ab0..ae1ce009c1 100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -120,48 +120,90 @@ function load_translation_table($lang) {
}}
-// translate string if translation exists
-
-if (! function_exists('t')) {
-function t($s) {
-
+/**
+ * @brief Return the localized version of the provided string with optional string interpolation
+ *
+ * This function takes a english string as parameter, and if a localized version
+ * exists for the current language, substitutes it before performing an eventual
+ * string interpolation (sprintf) with additional optional arguments.
+ *
+ * Usages:
+ * - t('This is an example')
+ * - t('URL %s returned no result', $url)
+ * - t('Current version: %s, new version: %s', $current_version, $new_version)
+ *
+ * @param string $s
+ * @return string
+ */
+function t($s)
+{
$a = get_app();
- if (x($a->strings,$s)) {
+ if (x($a->strings, $s)) {
$t = $a->strings[$s];
- return is_array($t)?$t[0]:$t;
+ $s = is_array($t) ? $t[0] : $t;
+ }
+ if (func_num_args() > 1) {
+ $args = array_slice(func_get_args(), 1);
+ $s = @vsprintf($s, $args);
}
- return $s;
-}}
-if (! function_exists('tt')){
-function tt($singular, $plural, $count){
+ return $s;
+}
+
+/**
+ * @brief Return the localized version of a singular/plural string with optional string interpolation
+ *
+ * This function takes two english strings as parameters, singular and plural, as
+ * well as a count. If a localized version exists for the current language, they
+ * are used instead. Discrimination between singular and plural is done using the
+ * localized function if any or the default one. Finally, a string interpolation
+ * is performed using the count as parameter.
+ *
+ * Usages:
+ * - tt('Like', 'Likes', $count)
+ * - tt("%s user deleted", "%s users deleted", count($users))
+ *
+ * @global type $lang
+ * @param string $singular
+ * @param string $plural
+ * @param int $count
+ * @return string
+ */
+function tt($singular, $plural, $count)
+{
global $lang;
$a = get_app();
- if (x($a->strings,$singular)) {
+ if (x($a->strings, $singular)) {
$t = $a->strings[$singular];
- $f = 'string_plural_select_' . str_replace('-','_',$lang);
- if (! function_exists($f))
- $f = 'string_plural_select_default';
- $k = $f($count);
- return is_array($t)?$t[$k]:$t;
+ if (is_array($t)) {
+ $plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);
+ if (function_exists($plural_function)) {
+ $plural_function = 'string_plural_select_default';
+ }
+ $i = $plural_function($count);
+ $s = $t[$i];
+ } else {
+ $s = $t;
+ }
+ } elseif (string_plural_select_default($count)) {
+ $s = $plural;
+ } else {
+ $s = $singular;
}
- if ($count!=1){
- return $plural;
- } else {
- return $singular;
- }
-}}
+ $s = @sprintf($s, $count);
+
+ return $s;
+}
// provide a fallback which will not collide with
// a function defined in any language file
-
-if (! function_exists('string_plural_select_default')) {
-function string_plural_select_default($n) {
- return ($n != 1);
-}}
+function string_plural_select_default($n)
+{
+ return $n != 1;
+}
diff --git a/view/templates/admin_aside.tpl b/view/templates/admin_aside.tpl
deleted file mode 100644
index 5c9cce0d0c..0000000000
--- a/view/templates/admin_aside.tpl
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-{{foreach $subpages as $page}}
- - {{$page.1}}
-{{/foreach}}
-
-
-{{if $admin.update}}
-
-{{/if}}
-
-
-{{if $admin.plugins_admin}}{{$plugadmtxt}}
{{/if}}
-
- {{foreach $admin.plugins_admin as $l}}
- - {{$l.1}}
- {{/foreach}}
-
-
-
-{{$logtxt}}
-
-
-{{$diagnosticstxt}}
-
diff --git a/view/templates/admin_blocklist.tpl b/view/templates/admin_blocklist.tpl
deleted file mode 100644
index 1484c987e9..0000000000
--- a/view/templates/admin_blocklist.tpl
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-
{{$intro}}
-
{{$public}}
-
-
{{$addtitle}}
-
-
- {{if $entries}}
-
{{$currenttitle}}
-
{{$currentintro}}
-
-
-
diff --git a/view/templates/admin_deleteitem.tpl b/view/templates/admin_deleteitem.tpl
deleted file mode 100644
index cf819dea67..0000000000
--- a/view/templates/admin_deleteitem.tpl
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
{{$title}} - {{$page}}
-
{{$intro1}}
-
{{$intro2}}
-
-
-
diff --git a/view/templates/admin_federation.tpl b/view/templates/admin_federation.tpl
deleted file mode 100644
index ee33df09b2..0000000000
--- a/view/templates/admin_federation.tpl
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
{{$title}} - {{$page}}
-
{{$intro}}
- {{if not $autoactive}}
-
{{$hint}}
- {{/if}}
-
{{$legendtext}}
-
- {{foreach $counts as $c}}
- {{if $c[0]['total'] > 0}}
- - {{$c[0]['platform']}} ({{$c[0]['total']}})
- {{/if}}
- {{/foreach}}
-
-
-
-
-
-
-{{foreach $counts as $c}}
- {{if $c[0]['total'] > 0}}
-
- {{$c[0]['platform']}} |
- {{$c[0]['total']}}
- | {{$c[0]['network']}} |
-
-
-
-
-
-
- {{foreach $c[1] as $v}}
- - {{if ($c[0]['platform']==='Friendica' and $version===$v['version']) }}{{$v['version']}}{{else}}{{$v['version']}}{{/if}} ({{$v['total']}})
- {{/foreach}}
-
- |
-
- {{/if}}
-{{/foreach}}
-
diff --git a/view/templates/admin_logs.tpl b/view/templates/admin_logs.tpl
deleted file mode 100644
index b2e6357a9a..0000000000
--- a/view/templates/admin_logs.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
{{$title}} - {{$page}}
-
-
-
-
{{$phpheader}}
-
-
{{$phplogenabled}}
-
{{$phphint}}
-
{{$phplogcode}}
-
-
-
diff --git a/view/templates/admin_plugins.tpl b/view/templates/admin_plugins.tpl
deleted file mode 100644
index 75565dd2ed..0000000000
--- a/view/templates/admin_plugins.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
{{$title}} - {{$page}}
- {{if $pcount eq 0}}
-
- {{$noplugshint}}
-
- {{else}}
-
{{$reload}}
-
- {{foreach $plugins as $p}}
- -
-
- {{$p.2.name}} - {{$p.2.version}}
- {{if $p.2.experimental}} {{$experimental}} {{/if}}{{if $p.2.unsupported}} {{$unsupported}} {{/if}}
-
-
{{$p.2.description}}
-
- {{/foreach}}
-
- {{/if}}
-
diff --git a/view/templates/admin_plugins_details.tpl b/view/templates/admin_plugins_details.tpl
deleted file mode 100644
index 9def8fc605..0000000000
--- a/view/templates/admin_plugins_details.tpl
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-
-
{{$info.name}} - {{$info.version}} : {{$action}}
-
{{$info.description}}
-
-
{{$str_author}}
- {{foreach $info.author as $a}}
- {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}},
- {{/foreach}}
-
-
-
{{$str_maintainer}}
- {{foreach $info.maintainer as $a}}
- {{if $a.link}}{{$a.name}}{{else}}{{$a.name}}{{/if}},
- {{/foreach}}
-
-
- {{if $screenshot}}
-
- {{/if}}
-
- {{if $admin_form}}
-
{{$settings}}
-
- {{/if}}
-
- {{if $readme}}
-
Readme
-
- {{$readme}}
-
- {{/if}}
-
diff --git a/view/templates/admin_queue.tpl b/view/templates/admin_queue.tpl
deleted file mode 100644
index aaca9b0148..0000000000
--- a/view/templates/admin_queue.tpl
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
{{$title}} - {{$page}} ({{$count}})
-
-
{{$info}}
-
-
- {{$id_header}} |
- {{$to_header}} |
- {{$url_header}} |
- {{$network_header}} |
- {{$created_header}} |
- {{$last_header}} |
-
- {{foreach $entries as $e}}
-
- {{$e.id}} |
- {{$e.name}} |
- {{$e.nurl}} |
- {{$e.network}} |
- {{$e.created}} |
- {{$e.last}} |
-
- {{/foreach}}
-
-
diff --git a/view/templates/admin_settings_features.tpl b/view/templates/admin_settings_features.tpl
deleted file mode 100644
index abcc527d42..0000000000
--- a/view/templates/admin_settings_features.tpl
+++ /dev/null
@@ -1,21 +0,0 @@
-{{$title}}
-
-
diff --git a/view/templates/admin_settings_head.tpl b/view/templates/admin_settings_head.tpl
deleted file mode 100644
index 25c0f804e4..0000000000
--- a/view/templates/admin_settings_head.tpl
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/view/templates/admin_site.tpl b/view/templates/admin_site.tpl
deleted file mode 100644
index 9f7b3601e5..0000000000
--- a/view/templates/admin_site.tpl
+++ /dev/null
@@ -1,160 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-
-
-
- {{* separate form for relocate... *}}
-
-
-
diff --git a/view/templates/admin_summary.tpl b/view/templates/admin_summary.tpl
deleted file mode 100644
index e650144134..0000000000
--- a/view/templates/admin_summary.tpl
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-{{if $showwarning}}
-
- {{foreach $warningtext as $wt}}
-
{{$wt}}
- {{/foreach}}
-
-{{/if}}
-
-
- - {{$queues.label}}
- - {{$queues.queue}} - {{$queues.workerq}}
-
-
- - {{$pending.0}}
- - {{$pending.1}}
-
-
-
- - {{$users.0}}
- - {{$users.1}}
-
- {{foreach $accounts as $p}}
-
- - {{$p.0}}
- - {{if $p.1}}{{$p.1}}{{else}}0{{/if}}
-
- {{/foreach}}
-
-
-
- - {{$plugins.0}}
-
- {{foreach $plugins.1 as $p}}
- - {{$p}}
- {{/foreach}}
-
-
-
-
- - {{$version.0}}
- - {{$platform}} '{{$codename}}' {{$version.1}} - {{$build}}
-
-
-
-
diff --git a/view/templates/admin_users.tpl b/view/templates/admin_users.tpl
deleted file mode 100644
index a842d6e364..0000000000
--- a/view/templates/admin_users.tpl
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
{{$title}} - {{$page}}
-
-
- {{if $deleted}}
-
{{$h_deleted}}
-
-
-
- |
- {{foreach $th_deleted as $th}}{{$th}} | {{/foreach}}
-
-
-
- {{foreach $deleted as $u}}
-
- |
- {{$u.name}} |
- {{$u.email}} |
- {{$u.register_date}} |
- {{$u.login_date}} |
- {{$u.lastitem_date}} |
- {{$u.deleted}} |
-
- {{/foreach}}
-
-
- {{/if}}
-
{{$h_newuser}}
-
-
diff --git a/view/templates/admin_viewlogs.tpl b/view/templates/admin_viewlogs.tpl
deleted file mode 100644
index c80264c52a..0000000000
--- a/view/templates/admin_viewlogs.tpl
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
{{$title}} - {{$page}}
-
-
{{$logname}}
-
-
diff --git a/view/theme/frio/templates/admin_aside.tpl b/view/theme/frio/templates/admin_aside.tpl
deleted file mode 100644
index a90ec69163..0000000000
--- a/view/theme/frio/templates/admin_aside.tpl
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-{{if $admin.plugins_admin}}
-
-{{/if}}
-
-
-
-
diff --git a/view/theme/frost-mobile/templates/admin_aside.tpl b/view/theme/frost-mobile/templates/admin_aside.tpl
deleted file mode 100644
index 74b6cd5f69..0000000000
--- a/view/theme/frost-mobile/templates/admin_aside.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-{{if $admin.update}}
-
-{{/if}}
-
-
-{{if $admin.plugins_admin}}{{$plugadmtxt}}
{{/if}}
-
- {{foreach $admin.plugins_admin as $l}}
- - {{$l.1}}
- {{/foreach}}
-
-
-
-{{$logtxt}}
-
-
diff --git a/view/theme/frost-mobile/templates/admin_site.tpl b/view/theme/frost-mobile/templates/admin_site.tpl
deleted file mode 100644
index d5b64e58dd..0000000000
--- a/view/theme/frost-mobile/templates/admin_site.tpl
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
{{$title}} - {{$page}}
-
-
-
diff --git a/view/theme/frost-mobile/templates/admin_users.tpl b/view/theme/frost-mobile/templates/admin_users.tpl
deleted file mode 100644
index f0c4869a70..0000000000
--- a/view/theme/frost-mobile/templates/admin_users.tpl
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-
-
-
diff --git a/view/theme/frost/templates/admin_aside.tpl b/view/theme/frost/templates/admin_aside.tpl
deleted file mode 100644
index 74b6cd5f69..0000000000
--- a/view/theme/frost/templates/admin_aside.tpl
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-{{if $admin.update}}
-
-{{/if}}
-
-
-{{if $admin.plugins_admin}}{{$plugadmtxt}}
{{/if}}
-
- {{foreach $admin.plugins_admin as $l}}
- - {{$l.1}}
- {{/foreach}}
-
-
-
-{{$logtxt}}
-
-
diff --git a/view/theme/frost/templates/admin_site.tpl b/view/theme/frost/templates/admin_site.tpl
deleted file mode 100644
index 8dcfa91294..0000000000
--- a/view/theme/frost/templates/admin_site.tpl
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
{{$title}} - {{$page}}
-
-
-
diff --git a/view/theme/frost/templates/admin_users.tpl b/view/theme/frost/templates/admin_users.tpl
deleted file mode 100644
index f0c4869a70..0000000000
--- a/view/theme/frost/templates/admin_users.tpl
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
{{$title}} - {{$page}}
-
-
-
diff --git a/view/theme/quattro/templates/admin_users.tpl b/view/theme/quattro/templates/admin_users.tpl
deleted file mode 100644
index ddb395db9c..0000000000
--- a/view/theme/quattro/templates/admin_users.tpl
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
{{$title}} - {{$page}}
-
-
- {{if $deleted}}
-
{{$h_deleted}}
-
-
-
- |
- {{foreach $th_deleted as $th}}{{$th}} | {{/foreach}}
-
-
-
- {{foreach $deleted as $u}}
-
- |
- {{$u.name}} |
- {{$u.email}} |
- {{$u.register_date}} |
- {{$u.login_date}} |
- {{$u.lastitem_date}} |
- {{$u.deleted}} |
-
- {{/foreach}}
-
-
- {{/if}}
-
{{$h_newuser}}
-
-