mirror of
https://github.com/friendica/friendica
synced 2025-04-26 02:30:11 +00:00
Move translation functions. Add tt() for plural cases.
This commit is contained in:
parent
439ee37f99
commit
8a40c718fb
2 changed files with 51 additions and 22 deletions
46
include/pgettext.php
Normal file
46
include/pgettext.php
Normal file
|
@ -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;
|
||||
}
|
||||
}}
|
Loading…
Add table
Add a link
Reference in a new issue