aboutsummaryrefslogtreecommitdiffstats
path: root/include/pgettext.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-03-11 00:18:29 +0100
committerfabrixxm <fabrix.xm@gmail.com>2011-03-11 00:18:29 +0100
commit8a40c718fb9f9272ea99094a760f399e323cd66c (patch)
treed462e5b29109102b65801251f1f5c2441d6c704c /include/pgettext.php
parent439ee37f99a6029e1d689f3a0133ca3de25b593e (diff)
downloadvolse-hubzilla-8a40c718fb9f9272ea99094a760f399e323cd66c.tar.gz
volse-hubzilla-8a40c718fb9f9272ea99094a760f399e323cd66c.tar.bz2
volse-hubzilla-8a40c718fb9f9272ea99094a760f399e323cd66c.zip
Move translation functions. Add tt() for plural cases.
Diffstat (limited to 'include/pgettext.php')
-rw-r--r--include/pgettext.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/pgettext.php b/include/pgettext.php
new file mode 100644
index 000000000..2ffee70bc
--- /dev/null
+++ b/include/pgettext.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * translation support
+ */
+
+// load string translation table for alternate language
+
+if(! function_exists('load_translation_table')) {
+function load_translation_table($lang) {
+ global $a;
+
+ if(file_exists("view/$lang/strings.php"))
+ include("view/$lang/strings.php");
+}}
+
+// translate string if translation exists
+
+if(! function_exists('t')) {
+function t($s) {
+
+ $a = get_app();
+
+ if(x($a->strings,$s)) {
+ $t = $a->strings[$s];
+ return is_array($t)?$t[0]:$t;
+ }
+ return $s;
+}}
+
+if(! function_exists('tt')){
+function tt($singular, $plural, $count){
+
+ $a = get_app();
+
+ if(x($a->strings,$singular)) {
+ $t = $a->strings[$singular];
+ $k = string_plural_select($count);
+ return is_array($t)?$t[$k]:$t;
+ }
+
+ if ($count!=1){
+ return $plural;
+ } else {
+ return $singular;
+ }
+}} \ No newline at end of file