-
Requirjs 와 jquery 설치 방법 (+i18n)WEB/Javascript 2013. 10. 19. 16:30반응형
------------------------------------------default.html
<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css">
<!--link rel="stylesheet" href="/assets/styles/bootstrap.min.css"-->
</head>
<body>
<?=$contents?>
<script data-main="/assets/scripts/init" src="/assets/scripts/require.js"></script>
</body>
</html>
-------------------------------------------init.js
requirejs.config({
baseUrl: "/assets/scripts",
shim: {
"jquery": {
exports: "$"
},
"facebook" : {
exports : "FB"
},
'bootstrap': {
deps: ["jquery"],
exports: "$"
},
'json2' : {
exports: "JSON"
}
},
paths: {
'jquery': '//code.jquery.com/jquery-1.10.2.min',
'facebook': "//connect.facebook.net/en_US/all",
'bootstrap': "//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min",
'JSON': "//cdn.jsdelivr.net/json2/0.1/json2.min"
},
config: {
i18n: {
locale: localStorage.getItem('locale') || navigator.language || window.navigator.language
}
}
});
requirejs(['jquery','bootstrap'],function($, bs){
var url = location.pathname;
if(url=='/') {
url = "index";
}else{
url = url.substr(1);
require([url],function(url){
});
}
});
-------------------------------------------------------nls/lang.js
define({
"root": {
"title": "Sex Ratio",
"opratio":"Opposite sex ratio",
"message":"'s Facebook Sex Ratio is",
"wm" : "Female",
"m" : "Male",
"share" : "Share on Facebook",
"alert_com" : "Photo has been shared",
"alert_err" : "Error",
"start" : "Start",
"signup" : "Agree to join Useless.kr",
"user_msg" : "Please leave your message"
},
"cn": true,
"de": true,
"en": true,
"es": true,
"hi": true,
"ja": true,
"ko": true,
"po": true,
"ru": true,
"fr": true
});
-----------------------------------------------------------nls/ko/lang.js
define({
"title": "남녀비율",
"opratio":"이성비율",
"message":"님의 Facebook 남녀비율은",
"wm" : "여성",
"m" : "남성",
"share" : "페이스북에 공유하기",
"alert_com" : "사진이 올라갔습니다.",
"alert_err" : "에러",
"start" : "시작하기",
"signup" : "Useless.kr 가입에 동의합니다.",
"user_msg" : "당신의 메시지를 남겨주세요."
});
반응형'WEB > Javascript' 카테고리의 다른 글
20140331 자바스크립트, Ajax (0) 2014.03.31 정규식 사용방법 (0) 2013.09.25 prototype (0) 2013.09.16