我如何本地化jquery?

时间:2017-07-25 17:03:54

标签: javascript jquery autocomplete datepicker localization

我使用jquery作为日期选择器,它工作正常。对于锻炼,我使用了来自jquery的本地文件,我将其本地化为德语输出(Mittwoch vs Wednesday,Mai vs May ......) 一切都很好。我还想使用自动完成功能。 从jquery也很好,但我必须包括一个在线版本的jquery,它以某种方式覆盖了本地设置。 Eversgthing工作正常,但是datepicker再次是英文。我可以本地化脚本还是有Ger版本? 谢谢 海啸 一些:代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
      <title>www.olivereikel.de - Rem-O Reminder Online</title>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
      <link rel="icon" type="image/ico" href="../mainimages/remo_favicon.ico">


                                                                               <link rel="stylesheet" type="text/css" href="../maincss/styles.css" media="screen and (min-width: 981px)"/>

<!-- Attribut "Print" f�r die PCausgabe -->
<link rel="stylesheet" type="text/css" href="../maincss/styles_mobil.css" media="screen and (max-width: 980px)"/>


<!-- <link href="../maincss/styles.css" rel="stylesheet" type="text/css" /> -->
<link href="../maincss/hamburger.css" rel="stylesheet" type="text/css" />

<!--<link href="../maincss/alphacube.css" rel="stylesheet" type="text/css">

<link href="../maincss/default.css" rel="stylesheet" type="text/css">
<link href="../maincss/manual.css" rel="stylesheet" type="text/css">   -->

<!--[if lte IE 7]>

<!--<link href="css/patches/patch_my_layout.css" rel="stylesheet" type="text/css" />              -->

<![endif]-->
 <script language='JavaScript' type='text/javascript'>

function wirklichloeschen(formname,quittung) {
    var antwort = confirm("Achtung! Mit dem Klick auf OK wird der Eintrag '"+quittung+"' endg&uuml;ltig aus der Datenbank gel&ouml;scht! Sind Sie sicher?")
    if (antwort==true){
        document.formname.submit(); 
    }
    else
    {
    return false;
    }
}
 </script>
<script language='JavaScript' type='text/javascript'>
window.addEvent('domready', function(){
$$('input.DatePicker').each( function(el){
new DatePicker(el);
});
});
</script>
<script language='JavaScript' type='text/JavaScript'>

function kategorie_waehlen()
{
document.kategorie_senden.submit();

}
</script> 
<script language='JavaScript' type='text/JavaScript'>
    function filtern(){
        document.filter_senden.submit();
        }
</script>
<script language='JavaScript' type='text/JavaScript'>
function kategorie_senden()
{
document.katabschicken.submit();
}
</script>
<script language='JavaScript' type='text/JavaScript'>
function vonoderan_senden()
{
document.katabschicken.submit();
}
</script>  
<script language="JavaScript" type="text/JavaScript">
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_openBrWindow(theURL,winName,features) { 
window.open(theURL,winName,features);
}
</script>

<!--********************tooltip********-->
    <script type="text/javascript">
    <!--
    wmtt = null;
    document.onmousemove = updateWMTT;
    function updateWMTT(e) {
    if (wmtt != null && wmtt.style.display == 'block') {
    var l = screen.availWidth - 550;
    var t = 20;
    wmtt.style.left =  l + 'px';
    wmtt.style.top = t + 'px';
    }
    }
    function showWMTT(id) {
    wmtt = document.getElementById(id);
    wmtt.style.display = "block";
    }
    function hideWMTT() {
    wmtt.style.display = "none";
    }
    -->
    </script>
     <!--   //******editor mit formatierung*************
 OF COURSE YOU NEED TO ADAPT NEXT LINE TO YOUR tiny_mce.js PATH -->
<script type="text/javascript" src="./js/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript" >
tinyMCE.init({
       mode : "exact",
             language : "de",
       elements : "nachrichtentextfeld"
        //theme : "simple"   //(n.b. no trailing comma, this will be critical as you experiment later)
});
</script >
<!-- //----------- Autologout------>
<script type='text/javascript'>
var sek = 600;
var timer;
function reset() 
{   
sek=600;
}
function countdown()
{
var restzeit = Math.round(sek/60);
sek--;          
document.getElementById('restlaufzeit').innerHTML=restzeit;     
document.getElementById('zaehler').style.width = sek/5 + 'px';
if(sek > 0){
timer = setTimeout('countdown()',1000);
}
else{
location.href='logout.php'; 
}  
}
</script>
<!-- <link rel="stylesheet" href="datepicker/jquery-ui.css" />
<script src="./datepicker/jquery-1.8.3.js"></script>
<script src="./datepicker/jquery-ui.js"></script> 
Alterdatepicker
-->
 <!-- Neuer Datepicker -->


<script src="./js/jquerymini.js" type="text/javascript"></script>
<script src="./js/jquerymini2.js" type="text/javascript"></script>
<link rel="stylesheet" href="../maincss/jquerycss.css"  type="text/css" media="all" />

<script src="./js/jquery-datepicker-de.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../maincss/datepicker.css">  


</head>
<body onload="countdown();init();" onmousemove="reset()" onkeydown="reset();" lang="de-DE"><a name="oben"></a>
<div id="page_margins">
<div class="headertimo">
<div class="headerlinks"><img src="../mainimages/remo_logo.png" alt="" class="toplogo" border="none"/>

</div>

<div class='loginkasten'><div class='logintxt'><div class='firmenname'>lizensiert f&uuml;r: <strong>Angela Merkel Krankenhaus</strong><br/> </div>Eingelogged: <strong>Herr&nbsp;Oliver&nbsp;Eikel
                        </strong> als <strong>'oleikel'</strong>.  
                        <br/>Berechtigung: <strong>Administrator</strong>.<form method='POST' action='logout.php'>
                            <input type='hidden' name='x' value='abmelden'><input type='submit' name='' value='abmelden'></form><br/>
                    </div><br/>    
                    <div class='zeitlogoutbox'>&nbsp;Nach <span id='restlaufzeit' style='width:auto;'>  </span> Minuten Unt&auml;tigkeit werden Sie automatisch ausgeloggt.&nbsp;<div style='border: 1px solid black; width:121px; padding:3px 3px 3px 3px;float:left;'><div id='zaehler' style='height: 10px; width: 100px;  background: #003399; '></div>
                </div>
                    </div>
                    </div></div>

<div class="time">
25.07.2017</div><!-- <script>
function weiterleitung(wohin) {
setTimeout("location.href='"+wohin+"';",1000);
}
</script> -->

   <h2 class='ueberschrift'>Neue Erinnerung</h2>
   </h2> 
   <script type="text/javascript">
          $(function() {$("#datepicker").datepicker();});
</script>    
<!-- ************* autotext -->
     <style>
     .ui-helper-hidden-accessible { display:none; }
     ul{list-style: none;
     border:1px solid grey;width:200px;
     }    input::-webkit-calendar-picker-indicator {
              opacity: 0;
           }
     </style>  
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>   
 <script>
         $(function () {
              $("#rowxxx").prop("disabled", true);
             var projects = [{value: "31",label:"1&1 Internet AG  - Telgte"},{value: "55",label:"Abdel Ghani Emad - Telgte"},{value: "53",label:"Ahmann Jürgen - Telgte"},{value: "44",label:"Ahmann Walter - Telgte"},{value: "107",label:"Ahmann Bianca - Telgte"},{value: "42",label:"Albrecht Sabrina - Telgte"},{value: "3",label:"Amazon.de  - Telgte"},{value: "14",label:"Bäuerle Beate - Telgte"},{value: "89",label:"Benning Charlotte - Telgte"},{value: "78",label:"Berger Karl-Heinz - Telgte"},{value: "58",label:"Borggreve Alfred - Telgte"},{value: "108",label:"Borggreve Marco - Telgte"},{value: "13",label:"buch.de internetstores AG  - Telgte"},{value: "91",label:"Buchmayr Karl-Heinz - Telgte"},{value: "7",label:"computeruniverse.net GmbH  - Telgte"},{value: "95",label:"Cremann Jochen - Telgte"},{value: "76",label:"Dahmen Norbert - Telgte"},{value: "65",label:"Demmer Heinz - Telgte"},{value: "9",label:"Deutsche Post AG  - Telgte"},{value: "39",label:"Diekmannshemke Günter - Telgte"},{value: "17",label:"Diekmannshemke Günther - Telgte"},{value: "59",label:"Dierkes Detlev - Telgte"},{value: "2",label:"Domainfactory GmbH  - Telgte"},{value: "60",label:"Dorgeist Theodor - Telgte"},{value: "18",label:"EDV & Büroservice Heuer GmbH  - Telgte"},{value: "23",label:"Eikel Ludger - Telgte"},{value: "87",label:"Ernst Friedrich - Telgte"},{value: "26",label:"Füchtenghans August - Telgte"},{value: "47",label:"Fechner Jörg - Telgte"},{value: "93",label:"Fellenberg Peter - Telgte"},{value: "111",label:"Fichert Iris - Telgte"},{value: "66",label:"Finanzamt Warendorf  - Telgte"},{value: "64",label:"Flotmann Martin - Telgte"},{value: "85",label:"Grothaus Georg - Telgte"},{value: "12",label:"Grunden Thomas - Telgte"},{value: "86",label:"Hahn Wolfgang - Telgte"},{value: "51",label:"Harsch Martin - Telgte"},{value: "79",label:"Heitmann Rolf - Telgte"},{value: "75",label:"Holzmüller Frank - Telgte"},{value: "80",label:"Jeschke Peter - Telgte"},{value: "105",label:"Johnson Roy - Telgte"},{value: "40",label:"Kühn Mathias - Telgte"},{value: "81",label:"Kammer Reinhard - Telgte"},{value: "97",label:"Kamphans Wolfgang - Telgte"},{value: "32",label:"KFW Bank  - Telgte"},{value: "1",label:"Kirchner Sven - Telgte"},{value: "37",label:"Kirchner Sven - Telgte"},{value: "102",label:"Kirchner Karin - Telgte"},{value: "52",label:"Kleideiter Michael - Telgte"},{value: "90",label:"Kloppenborg Ralf - Telgte"},{value: "83",label:"Klosterkamp Markus - Telgte"},{value: "54",label:"Kluge Oliver - Telgte"},{value: "57",label:"Koebbert Hans-Otto - Telgte"},{value: "38",label:"Kretschmmar GmbH  - Telgte"},{value: "72",label:"Kretzer Franz-Josef - Telgte"},{value: "99",label:"Landwehr Martin - Telgte"},{value: "10",label:"Lepper Roland - Telgte"},{value: "20",label:"Möhlmann Ralf - Telgte"},{value: "100",label:"Möllers Melanie - Telgte"},{value: "69",label:"Meyers Michael - Telgte"},{value: "110",label:"Neue Benedikt - Telgte"},{value: "6",label:"Poster XXL AG  - Telgte"},{value: "70",label:"Prinz Karuna - Telgte"},{value: "96",label:"Puga Josef - Telgte"},{value: "48",label:"Rösmann Bernd-Rainer - Telgte"},{value: "25",label:"Rüter Ludger - Telgte"},{value: "36",label:"Rickert Günther - Telgte"},{value: "33",label:"Rodenkirchen Bernhard - Telgte"},{value: "49",label:"Rutsch Heidrun - Telgte"},{value: "84",label:"Salger Klaus - Telgte"},{value: "94",label:"Schäfer Jutta - Telgte"},{value: "16",label:"Schabhüser Martin - Telgte"},{value: "45",label:"Schneider Norbert - Telgte"},{value: "68",label:"Schulze Helmut - Telgte"},{value: "50",label:"Schulze Helmut - Telgte"},{value: "82",label:"Schulze Zumkley Renate - Telgte"},{value: "74",label:"Schwering Herbert - Telgte"},{value: "71",label:"Spenst Julia - Telgte"},{value: "103",label:"Stein Herbert - Telgte"},{value: "88",label:"Stuppe Ludwig - Telgte"},{value: "104",label:"Thaele-Boehnke Doris - Telgte"},{value: "101",label:"Thoholte Hubertus - Telgte"},{value: "56",label:"Tomasello Camelo - Telgte"},{value: "5",label:"van de Vint Ian - Telgte"},{value: "24",label:"van Dijk Gustaaf Christiaan - Telgte"},{value: "67",label:"Vartmann Michael - Telgte"},{value: "98",label:"Vogelpohl Sylvia - Telgte"},{value: "106",label:"Vogelsang Adolf - Telgte"},{value: "61",label:"Wegener Stefanie - Telgte"},{value: "92",label:"Weidig Peter - Telgte"},{value: "77",label:"Wessels Beate - Telgte"},{value: "43",label:"Wortmann Franjo - Telgte"},{value: "11",label:"Yello Strom GmbH  - Telgte"},{value: "73",label:"Züwerink André - Telgte"},{value: "63",label:"Zeisberger Julia - Telgte"},{value: "34",label:"Zschoke Caroline - Telgte"}];
            $("#empfaenger").autocomplete({
                minLength: 3,
                source: projects,
                focus: function (event, ui) {
                    $("#empfaenger").val(ui.item.label);
                    return false;
                },
                select: function (event, ui) {
                    $("#empfaenger").val(ui.item.label);
                    $("#empfaenger_id").val(ui.item.value);
                    $("#rowxxx").prop("disabled", false);
                    return false;
                },
                selectFirst: true,
                click: function (event, ui) {
                    if (ui.item == null) {
                        //here is null if entered value is not match in suggestion list
                        $(this).val((ui.item ? ui.item.id : ""));
                        //                 $( "#empfaenger_id" ).val( ui.item.value )="";
                        //               $( "#empfaenger" ).val( ui.item.value )="";
                        document.getElementById('rowxxx').disabled = true;
                    }
                    else
                        document.getElementById('rowxxx').disabled = false;
                }
            })
            $("#empfaenger").autocomplete("instance")._renderMenu = function (ul, items) {
                var that = this;
                $.each(items, function (index, item) {
                    that._renderItemData(ul, item);
                });
                inp = $("#empfaenger");
                if (inp.val() == "") {
                    $("#rowxxx").prop("disabled", true);
                } else {
                    var found = false;
                    $.each(items, function (idx, item) {
                        if (item.label == inp.val()) {
                            found = true;
                            return false;
                        } else return true;
                    });
                    if (found) $("#rowxxx").prop("disabled", false);
                    else $("#rowxxx").prop("disabled", true);
                }
            };
        }); // dies fehlte
    </script>

这两行:

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 

是问题所在。没有datepickers在德语中工作正常,但自动完成功能根本不起作用。有了它,两个脚本都在工作,但英文的日期选择器...... 任何的想法? 海啸

1 个答案:

答案 0 :(得分:0)

谢谢,这解决了它: How do I localize the jQuery UI Datepicker? 除了ger版本,我必须定义一些Vars,如Mon,Sat和Sun ...... 不行吗! 海啸