Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

language.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /*
  3. * Injects language translations into phpVirtualBox as a JavaScript object and
  4. * provides interface translation logic
  5. * Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  6. *
  7. * $Id: language.php 595 2015-04-17 09:50:36Z imoore76 $
  8. */
  9. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
  10. require_once(dirname(__FILE__).'/lib/language.php');
  11. if(!is_object($_vbox_language)) $_vbox_language = new __vbox_language();
  12. header("Content-type: application/javascript; charset=utf-8", true);
  13. //Set no caching
  14. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  15. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  16. header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
  17. header("Pragma: no-cache");
  18. if(isset($_GET['debug']) && $_GET['debug']) {
  19. print_r(__vbox_language::$langdata);
  20. return;
  21. }
  22. /*
  23. * Dump in JavaScript
  24. */
  25. echo('var __vboxLangData = ' . json_encode(__vbox_language::$langdata) .";\n\nvar __vboxLangName = '".constant('VBOXLANG')."';\n\n");
  26. ?>
  27. // Failsafe wrapper
  28. function trans(s,c,n,h) {
  29. if(s && c && c.constructor === Array) {
  30. o = c.shift();
  31. n = c.shift();
  32. h = c.shift();
  33. c = o;
  34. }
  35. if(!c) c = 'VBoxGlobal';
  36. var r = transreal(s,c,n,h);
  37. if(typeof r != 'string') {
  38. // console.log('Could not translate ' + s + ' with ' + c);
  39. return s;
  40. }
  41. return r;
  42. }
  43. function transreal(w,context,number,comment) {
  44. try {
  45. if(__vboxLangData['contexts'][context]['messages'][w]['translation']) {
  46. if(__vboxLangData['contexts'][context]['messages'][w]['translation']['numerusform']) {
  47. var t = __vboxLangData['contexts'][context]['messages'][w]['translation']['numerusform'];
  48. if(!number) number = 1;
  49. if(number <= 1 && t[0]) return t[0];
  50. if(number > 1 && t[1]) return t[1];
  51. if(t[0]) return t[0];
  52. return t[1];
  53. }
  54. /*
  55. if (__vboxLangData['contexts'][context]['messages'][w] && __vboxLangData['contexts'][context]['messages'][w]['translation_attr'] && __vboxLangData['contexts'][context]['messages'][w]['translation_attr']['type'] == 'obsolete') {
  56. console.log(w + ' in ' + context + ' is obsolete');
  57. }
  58. */
  59. return __vboxLangData['contexts'][context]['messages'][w]['translation'];
  60. } else if(__vboxLangData['contexts'][context]['messages'][w][0]) {
  61. if(comment) {
  62. for(var i in __vboxLangData['contexts'][context]['messages'][w]) {
  63. if(__vboxLangData['contexts'][context]['messages'][w][i]['comment'] == comment) {
  64. /*
  65. if (__vboxLangData['contexts'][context]['messages'][w][i]['translation_attr'] && __vboxLangData['contexts'][context]['messages'][w][i]['translation_attr']['type'] == 'obsolete') {
  66. console.log(w + ' ' + ' and ' + comment + ' is obsolete');
  67. }
  68. */
  69. return __vboxLangData['contexts'][context]['messages'][w][i]['translation'];
  70. }
  71. }
  72. }
  73. /*
  74. 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') {
  75. console.log(w + ' in ' + context + ' is obsolete');
  76. }
  77. */
  78. return __vboxLangData['contexts'][context]['messages'][w][0]['translation'];
  79. } else {
  80. return w;
  81. }
  82. } catch(err) {
  83. // console.log(w + ' - ' + context + ': ' + err);
  84. return w;
  85. }
  86. }