2

저는 현대의 Javascript에 비교적 익숙합니다 (10 년 전 항상 사용했습니다). 그리고 globalize.js에 문제가 있습니다. 여기 Globalize.format이 다른 로케일이나 날짜 형식으로 작동하지 않습니다.

그것이

<script src ="{% static "js/jquery-2.1.0.min.js" %}" type="text/javascript"></script> 
<script src ="{% static "js/node_modules/globalize/dist/globalize.min.js" %}" type="text/javascript"></script> 
<script> 
    $.get("{% static "json/en/ca-gregorian.json" %}", Globalize.load); 
    $.get("{% static "json/de/ca-gregorian.json" %}", Globalize.load); 
    $.get("{% static "json/supplemental/likelySubtags.json" %}", Globalize.load); 
    $.get("{% static "json/supplemental/timeData.json" %}", Globalize.load); 
    $.get("{% static "json/supplemental/weekData.json" %}", Globalize.load); 
    console.log("short:" + Globalize.format(new Date(2010, 10, 30, 17, 55), { datetime: "short" })); 
    console.log("medium:" + Globalize.format(new Date(2010, 10, 30, 17, 55), { datetime: "medium" })); 
    console.log("long:" + Globalize.format(new Date(2010, 10, 30, 17, 55), { datetime: "long" }, "de")); 
</script> 

세계화에 관한 나는 머리에있어 무엇을 그리고 여기 출력 : 당신이 볼 수 있듯이

short:11/30/2010 5:55:00 PM (index):21 
medium:11/30/2010 5:55:00 PM (index):22 
Uncaught TypeError: Cannot read property 'calendar' of null 

, 나는 두 가지 문제로 실행 해요 - {datetime :} 매개 변수는 출력에 전혀 영향을 미치지 않는 것 같습니다. 더 중요한 것은 왜 날짜를 다른 언어로 번역 할 수 없는지를 알 수 없습니다. 포함 물이 누락 되었습니까? 문제 목록에있는 다른 스레드는 날짜를 현지화하기 위해 필요한 모든 것을 가리 킵니다. 심지어

new Date().toLocaleDateString('de', { year: 'numeric', month: 'long', day: 'numeric' }) 

나 :

new Date().toLocaleDateString(Globalize.culture().name, { year: 'numeric', month: 'long', day: 'numeric' }) 

Globalize.culture().name 당신이 수동으로 세계화하기 위해 가능한 문화를 추가하거나 각각에 대해 globalize.culture.{culture}[.min].js 파일을 가져 와서 한 가정을

+0

date.js 모듈이 누락되었을 수 있습니다. 날짜 ... * 떨림 * – Jerther

답변

0

난 당신이 대신를 사용하는 것이 좋습니다 , 예 : globalize.culture.fr.min.js