Translator.php 63.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
<?php
	/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
	 
	/**
	 * Arquivo que contem a classe de traducao e outros para a traducao de aplicacoes
	 *
	 * As aplicacoes baseadas nesse arquivo/classe deverao adaptar-se ao modo como este
	 * monta os arquivos de idiomas e seus requisitos de codificacao de idioma.
	 *
	 * PHP versions 4 and 5
	 *
	 * LICENSE: This source file is subject to version 2 of the GNU/GPL license
	 * that is available through the world-wide-web at the following URI:
	 * http://www.gnu.org/copyleft/gpl.html.  If you did not receive a copy of
	 * the GNU/GPL License and are unable to obtain it through the web, please
	 * send a note to harpiain at users.sourceforge.net so I can mail you a copy immediately.
	 *
	 * Um exemplo de como usar a classe:
	 * <code>
	 *  
	 * define(TRANSLATOR_PATH, "../include/phpTranslator/");
	 * define(TRANSLATOR_PATH_URL, "../include/phpTranslator/");
	 *
	 * if(!@include_once( TRANSLATOR_PATH.'/Translator.php'))
	 *   echo "<h1>There is a trouble with phpTranslator package. 
	 *              It isn't found.</h1>";
	 * 
	 * $_objTranslator = new Translator( USER_LOCALE );
	 *
	 * $_objTranslator->setLangFilePath( "/myapplic_path_lang_files/" );
	 * $_objTranslator->setURLPath( TRANSLATOR_PATH_URL );
	 * $_objTranslator->initStdLanguages();
	 * if(CODING)   
	 *   $_objTranslator->translatorGUI( false );
	 * elseif(TRANSLATING)
	 *   $_objTranslator->translatorGUI();
	 * else   
	 *   echo $_objTranslator->getText( 'some text to translate and
	 *                         be showed after had been registred.' );
	 * </code>
	 * 
	 * @category   PHP-Tool
	 * @package    phpTranslator
	 * @author     Adriano dos Santos Vieira (harpiain) <harpiain@users.sourceforge.net>
	 * @copyright  2005-2007 Adriano dos Santos Vieira
	 * @license    http://www.gnu.org/copyleft/gpl.html  GNU/GPL License 3.0
	 * @version    subVersion: $Id: phpTranslator, v 0.2.0-40 feb/23/2006 $
	 * @link       http://obiblioopac4j.sourceforge.net
	 * @see        Translator()
	 * @since      File available since Release 0.0.1
	 * @todo  The package TODO/Roadmap are: {@example ToDo.txt}
	 */
	 
	/**
	 * Constante que define o "ENTER" e o "SALTO DE LINHA" nos arquivos de idiomas
	 * @access private
	 */
	 define ( T_CRLF, chr(13).chr(10) );
	    
	/**
	 * Constante que define a cor do texto ainda nao traduzido
	 * @access private
	 */
	 define ( T_BG_COLOR_TRADUZ, "#e7d4d4" );

	/**
	 * Constrante que define se apenas traducao
	 * @access private
	 */
    define(  T_TRANSLATOR, true );
    
	/**
	 * Constante que define se codificacao e traducao
	 * @access private
	 */
    define(  T_CODER , false );

    /**
     * Classe para realizar a traducao de um texto com base em arquivos pre-definidos
     *
     * As aplicacoes baseadas nessa classe deverao adaptar-se ao modo como esta classe <br>
     * monta os arquivos de idiomas e seus requisitos de codificacao de idioma.
     *
     * @category   PHP-Tool
     * @package    phpTranslator
     * @author     Adriano dos Santos Vieira (harpiain) <harpiain@users.sourceforge.net>
     */
    Class Translator {
      
      /**
      * path para para a propria classe
      * @access private
      * @var string
      */
      var $classSelfPath = "./";
      
      /**
      * path relativo (URL) para a classe
      * @access private
      * @var string
      */
      var $translatorUrlPath = "./";
      
      /**
      * path para o arquivo de mensagens
      * @access private
      * @var sting
      */
      var $languageFilePath = "./";
      
      /**
      * prefixo para o arquivo de mensagens
      * @access private
      * @var $languageFilePrefix
      */
      var $languageFilePrefix = "language.";
       
      
      /**
      * sufixo para o arquivo de mensagens
      * @access private
      * @var string
      */
      var $languageFileSufix = ".inc.php";
            
      /**
      * contera as mensagens a serem exibidas para a aplicacao de 2 idiomas (source and target)
      * 
      * @access private
      * @var array
      */
      var $translated_text    = "";
    
      /**
      * contera as mensagens padrao
      * 
      * @access private
      * @var array
      */
      var $translatedTextStd    = array();
            
      /**
      * contera as mensagens traduzidas (ex: en-us)
      * 
      * @access private
      * @var array
      */
      var $translatedTextTgt    = array();

      /**
      * contera as mensagens da propria classe traduzidas ou padrao
      * 
      * @access private
      * @var array
      * @since v 0.2.0-40
      */
      var $translatedTextSelf    = array();
            
      /**
      * padrao da aplicacao
      * 
      * @access private
      * @var string
      */
      var $languageStd       = "pt-br";
      
      /**
      * preferencia do usuario
      * @access private
      * @var string
      */
      var $languageUser      = "";
      
      /**
      * se traduz textos padrao conforme idioma: 
      *    TRUE - tenta traduzir todos os textos;
      *   FALSE - nao traduz os textos
      * 
      * @access private
      * @var boolean
      */
      var $translateMessage  = true;
      
      /**
      * se os arquivos de idioma estarao em sub-diretorios, conforme abrevitura ISO I18N
      * ex: pt-br/language.pt-br.inc.php, en/language.en.inc.php ...
      *    TRUE - os arquivos estarao em subdiretorios;
      *   FALSE - os arquivos nao estarao em subdiretorios
      * 
      * @access private
      * @var boolean
      * @since v 0.2.0-40
      */
      var $languageFilesubdir = false;
    
      /**
      * se os arquivos de idioma estarao seccionados, conforme contextualizacao
      * ex: prefix.SECTION.sufix == language.admin.pt-br.inc.php ...
      *    TRUE - os arquivos estarao seccionados;
      *   FALSE - os arquivos nao estarao seccionados
      * 
      * @access private
      * @var boolean
      * @since v 0.2.0-40
      */
      var $languageFileInSections = false;
    
      /**
      * devera conter as secoes dos arquivos de idiomas, conforme contextualizacao
      *  
      * <code>
      *  ...
      *  $_lang_sections = array('phpTranslator' => 'textos da classe de traducao',
      *                                         'admin'             => 'Textos da secao administrativa',
      *                                         'home'              => 'textos da secao principal',
      *                                         'and son on'      => 'e assim por diante...');
      *  ...
      * </code>
      * @access private
      * @var array
      * @since v 0.2.0-40
      */
      var $languageSections = array();
    
      /**
      * devera conter a secao ativa a ser mostrada/traduzida, quando fizer uso de secoes
      *  
      * @access private
      * @var array
      * @since v 0.2.0-40
      */
      var $languageSectionActive = "";
    
      /**
      * possiveis mensagens retornadas pela classe
      * @access private
      * @var string
      */
      var $mensagem = "";
            
      /**
      * se ocorreu erro em um metodo - true = ocorreu erro; false = nao ocorreu erro
      * @access private
      * @var boolean
      */
      var $error = false;
    
      /**
      * Tamanho para o codigo do idioma
      * @var numeric
      * @access private
      */
      var $messageCountryLen = 10;
            
      /**
      * Tamanho para o codigo da mensagem
      * @var numeric
      * @access private
      */
      var $messageCodeLen  = 100;
            
      /**
      * Tamanho para o tipo da mensagem
      * @var numeric
      * @access private
      */
      var $messageTypeLen  = 10;
            
      /**
      * Tamanho para a abreviacao
      * @var numeric
      * @access private
      */
      var $messageAbbrLen  = 10;
            
      /**
      * Tamanho para o contextualizacao (ex: admin, config, preferences, front-end etc)
      * @var numeric
      * @access private
      */
      var $messageContextLen = 10;
             
      /**
      * contera as mensagens a serem exibidas para traducao
      * 
      * @access private
      * @var array
      */
      var $arrLanguageLang = array();
      
      /**
      * contera as mensagens a serem listadas
      * 
      * @access private
      * @var array
      */
      var $arrLanguageList = array();
       
      /**
      * idioma do browser
      * @var string
      * @access private
      */
      var $_browserLanguage  = '';

      /**
      * Se mostra todas as mensagens geradas pela aplicacao
      * @var boolean
      * @access private
      */
      var $_debugTranslator = false;
                   
      /**
      * Objeto template
      * @var object
      * @access private
      */
      var $_objTmpl;
             
       /**
        * Metodo contrutor para realizar a traducao de um texto com base em arquivos pre-definidos
        * @access public
        * @name   Translator
        * @param  string $_abbr_i18n_tgt - Deve ser informado o idioma destino para a aplicacao
        * @param  string $_langFilePath  - path para o arquivo de mensagens
        * @param  string $_abbr_i18n_src - Deve ser informado o idioma padrao da aplicacao 
        *                                  (padrao "en" = English)
        */
        function Translator( $_abbr_i18n_tgt='', $_langFilePath='', $_abbr_i18n_src='en-us' ) {
    
             $_browserLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
             if(strpos($_browserLanguage, ",")) {
                $_browserLanguage = substr($_browserLanguage,0,strpos($_browserLanguage, ","));
             }
             $this->_browserLanguage = $_browserLanguage;
             
            $this->classSelfPath = dirname(__FILE__);
            
            if(!empty($_abbr_i18n_src))
               $this->SetLanguage($_abbr_i18n_src);

            if(!empty($_abbr_i18n_tgt))
            $this->SetLanguage($_abbr_i18n_tgt,'target');
            
            /*
             * busca a propia traducao
             */
            $this->setLangFilePath( $this->classSelfPath."/languages/" );
            $this->translatedTextSelf = $this->_getLangFile($_abbr_i18n_tgt);
            if($this->error) {
                $this->translatedTextSelf = $this->_getLangFile($_abbr_i18n_src);
                if($this->error) {
                    $this->translatedTextSelf = $this->_getLangFile("en-us");
                }
            }
            
            if( !empty($_langFilePath) )
            	$this->setLangFilePath( $_langFilePath );
            	
        } // end func: Translator
    
       /**
        * Prove a interface de cadastramento de codigos de mensagems ou a de traducao
        *
        * @param boolean $_translate_only FALSE - Se apenas para traduzir 
        *                                  TRUE - tambem para fazer manutencao (default)
        */ 
        function translatorGUI( $_translate_only=true ) {

           // objeto para o template
           $_objTmpl =& $this->_createTemplate();
           $_objTmpl->setRoot( $this->classSelfPath.'/templates' );
    
            // Dados de inicializacao
            if(!isset($_POST['mnt_lang_action'])) $_langAction = 'listar';
            elseif(array_key_exists('tradutor', $_POST['mnt_lang_action'])) $_langAction = 'tradutor';
            elseif(array_key_exists('inserir', $_POST['mnt_lang_action'])) $_langAction = 'inserir';
            elseif(array_key_exists('alterar', $_POST['mnt_lang_action'])) $_langAction = 'alterar';
            elseif(array_key_exists('excluir', $_POST['mnt_lang_action'])) $_langAction = 'excluir';
            elseif(array_key_exists('listar', $_POST['mnt_lang_action'])) $_langAction = 'listar';
            elseif(array_key_exists('salvar', $_POST['mnt_lang_action'])) $_langAction = 'salvar';

           if(!empty($_POST['tag_active']))
              $this->languageSectionActive = $_POST['tag_active'];
              
           $this->initStdLanguages();
           
            $_list_lang = false;
            $_abbr_i18n_save = $this->languageStd;
            $_mnt_language = $_POST['mnt_language'];
            $_lang_code_selected = $_POST['mnt_code_selected'];
            $_lang_data_selected[$_lang_code_selected] = ($_POST['mnt_lang_data'][$_lang_code_selected]);
    
           // Variaveis para o Template
    
           // fim de variaveis para o template
    
           // inicio de Montagem pagina HTML
           $_objTmpl->readTemplatesFromInput( 'translate_mnt_tmpl.html' );
           $_objTmpl->addVar( 'ini_page_form', 'classSelfPath', $this->classSelfPath );
           $_objTmpl->addVar( 'ini_page_form', 'translatorUrlPath', $this->translatorUrlPath );
           $_objTmpl->addVar( 'ini_page_form_mos', 'translatorUrlPath', $this->translatorUrlPath );
    
           // Se acionado o botao para traduzir, retira-o e mostra o SALVAR/RESTAURAR
           if($_translate_only) {
               $_objTmpl->addVar( 'ini_page_form_btn', 'mnt_btn_show',"translate");
            }
            if(isset($_POST['save_translation'])) {
              $this->_langSave($_POST['lang_target'],$this->languageUser);
            }
    
            if(defined( '_VALID_MOS' ))
               $_objTmpl->addVar( 'ini_page_form_mos', 'mos_page',"inside");
       
           if($_langAction == 'excluir' ) {
              $this->_langCodeDelete($_lang_data_selected);
              $_list_lang = true;  
              $this->_langSave($this->translatedTextStd,$_abbr_i18n_save);
           }
               
           if($_langAction == 'salvar') {
              $_list_lang = true;
              $this->translatedTextStd[$this->stripContraBarra($_mnt_language['code'])] = $_mnt_language;
              $this->_langSave($this->translatedTextStd,$_abbr_i18n_save);
           }
           
           // (re)constroi os arrays para o template
           if(!empty($_POST['tag_active']))
              $this->languageSectionActive = $_POST['tag_active'];
              
           $this->initStdLanguages();
           $this->buildArrayVars();
           
           $titulo = $this->getText('#phpTranslator_page_title#');
           $_objTmpl->addVar( 'ini_page_form', 'titulo', $titulo );
           $_objTmpl->addVar( 'ini_page_form', 'PHPTRANSLATOR_EXCLUIR_CODIGO', 
                                              $this->getText('#phpTranslator_excluir codigo#') );
           $_objTmpl->displayParsedTemplate('ini_page_form');
           $this->showTagHeader(&$_objTmpl);
    
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_INSERIR', 
                                              $this->getText('#phptranslator_inserir#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_ALTERAR', 
                                              $this->getText('#phptranslator_alterar#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_EXCLUIR', 
                                              $this->getText('#phptranslator_excluir#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_LISTAR', 
                                              $this->getText('#phptranslator_listar#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_TRADUZIR', 
                                              $this->getText('#phptranslator_traduzir#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_SALVAR', 
                                              $this->getText('#phptranslator_salvar#') );
           $_objTmpl->addVar( 'ini_page_form_btn', 'BTN_RESTAURAR', 
                                              $this->getText('#phptranslator_restaurar#') );
                                              
           $_objTmpl->addVar( 'ini_page_form_btn', 'MSG_SELECT_ONE_CHANGE', 
                                        $this->getText('#phptranslator_falta selecionar mensagem a ser alterada#') );
                                        
           $_objTmpl->addVar( 'ini_page_form_btn', 'MSG_SELECT_ONE_DELETE', 
                                        $this->getText('#phptranslator_falta selecionar mensagem a ser excluida#') );
                                        
           $_objTmpl->addVar( 'translate_mnt', 'BTN_SALVAR', 
                                        $this->getText('#phptranslator_salvar#') );
           $_objTmpl->addVar( 'translate_mnt', 'BTN_RESTAURAR', 
                                        $this->getText('#phptranslator_restaurar#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING', 
                                        $this->getText('#phptranslator_codificacao de idioma padrao#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_CONTEXT', 
                                        $this->getText('#phptranslator_contexto da mensagem#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_LANG', 
                                        $this->getText('#phptranslator_idioma#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_MSG_CODE', 
                                        $this->getText('#phptranslator_codigo da mensagem#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_MSG_TYPE', 
                                        $this->getText('#phptranslator_tipo da mensagem#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_MSG_ABBR', 
                                        $this->getText('#phptranslator_sigla para a mensagem#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_MSG', 
                                        $this->getText('#phptranslator_mensagem#') );
           $_objTmpl->addVar( 'translate_mnt', 'STANDARD_LANG_CODING_ADVISE', 
                                        $this->getText('#phptranslator_mnt_code_advise#') );
                                        
           $_objTmpl->addVar( 'translate_list_head', 'STANDARD_LANG_REPORTING', 
                                        $this->getText('#phptranslator_listagem de mensagens padrao codificadas#') );
                                                
           $_objTmpl->displayParsedTemplate('form_buttons');
           
           if($_langAction == 'inserir' or $_langAction == 'alterar') {
               
             $_show_form = true;
             
             $_objTmpl->addVar( 'translate_mnt',"LANG_COUNTRY_LEN", $this->messageCountryLen);
             $_objTmpl->addVar( 'translate_mnt',"LANG_CODE_LEN", $this->messageCodeLen );
             $_objTmpl->addVar( 'translate_mnt',"LANG_CONTEXT_LEN",$this->messageContextLen);
             $_objTmpl->addVar( 'translate_mnt',"LANG_TYPE_LEN", $this->messageTypeLen);
             $_objTmpl->addVar( 'translate_mnt',"LANG_ABBR_LEN", $this->messageAbbrLen);
               
              if(array_key_exists('alterar', $_POST['mnt_lang_action']) ) {
                 if(empty($_lang_code_selected))
                    $_show_form = false;
            
                 $_objTmpl->addVar( 'translate_mnt',"LANG_COUNTRY", $this->stripContraBarra($_lang_data_selected[$_lang_code_selected]['lang'] ));
                 $_objTmpl->addVar( 'translate_mnt',"LANG_CODE_DISABLED", 'disabled' );
                 $_objTmpl->addVar( 'translate_mnt',"LANG_CODE", $this->stripContraBarra($_lang_code_selected ));
                 $_objTmpl->addVar( 'translate_mnt',"LANG_CONTEXT", 
                                                           $this->stripContraBarra($_lang_data_selected[$_lang_code_selected]['context'] ));
                 $_objTmpl->addVar( 'translate_mnt',"LANG_TYPE", $this->stripContraBarra($_lang_data_selected[$_lang_code_selected]['type'] ));
                 $_objTmpl->addVar( 'translate_mnt',"LANG_ABBR", $this->stripContraBarra($_lang_data_selected[$_lang_code_selected]['abbr'] ));
                 $_objTmpl->addVar( 'translate_mnt',"LANG_MESSAGE", $this->stripContraBarra($_lang_data_selected[$_lang_code_selected]['text'] ));
              }
              else {
                 $_objTmpl->addVar( 'translate_mnt',"LANG_COUNTRY", $this->languageStd );        
              }
    
              if($_show_form)
                 $_objTmpl->displayParsedTemplate('translate_mnt');
              $_list_lang = true;  
            }
      
           if(!$_translate_only and ($_langAction == 'listar' or $_list_lang)) {
              $_objTmpl->displayParsedTemplate('translate_list_head');
              if($this->arrLanguageList)
                 foreach($this->arrLanguageList as $_keys => $_key) {
                    $_objTmpl->addVar( 'translate_list_body', 'TAB_CONTEXT', $_keys );
         
                   $_objTmpl->addVar( 'translate_list_body', 'STANDARD_LANG_CODING_LANG', 
                                                $this->getText('#phptranslator_idioma#') );
                   $_objTmpl->addVar( 'translate_list_body', 'STANDARD_LANG_CODING_MSG_CODE', 
                                                $this->getText('#phptranslator_codigo da mensagem#') );
                   $_objTmpl->addVar( 'translate_list_body', 'STANDARD_LANG_CODING_MSG_TYPE', 
                                                $this->getText('#phptranslator_tipo da mensagem#') );
                   $_objTmpl->addVar( 'translate_list_body', 'STANDARD_LANG_CODING_MSG_ABBR', 
                                                $this->getText('#phptranslator_sigla para a mensagem#') );
                   $_objTmpl->addVar( 'translate_list_body', 'STANDARD_LANG_CODING_MSG', 
                                                $this->getText('#phptranslator_mensagem#') );
                                                      
                    $_objTmpl->addRows( 'translate_list_by_context', $this->arrLanguageList[$_keys] );
                    $_objTmpl->displayParsedTemplate('translate_list_body');
                    // limpa dados de template para acrecentar outros dados
                    $_objTmpl->clearTemplate('translate_list_body');
                    $_objTmpl->clearTemplate('translate_list_by_context');
                 }  // end foreach
              else
                 $_objTmpl->addVar('translate_list_foot', 'LIST_MESSAGE', $this->getText('#phptranslator_text#')." ".$this->getText('#phptranslator_not found#'));
      
              $_objTmpl->displayParsedTemplate('translate_list_foot');
            }
    
           if($_translate_only or $_langAction == 'tradutor') {
              // inicio de Montagem pagina do tradutor
              $_objTmpl->readTemplatesFromInput( 'translate_tmpl.html' );
              $_objTmpl->addVar( 'translate_lang_head', 'STANDARD_LANG_TRANSLATION', 
                                        $this->getText('#phptranslator_traducao do idioma padrao#') );
      
              $_objTmpl->displayParsedTemplate('translate_lang_head');
              if(is_array($this->arrLanguageLang ))
                  foreach($this->arrLanguageLang as $_keys => $_key) {
                     $_objTmpl->addVar( 'translate_lang_body', 'STANDARD_TEXT', 
                                        $this->getText('#phptranslator_texto padrao#') );
                     $_objTmpl->addVar( 'translate_lang_body', 'TARGET_TEXT', 
                                        $this->getText('#phptranslator_traduzir para#') );
                     $_objTmpl->addVar( 'translate_lang_body', 'TRANSLATED_TEXT', 
                                        $this->getText('#phptranslator_texto traduzido#') );
                     $_objTmpl->addVar( 'translate_lang_body', 'ABBREVIATION', 
                                        $this->getText('#phptranslator_sigla#')."/".
                                        $this->getText('#phptranslator_simbolo#') );
                     $_objTmpl->addVar( 'translate_lang_body', 'BTN_SALVAR', 
                                        $this->getText('#phptranslator_salvar#') );
                     $_objTmpl->addVar( 'translate_lang_body', 'BTN_RESTAURAR', 
                                        $this->getText('#phptranslator_restaurar#') );
                                              
    
                     $_objTmpl->addVar( 'translate_lang_body', 'TAB_CONTEXT', $_keys );
                     $_objTmpl->addVar( 'translate_lang_body','LANGUAGE_SOURCE',"(".$this->languageStd.")");
                     $_objTmpl->addVar( 'translate_lang_body','LANGUAGE_TARGET',"(".$this->_getLanguage().")");
                     $_objTmpl->addRows( 'translate_lang_list_entry', $this->arrLanguageLang[$_keys] );
                     $_objTmpl->displayParsedTemplate('translate_lang_body');
                     // limpa dados de template para acrecentar outros dados
                     $_objTmpl->clearTemplate('translate_lang_body');
                     $_objTmpl->clearTemplate('translate_lang_list_entry');
                  }  // end foreach
      
              $_objTmpl->displayParsedTemplate('translate_lang_foot');
              // fim de Montagem pagina do tradutor
           }
           $_objTmpl->displayParsedTemplate('end_page_form');
    
        } //end func: Translate
    
       /**
        * Busca o texto a ser traduzido
        *
        * Busca a traducao do texto - caso o texto traduzido nao exista retorna o texto padrao e caso este 
        * tambem nao exista retorna o codigo de pesquisa
        *
        * @param string $_msg_code O codigo da mensagem a ser traduzida
        * @param boolean $_sigla Se retorna a sigla em lugar da mensagem completa
        * @param boolean $_text_case Se o texto retorna o texto como cadastrado, em maiusculas ou minusculas
        *                                                1 - maiuscula
        *                                                2 - minuscula
        *                                          outro - como estiver cadastrado
        *
        * @return string  O texto traduzido, o texto padrao ou o codigo da mensagem
        *
        */ 
        function getText( $_msg_code, $_sigla=false, $_text_case=0, $_args = array() ) {
            
            if(is_array($_sigla)) {
                $_args = $_sigla;
                $_sigla = false;
            }
            if(is_array($_text_case)) {
                $_args = $_text_case;
                $_text_case = 0;
            }
            if(!is_bool($_sigla))  $_sigla = false;
    
            if(!empty($_msg_code) && ($this->translateMessage)) {
               $_msg_text = $this->_getStdText( &$_msg_code, &$_sigla, &$_text_case, &$_args);
            }
            else {
               $_msg_text = $_msg_code;
            }
    
                return $_msg_text;
    
        } // end func: getText
    
       /**
        * Metodo para retornar a mensagens de erros ocorridas
        * 
        * @access public
        * @name   getMessage
        */
        function getMessage() {
          return $this->mensagem;
        } // end func: getMessage
        
       /**
        * Metodo para retornar se houve erro ou nao na classe
        *
        * @access public
        * @return boolean  TRUE  - houve erro ao processar a classe
        *                             FALSE - nao houve erro
        */
        function isError() {
          return $this->error;
        } // end func: isError
        
     /**
      * Atribui o caminho fisico para os arquivos de idiomas
      * 
      * devera conter as secoes dos arquivos de idiomas, conforme contextualizacao
      * <code>
      *  ...
      *  $_lang_sections = array(
      *                      'phpTranslator' => 'textos da classe de traducao',
      *                      'admin'             => 'Textos da secao administrativa',
      *                      'home'              => 'textos da secao principal',
      *                      'and son on'      => 'e assim por diante...');
      *  
      *  $objTranslator->setLangFileSections($_lang_sections);
      *  ...
      * </code>
      * @param string $_languageFilePath O caminho para os arquivos de idiomas
      * @var array
      * @since v 0.2.0-40
      */
      function setLangFileSections($_languageSections=array()) {
          if(empty($_languageSections)) {
              $this->message = "Impossivel processar traducao por secoes, secoes nao informadas.";
              $this->error = true;
          }
          else {
              $this->languageSections = $_languageSections;
              $this->error = false;
          }
        return !$this->error;
      }
     
       /**
        * Atribui o caminho fisico para os arquivos de idiomas
        * 
        * @param string $_languageFilePath O caminho para os arquivos de idiomas
        */ 
        function setLangFilePath($_languageFilePath="") {
             if (!empty($_languageFilePath))
                $this->languageFilePath = $_languageFilePath;
        } // end func: setLangFilePath
     
       /**
        * Mostra o formulario de selecao de contextos
        * @access private
        * @since v 0.2.0-40
        */ 
        function showTagHeader(&$_objTmpl) {
            if ($this->languageFileInSections)
	            if(!is_object($_objTmpl)) {
	                    $this->mensagem = $this->getText('#phptranslator_objTemplate#').$this->getText('#phptranslator_not found#');
	                    if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
	                    $this->error = true;
	            }
	            else {
                    if(is_array($this->languageSections) and !empty($this->languageSections)) {
                       $_list = array();
                       foreach($this->languageSections as $_tag => $_tag_title) {
                           $_tag_current = '';
                           if($_tag == $this->languageSectionActive)
                               $_tag_current = 'TagCurrent';
                               
                           $_arrAux = array( 
                                          array( 
                                                 'TAG_NAME' => $_tag,
                                                 'TAG_HEADER_ACTIVE' => $_tag_current,
                                                 'TAG_HEADER' => $this->getText($_tag),
                                                 'TAG_HEADER_TITLE' => $this->getText($_tag_title)
                                                )
                                         );
                         $_list = array_merge($_list,$_arrAux);
                       }
                       /*
                       echo $this->languageSectionActive;
                       if('tradutor' == $this->languageSectionActive)
                           $_tag_current = 'TagCurrent';
                               
                        $_list = array_merge($_list,
                                                                    array( 
                                                                      array( 
                                                                             'TAG_NAME' => 'tradutor',
                                                                             'TAG_HEADER_ACTIVE' => $_tag_current,
                                                                             'TAG_HEADER' => $this->getText('tradutor'),
                                                                             'TAG_HEADER_TITLE' => $this->getText('Classe Tradutora')
                                                                            )
                                                                    )
                                        );
                        */
                       $_objTmpl->addRows( 'tmplTagHeader_list', $_list);
                       $_objTmpl->addVar('tmplTagHeader','translatorUrlPath',$this->translatorUrlPath);
                       $_objTmpl->addVar('tmplTagHeader','TAG_ACTIVE',$_POST['tag_active']);
                       $_objTmpl->displayParsedTemplate('tmplTagHeader'); 
                    }
                    else {
                        $this->mensagem = $this->getText('#phptranslator_section array not defined#');
                        if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
                        $this->error = true;
                    }
            }
        } // end func: showTagHeader
        
       /**
        * Atribui o caminho (URL) para a classe
        *
        * @param string $_translatorUrlPath A URL para a classe
        * @since v 0.2.0-40
        */ 
        function setURLPath($_translatorUrlPath="") {
             if (!empty($_translatorUrlPath))
                $this->translatorUrlPath = $_translatorUrlPath;
        } // end func: setURLPath
    
       /**
        * Atribui o sufixo para o arquivo de idiomas
        *
        * @param string $_file_sufix O sufixo a ser atribuido ao arquivo
        */ 
        function setLangFileSufix($_file_sufix="") {
             if (!empty($_file_sufix))
                $this->languageFileSufix = $_file_sufix;
        } // end func: setLangFileSufix
    
       /**
        * Atribui o prefixo para o arquivo de idiomas
        *
        * @param string $_file_prefix O prefixo a ser atribuido ao arquivo
        */ 
        function setLangFilePrefix($_file_prefix="") {
             if (!empty($_file_prefix))
                $this->languageFilePrefix = $_file_prefix;
        } // end func: setLangFilePrefix
    
       /**
        * Atribui os idiomas a serem usado na aplicacao
        * 
        * @access private
        * @param string $_abbr_i18n    ISO do Idioma em questao
        * @param string $_lang_choice Qual o padrao a ser lido e armazenado
        *                                    standard - o padrao para a aplicacao 
        *                                    target   - o idioma destino 
        *                                    user     - o idioma para o usuario 
        */ 
        function setLanguage($_abbr_i18n, $_lang_choice='standard') {
          switch ($_lang_choice) {
            case 'standard': {
                              $this->setLangSrc($_abbr_i18n);
                              break;
                             } 
            case 'target': {
                              $this->setLangTgt($_abbr_i18n);
                              break;
                             } 
            case 'user': {
                              $this->setLangUser($_abbr_i18n);
                              break;
                             } 
          }
        } // end func: setLanguage
    
        
       /**
        * Inicializa os arrays de idiomas especificos (padrao ou destino)
        * @access public
        */ 
        function initStdLanguages() {
           $this->buildLangArray();
           $this->buildLangArray('target');  
       }
       
       /**
        * Le os arquivos de idioma e os armazena em array especificos (padrao ou destino)
        * @access private
        * @param string $_lang_choice Qual o padrao a ser lido e armazenado<br>
        *                                    . standard - o padrao para a aplicacao<br>
        *                                    . target   - o idioma a ser mostrado para o usuario<br>
        */ 
        function buildLangArray($_lang_choice='standard') {
          switch ($_lang_choice) {
            case 'standard': {
                              $this->translatedTextStd = $this->_getLangFile();
                              $this->translated_text[$this->languageStd] = $this->translatedTextStd;
                              break;
                             } 
            case 'target': {
                              $this->translatedTextTgt = $this->_getLangFile($this->languageUser);
                              $this->translated_text[$this->languageUser] = $this->translatedTextTgt;
                              break;
                             } 
          }
        } // end func: buildLangArray
          
       /**
        * Constroi o array de traducao de idiomas (DE -> PARA)
        *
        * @access private
        */ 
        function getLangArray4Translate() {
            
            $_language_src = $this->translatedTextStd;
            $_language_tgt = $this->translatedTextTgt;
            
            if($_language_src) {
               //Idioma a traduzir
               // cria array para cada context
               foreach($_language_src as $_keys => $_key) {
                 if($_key['type'] != 'notran')   
                   $_list[$this->getText($_key['context'])]   =    array();
               }  // end foreach
            
               foreach($_language_src as $_keys => $_key) {
                 if(!empty($_language_tgt[$_keys]['text']) or !empty($_language_tgt[$_keys]['abbr']))
                    $_cor = "";
                 else
                    $_cor = T_BG_COLOR_TRADUZ;
              
                 if($_key['type'] != 'notran')   
                   $_arrAux = array(
                                  array( 'cor' => $_cor,
                                         'lang_src_key' => $_keys,
                                         'lang_language' => $this->languageUser,
                                         'lang_context' => $_key['context'],
                                         'lang_type' => $_key['type'],
                                         'lang_src' => $_key['text'],
                                         'lang_tgt' => $_language_tgt[$_keys]['text'],
                                         'lang_tgt_acr' => $_language_tgt[$_keys]['abbr']
                                        )
                                 );
    
                 //$_list = array_merge($_list, $_arrAux);
                 $_list[$this->getText($_key['context'])] = array_merge($_list[$this->getText($_key['context'])],$_arrAux);
               }  // end foreach
            }
    
            if(empty($_list))
               $_list = false;
    
            return $_list;
        } // end Function getLangArray4Translate
    
       /**
        * Constroi o array de listagem de idioma padrao
        *
        * @access private
        */ 
        function getLangArray4List() {
            $_language_src = $this->translatedTextStd;
            //Idioma a traduzir
            if(!empty($_language_src)) {
               // cria array para cada context
               foreach($_language_src as $_keys => $_key) {
                 if($_key['type'] != 'notran')   
                   $_list[$this->getText($_key['context'])]   =    array();
               }  // end foreach
            
               foreach($_language_src as $_keys => $_key) {
                 if($_key['type'] != 'notran') {
                   $_arrAux = array( 
                                  array( 
                                         'list_lang' => $this->languageStd,
                                         'list_lang_code' => $_keys,
                                         'list_lang_context' => $_key['context'],
                                         'list_lang_type' => $_key['type'],
                                         'list_lang_message' => $_key['text'],
                                         'list_lang_abbr' => $_language_src[$_keys]['abbr']
                                        )
                                 );
    
                   $_list[$this->getText($_key['context'])] = array_merge($_list[$this->getText($_key['context'])],$_arrAux);
                 }   
               }  // end foreach
            }  
            if(empty($_list))
               $_list = false;
    
            return $_list;
        } // end Function getLangArray4List
        
       /**
        *  Constroi os arrays de traducao e listagem de idioma padrao
        *
        * @access private
        */ 
        function buildArrayVars() {
           $this->arrLanguageLang = $this->getLangArray4Translate();
           $this->arrLanguageList = $this->getLangArray4List();
           if(!empty($this->arrLanguageLang))
              ksort($this->arrLanguageLang);
           if(!empty($this->arrLanguageList))
              ksort($this->arrLanguageList);
        } // end Function buildArrayVars
    
       /**
        * Constroi string de conteudo do arquivo a ser salvo
        * 
        * @access private
        * @param array $_lang_tgt_text_file Idioma a ser salvo
        */ 
        function buildStr4File($_lang_tgt_text_file) {
           $_new_target_file = "";
           if(is_array($_lang_tgt_text_file)) {
              foreach($_lang_tgt_text_file as $_keys => $_values) {
                    $_text_test = $this->stripContraBarra(trim($_values['text'] ). trim($_values['abbr']));
                    $_keyCode = $this->stripContraBarra($_values['code']);
                    if( ! $_keyCode ) $_keyCode = $this->stripContraBarra($_keys);
                    if(!empty($_text_test)) {
                        $_new_target_file .= $this->stripContraBarra($_values['lang']).
                                             $this->_spaces($this->messageCountryLen-
                                                                        strlen($this->stripContraBarra($_values['lang'])));
                        $_new_target_file .= $_keyCode.
                                             $this->_spaces($this->messageCodeLen-strlen($_keyCode));
                                             
                        $_new_target_file .= $this->stripContraBarra($_values['context']).
                                             $this->_spaces($this->messageContextLen-
                                                                        strlen($this->stripContraBarra($_values['context'])));
                        $_new_target_file .= $this->stripContraBarra($_values['type']).
                                             $this->_spaces($this->messageTypeLen-
                                                                        strlen($this->stripContraBarra($_values['type'])));
                        $_new_target_file .= $this->stripContraBarra($_values['abbr']).
                                             $this->_spaces($this->messageAbbrLen-
                                                                        strlen($this->stripContraBarra($_values['abbr'])));
                        $_new_target_file .= $this->stripContraBarra($_values['text']); 
                        $_new_target_file .= T_CRLF ; 
                   }
               }
           }
           else {
             $this->Error = true;
             $this->mensagem = $this->getText('#phptranslator_array parameter required#');
             if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
             $_new_target_file = false;
            }
            
            return $_new_target_file;
        } // end Function buildStr4File
        
       /**
        * Salva o arquivo de idioma conforme definido nos padroes
        * 
        * @access private
        * @param string $_content_to_file Texto/conteudo do arquivo a ser salvo
        * @param string $_abbr_i18n Idioma do arquivo a ser salvo- se nao informado busca o idioma padrao
        * @param boolean $_file_increment Se o conteudo do arquivo sera incrementado - padrao eh sobrescrever
        * @return boolean  se o arquivo foi salvo ou nao
        */ 
        function saveLangFile($_content_to_file, $_abbr_i18n  = "", $_file_increment=false) {
            
            if(empty($_abbr_i18n))
              $_abbr_i18n  = $this->languageStd;
            
            $_file_name = $this->_makeFileName($_abbr_i18n);
            
            $this->error = true;
            
            if(is_writable($this->languageFilePath)) {
                if (is_writable($_file_name) or !file_exists($_file_name)) {
                    if(($_file_increment) and file_exists($_file_name))
                        $_resource = @fopen($_file_name,'w+');
                    else
                        $_resource = @fopen($_file_name,'w');
                        
                    if($_resource){
                      fwrite($_resource,$_content_to_file);
                      fclose($_resource);
                    }
                    else {
                      $this->mensagem = $this->getText('#phptranslator_file#')." ($_file_name) ".$this->getText('#phptranslator_without write permition#');
                      if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
                      $this->error = false;
                    }
                }
                else {
                  $this->mensagem = $this->getText('#phptranslator_file#')." ($_file_name) ".$this->getText('#phptranslator_without write permition#');
                  if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
                  $this->error = false;
                }
            }
            else {
              $this->mensagem = $this->getText('#phptranslator_directory#')." ($this->languageFilePath) ".$this->getText('#phptranslator_without write permition#');
              if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
              $this->error = false;
            }
            
            return $this->error;
        } // end func: SaveFile
    
       /*
        *     Metodos PRIVATE
        */ 
    
       /**
        *  Atribui o idioma padrao para a aplicacao
        *
        * @access private
        * @param string $_abbr_i18n  ISO do Idioma da aplicacao
        */ 
        function setLangSrc($_abbr_i18n) {
            $this->languageStd = $_abbr_i18n;
        } // end func: setLangSrc
    
       /**
        *  Atribui o idioma do usuario
        *
        * @access private
        * @param string $_abbr_i18n  ISO do Idioma do usuario
        */ 
        function setLangUser($_abbr_i18n) {
            $this->languageUser = $_abbr_i18n;
        } // end func: setLangUser
    
       /**
        *  Atribui o idioma do destino na traducao
        *
        * @access private
        * @param string $_abbr_i18n  ISO do Idioma target
        */ 
        function setLangTgt($_abbr_i18n) {
            $this->setLangUser($_abbr_i18n) ;
        } // end func: setLangTgt
        
       /**
        * Monta o nome do arquivo de idiomas
        * @access private
        *
        * @param string $_abbr_i18n Codigo ISO do idioma a ser usado
        *
        * @return string O nome do arquivo (incluindo o path)
        */ 
        function _makeFileName($_abbr_i18n) {
            if(empty($_abbr_i18n))
              $_abbr_i18n = $this->languageUser;
              
            $_file_name  = $this->languageFilePath;
            if($this->languageFilesubdir)
                $_file_name .= $_abbr_i18n."/";
            
            $_file_name .= $this->languageFilePrefix; 
            if ($this->languageFileInSections)
                if(!empty($this->languageSectionActive))
                  $_file_name .= $this->languageSectionActive."."; 
                
            $_file_name .= $_abbr_i18n;
            $_file_name .= $this->languageFileSufix;
            $this->error = false;
            
            if(!is_file($_file_name))  {
               $this->mensagem = $this->getText('#phptranslator_file#')." ($_file_name) ".$this->getText('#phptranslator_not found#');
               if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
               $this->error = true;
            }
                            
            return $_file_name;
            
        } // end func: MakeFileName
        
       /**
        * Idioma a ser traduzido para a aplicacao. 
        * Se o preferido pelo usuario ou o do Browser em uso ou o padrao da aplicacao
        * @access private
        */ 
        function _getLanguage() {
    
            // faz insercao dos textos padroes para a aplicacao (conforme o idioma
            $_language = ""; 
            if(!empty($this->languageUser))
                $_language = $this->languageUser;
            elseif(!empty($this->_browserLanguage))
                $_language = $this->_browserLanguage;
            else
                $_language = $this->languageStd;
    
           return $_language;
        } // end func: _getLanguage
    
       /**
        * Busca o texto a ser traduzido dentro do array de idiomas
        *
        * Busca a traducao do texto - caso o texto traduzido nao exista retorna o texto padrao e caso este 
        * tambem nao exista retorna o codigo de pesquisa
        *
        * @access private
        * @param string $_msg_code O codigo da mensagem a ser traduzida
        * @param boolean $_sigla Se retorna a sigla em lugar da mensagem completa
        * @param boolean $_text_case Se o texto retorna o texto como cadastrado, em maiusculas ou minusculas
        *                                                1 - maiuscula
        *                                                2 - minuscula
        *                                          outro - como estiver cadastrado
        * @param array $_args Sao os argumentos nessarios para substituir no texto que contenha %n
        *
        * @return string  O texto traduzido, o texto padrao ou o codigo da mensagem
        *
        */ 
        function _getStdText( $_msg_code='', $_sigla=false, $_text_case=0, $_args = array() ) {
           if(!empty($_msg_code))
            /*
             * - A chave de procura deve estar em minusculas bem como o conteudo do arquivo de idiomas
             */
             $_key_lower_text = strtolower($_msg_code);
             
             $_lang_array_aux = $this->translated_text[$this->_getLanguage()];
             if(@array_key_exists($_key_lower_text, $_lang_array_aux)) {
                   if(@array_key_exists('text', $_lang_array_aux[$_key_lower_text])) {
                      $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['text'];
                      if($_sigla) 
                        if(@array_key_exists('abbr', $_lang_array_aux[$_key_lower_text]))
                          $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['abbr'];
                   }
             }
             else { 
                $_lang_array_aux = $this->translatedTextStd;
                if(@array_key_exists($_key_lower_text, $_lang_array_aux)) {
                   if(@array_key_exists('text', $_lang_array_aux[$_key_lower_text])) {
                      $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['text'];
                      if($_sigla) 
                        if(@array_key_exists('abbr', $_lang_array_aux[$_key_lower_text]))
                          $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['abbr'];
                   }
                }
                else {
                    $_lang_array_aux = $this->translatedTextSelf;
                    if(@array_key_exists($_key_lower_text, $_lang_array_aux)) {
                        if(@array_key_exists('text', $_lang_array_aux[$_key_lower_text])) {
                            $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['text'];
                            if($_sigla) 
                                if(@array_key_exists('abbr', $_lang_array_aux[$_key_lower_text]))
                                  $_msg_code_aux = $_lang_array_aux[$_key_lower_text]['abbr'];
                        }
                    }
                }
           }
           
           switch ($_text_case) {
                case 1: // tudo em minusculas
                        $_msg_code_aux = strtolower($_msg_code_aux);
                        break;
                case 2: // tudo em maiusculas
                        $_msg_code_aux = strtoupper($_msg_code_aux);
                        break;
            }
            
            if(empty($_msg_code_aux))
               $_msg_code_aux = $_msg_code;
            
            $_argcPercentage = substr_count( $_msg_code_aux, "%" );
            if( $_argcPercentage > 0 ) { // tem % no texto
                // substitui os %n do texto pelos parametros do array de argumentos
                for( $i=0; $i<$_argcPercentage; $i++ ) {
                    $_argsValue = "%".($i+1);
                    if( strpos( $_msg_code_aux, $_argsValue ) <> 0 ) {
                        $_msg_code_aux = str_replace($_argsValue, $_args[$i], $_msg_code_aux );
                    }
                }
            }

            return $_msg_code_aux;
        } // end func: _getStdText
        
       /**
        * Monta uma string contendo espacos em branco
        * @access private
        * @param int $_num Numero de espacos que a string contera
        * @return string Espacos em branco
        */ 
        function _spaces($_num=0)  {
          if($_num>0)
             for($_inc=1;$_inc<=$_num;$_inc++) {
               $_spaces .= " ";
             }
          return $_spaces;
         } // end func: _spaces
    
       /**
        * cria template para a propria classe usar
        * @access private
        * @return patTemplate
        */
        function &_createTemplate() {
             global $option, $mosConfig_absolute_path;
             
             if(defined( '_VALID_MOS' )) {
                 require_once($mosConfig_absolute_path.'/includes/patTemplate/patTemplate.php' );
                 $tmpl =& patFactory::createTemplate();
                 $tmpl->setRoot( dirname( __FILE__ ) . '/templates' );
             }
             else {
                    require_once( $this->classSelfPath.'/classes/pat/patErrorManager.php' );
                    require_once( $this->classSelfPath.'/classes/pat/patTemplate.php' );
                    $tmpl = new patTemplate();
                    $tmpl->setNamespace("mos");
             }
             $this->_objTmpl = $tmpl;
             return $tmpl;
        } // end func: _createTemplate
         
    
       /**
        * Salvar dados apos alteracoes ou exclusoes de mensagens codificadas
        * 
        * @access private
        */ 
        function _langSave($_lang_target,$_abbr_i18n_save) {
             $_text4file = $this->buildStr4File($_lang_target);
             if(!is_bool($_text4file)) {
                $_saved = $this->saveLangFile($_text4file,$_abbr_i18n_save);
                if(!$_saved)
                    if($this->inDebugMode() ) echo $this->getMessage();
             }
             elseif(!($_text4file))
               if($this->inDebugMode() ) echo $this->getMessage();
        } // end func: _langSave
    
       /**
        * Excluir mensagem do idioma padrao
        *
        * @access private
        * @param array $_lang_data_selected Dado do idioma padrao a ser excluido
        * 
        */ 
        function _langCodeDelete($_lang_data_selected) {
          foreach($_lang_data_selected as $_keys => $_key) {
            unset( $this->translatedTextStd[$this->stripContraBarra($_keys)]);
          }
        } // end func: _langCodeDelete
    
       /**
        * Busca o arquivo de idiomas
        *
        * @access private
        * @param string $_abbr_i18n O codigo ISO do idioma a ser tratado
        *
        * @return array Contem os dados do idioma
        */ 
        function _getLangFile($_abbr_i18n="") {
          
            $this->error = false;
    
            if(empty($_abbr_i18n))
              $_abbr_i18n = $this->languageStd;
            
            $_src_file_name =   $this->_makeFileName($_abbr_i18n);
            
            if(!file_exists($_src_file_name)) {
               $this->mensagem = $this->getText('#phptranslator_language file#')." ($_src_file_name) ".
                                                $this->getText('#phptranslator_not found#');
               if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
               $this->error = true;
               return false;
            }
            
            $_src_file = file($_src_file_name);
    
            // monta idioma padrao
            foreach($_src_file as $_keys => $_values) {
              $_lang = trim(substr($_values,0,$this->messageCountryLen));
              $_msg_code = strtolower(trim(substr($_values,$this->messageCountryLen,$this->messageCodeLen)));
              
              $_str_start_aux = $this->messageCountryLen+$this->messageCodeLen;
              $_msg_context = trim(substr($_values,$_str_start_aux,$this->messageContextLen));
              
              $_str_start_aux = $this->messageCountryLen+$this->messageCodeLen+$this->messageContextLen;
              $_msg_type = trim(substr($_values,$_str_start_aux,$this->messageTypeLen));
              
              $_str_start_aux = $this->messageCountryLen+$this->messageCodeLen+
                                $this->messageContextLen+$this->messageTypeLen;
              $_msg_abbr = trim(substr($_values,$_str_start_aux,$this->messageAbbrLen));
              
              $_str_start_aux = $this->messageCountryLen+$this->messageCodeLen+
                                $this->messageContextLen+$this->messageTypeLen+$this->messageAbbrLen;
              $_msg_text = trim(substr($_values,$_str_start_aux));
              
              $_language_data[$_lang][$_msg_code]['text'] = $_msg_text;
              $_language_data[$_lang][$_msg_code]['context'] = $_msg_context;
              $_language_data[$_lang][$_msg_code]['type'] = $_msg_type;
              $_language_data[$_lang][$_msg_code]['abbr'] = $_msg_abbr;
              $_language_data[$_lang][$_msg_code]['lang'] = $_abbr_i18n;
            }
            
            @asort($_language_data[$_abbr_i18n]);

            return $_language_data[$_abbr_i18n];
            
        } // end func: _getLangFile
        
	   /**
	    * Atribui o tamanho do campo de codigo (abbrI18N) do idioma
	    * @access public
	    * @param boolean $_length Tamnho a ser atribuido
	    */ 
	    function setLangCountryLength( $_length ) {
	   		$this->messageCountryLen = $_length;
	    } // end func: setLangCountryLength
        
	   /**
	    * Atribui o tamanho do campo de codigo da messagem
	    * @access public
	    * @param boolean $_length Tamnho a ser atribuido
	    */ 
	    function setLangMsgCodeLength( $_length ) {
	   		$this->messageCodeLen = $_length;
	    } // end func: setLangMsgCodeLength
        
	   /**
	    * Atribui o tamanho do campo de tipo da messagem
	    * @access public
	    * @param boolean $_length Tamnho a ser atribuido
	    */ 
	    function setLangMsgTypeLength( $_length ) {
	   		$this->messageTypeLen = $_length;
	    } // end func: setLangMsgTypeLength
        
	   /**
	    * Atribui o tamanho do campo de contexto da messagem
	    * @access public
	    * @param boolean $_length Tamnho a ser atribuido
	    */ 
	    function setLangMsgContextLength( $_length ) {
	   		$this->messageContextLen = $_length;
	    } // end func: setLangMsgContextLength
        
	   /**
	    * Atribui o tamanho do campo da abreviatura  da messagem
	    * @access public
	    * @param boolean $_length Tamnho a ser atribuido
	    */ 
	    function setLangMsgAbbrLength( $_length ) {
	   		$this->messageAbbrLen = $_length;
	    } // end func: setLangMsgAbbrLength
             
	   /**
	    * Atribui que o caminho dos arquivos de idiomas ficarao em subdiretorios abbrI18N
	    * @access public
	    * @param boolean $_filesInSubDirs TRUE - em subdiretorio abbrI18N 
	    * 						 	     FALSE - sem subdiretorio abbrI18N (default)
	    */ 
	    function setLangFilesInSubDirs($_filesInSubDirs=false) {
	   		$this->languageFilesubdir = $_filesInSubDirs;
	    } // end func: setLangFilesInSubDir
	    
	   /**
	    * Atribui que os arquivos de idiomas serao seccionados conforme contextualizacao
	    * @access public
	    * @param boolean $_filesInSections TRUE - seccionados 
	    * 							      FALSE -  nao seccionados (default)
	    */ 
	    function setLangFilesInSections($_filesInSections=false) {
	       $this->languageFileInSections = $_filesInSections;
	    } // end func: setLangFilesInSections
	    
	   /**
	    * Atribui a secao ativa a ser mostrada a TAG em "showTagHeader"
	    * @access public
	    * @param string $_activeSection O nome da seccao ativa (ex: admin ou setup)
	    * 								Obs: Deve ser o nome interno e nao a traducao
	    */ 
	    function setActiveSection($_activeSection="") {
	       $this->languageSectionActive = $_activeSection;
	    } // end func: setActiveSection
        
	   /**
	    * Se necessario remove a contra barra do texto
	    * @access private
	    * @param string $_text O texto a ser tratado
	    */ 
        function stripContraBarra( $_text ) {
            if( get_magic_quotes_gpc() ) {
                $_text = stripslashes($_text);
            }
            
            return $_text;
        } // end stripContraBarra
	    
	   /**
	    * Ativa o modo "debug" do phpTranslator passando a mostrar as mensagens internas
	    * @access public
	    */ 
        function debugOn() {
            $this->_debugTranslator = true;
        } // end debugOn
	    
	   /**
	    * Desativa o modo "debug" do phpTranslator deixando de mostrar as mensagens internas
	    * @access public
	    */ 
        function debugOff() {
            $this->_debugTranslator = false;
        } // end debugOff
	    
	   /**
	    * Desativa o modo "debug" do phpTranslator deixando de mostrar as mensagens internas
	    * @access public
        * @return boolean - True = em modo "debug"; FALSE = nao esta em modo "debug"
	    */ 
        function inDebugMode() {
            return $this->_debugTranslator;
        } // end inDebugMode
	    
       /*
        *     Deprecated Methods 
        */ 
        
       /**
        * @access private
        * @deprecated since v 0.1.41
        * @see setURLPath()
        */ 
        function setTabPaneURLPath($_translatorUrlPath="") {
            $this->setURLPath($_translatorUrlPath);
        }
        
       /**
        * @access private
        * @deprecated since v 0.1.41
        * @see setLangFilePath()
        */ 
        function setFilePath($_languageFilePath="") {
			$this->setLangFilePath($_languageFilePath);
        } // end func: setFilePath
     
       /**
        * @access private
        * @deprecated since v 0.1.41
        * @see setLangFileSections()
        */ 
      	function setLangSections($_languageSections=array()) {
      		$this->setLangFileSections($_languageSections);
      	}
        
       /**
        * @access private
        * @deprecated since v 0.1.41
        * @see setLangFilePrefix()
        */ 
        function setFilePrefix($_file_prefix="") {
             $this->setLangFilePrefix($_file_prefix);
        } // end func: setFilePrefix
        
       /**
        * Prove a interface de cadastramento de codigos de mensagems ou a de traducao
        * @access private
        * @deprecated since v 0.1.99-28
        * @see translatorGUI()
        */ 
        function Translate( $_translate_only=true ) {
            $this->translatorGUI( $_translate_only );
        }
        /*  END OF DEPRECATED METHODS */
       } // end Class: Translator
?>