]> git.mxchange.org Git - friendica.git/commitdiff
Move translation functions. Add tt() for plural cases.
authorfabrixxm <fabrix.xm@gmail.com>
Thu, 10 Mar 2011 23:18:29 +0000 (00:18 +0100)
committerfabrixxm <fabrix.xm@gmail.com>
Thu, 10 Mar 2011 23:18:29 +0000 (00:18 +0100)
boot.php
include/pgettext.php [new file with mode: 0644]

index 4c3a923dcea2e52644dea55e826aface43047192..19c6d887866412f21c2af77d71f136bc8f929ef3 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -159,6 +159,11 @@ if (get_magic_quotes_gpc()) {
     unset($process);
 }
 
+/*
+ * translation system
+ */
+require_once("include/pgettext.php");
+
 
 /**
  *
@@ -601,28 +606,6 @@ function replace_macros($s,$r) {
 }}
 
 
-// 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))
-               return $a->strings[$s];
-       return $s;
-}}
-
 // curl wrapper. If binary flag is true, return binary
 // results. 
 
diff --git a/include/pgettext.php b/include/pgettext.php
new file mode 100644 (file)
index 0000000..2ffee70
--- /dev/null
@@ -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