summaryrefslogtreecommitdiffstats
path: root/endpoints/language.php
diff options
context:
space:
mode:
authorimoore76 <imoore76@users.noreply.github.com>2015-08-12 23:56:51 -0400
committerimoore76 <imoore76@users.noreply.github.com>2015-08-12 23:56:51 -0400
commita1172caa70fc60663bc0db62b643655497de3354 (patch)
treee79ec57bc7c291e5ae6f54954c441d26dc5b5698 /endpoints/language.php
parentcd0f2520d9065c7ce8ced16fb1d1500245689227 (diff)
parent8b611cdf516d4449c186493b1b24a01760c4a9c8 (diff)
downloadphpvirtualbox-a1172caa70fc60663bc0db62b643655497de3354.zip
phpvirtualbox-a1172caa70fc60663bc0db62b643655497de3354.tar.gz
phpvirtualbox-a1172caa70fc60663bc0db62b643655497de3354.tar.bz2
Merge pull request #4 from imoore76/develop
5.0-2
Diffstat (limited to 'endpoints/language.php')
-rw-r--r--endpoints/language.php60
1 files changed, 43 insertions, 17 deletions
diff --git a/endpoints/language.php b/endpoints/language.php
index a8eb1c6..e0769c6 100644
--- a/endpoints/language.php
+++ b/endpoints/language.php
@@ -3,7 +3,7 @@
* Injects language translations into phpVirtualBox as a JavaScript object and
* provides interface translation logic
* Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
- *
+ *
* $Id: language.php 595 2015-04-17 09:50:36Z imoore76 $
*/
@@ -40,52 +40,78 @@ echo('var __vboxLangData = ' . json_encode(__vbox_language::$langdata) .";\n\nva
// Failsafe wrapper
function trans(s,c,n,h) {
+ if(s && c && c.constructor === Array) {
+ o = c.shift();
+ n = c.shift();
+ h = c.shift();
+ c = o;
+ }
if(!c) c = 'VBoxGlobal';
var r = transreal(s,c,n,h);
-
- if(typeof r != 'string') {
+
+ if(typeof r != 'string') {
+ // console.log('Could not translate ' + s + ' with ' + c);
return s;
}
-
+
return r;
}
function transreal(w,context,number,comment) {
-
+
try {
-
+
if(__vboxLangData['contexts'][context]['messages'][w]['translation']) {
-
+
if(__vboxLangData['contexts'][context]['messages'][w]['translation']['numerusform']) {
-
+
var t = __vboxLangData['contexts'][context]['messages'][w]['translation']['numerusform'];
-
+
if(!number) number = 1;
-
+
if(number <= 1 && t[0]) return t[0];
if(number > 1 && t[1]) return t[1];
if(t[0]) return t[0];
return t[1];
}
+ /*
+ if (__vboxLangData['contexts'][context]['messages'][w] && __vboxLangData['contexts'][context]['messages'][w]['translation_attr'] && __vboxLangData['contexts'][context]['messages'][w]['translation_attr']['type'] == 'obsolete') {
+ console.log(w + ' in ' + context + ' is obsolete');
+ }
+ */
return __vboxLangData['contexts'][context]['messages'][w]['translation'];
-
+
} else if(__vboxLangData['contexts'][context]['messages'][w][0]) {
-
+
if(comment) {
for(var i in __vboxLangData['contexts'][context]['messages'][w]) {
- if(__vboxLangData['contexts'][context]['messages'][w][i]['comment'] == comment) return __vboxLangData['contexts'][context]['messages'][w][i]['translation'];
+ if(__vboxLangData['contexts'][context]['messages'][w][i]['comment'] == comment) {
+ /*
+ if (__vboxLangData['contexts'][context]['messages'][w][i]['translation_attr'] && __vboxLangData['contexts'][context]['messages'][w][i]['translation_attr']['type'] == 'obsolete') {
+ console.log(w + ' ' + ' and ' + comment + ' is obsolete');
+ }
+ */
+
+ return __vboxLangData['contexts'][context]['messages'][w][i]['translation'];
+ }
}
}
+ /*
+ if (__vboxLangData['contexts'][context]['messages'][w][0] && __vboxLangData['contexts'][context]['messages'][w][0]['translation_attr'] && __vboxLangData['contexts'][context]['messages'][w][0]['translation_attr']['type'] == 'obsolete') {
+ console.log(w + ' in ' + context + ' is obsolete');
+ }
+ */
+
return __vboxLangData['contexts'][context]['messages'][w][0]['translation'];
-
+
} else {
return w;
}
-
+
} catch(err) {
- // alert(w + ' - ' + context + ': ' + err);
+ // console.log(w + ' - ' + context + ': ' + err);
return w;
- }
+ }
}