요즘사이트들은 거의 utf8을 기준으로 만들어져있겠지만 joinc 사이트가 만들어진 2000년에는 euckr이 대세였고, 시대조류? 맞지 않게 euckr을 유지하고 있다. utf-8로 바꿀걸 생각해봤지만 워낙에 귀찮아서..
문제는 disuqs가 euckr을 전혀 지원하지 않는데 있다. 그러다보니 브라우저에 따라서 컨텐츠가 깨지는 문제가 발생한다. Firefox(:12) 에서는 잘되는데.. IE에서는 깨진다. 암튼 언제나 IE가 문제다. 그래도 (아마도)80%이상의 방문자가 IE를 사용하니 IE에서도 보이게 해줘야지..
해서 다음과 같은 간단한 함수를 만들어서 disuqs의 recent comment 컨텐츠 자체를 euckr 로 변경해 버렸다. php(:12)의 iconv(:12)함수를 사용했다.
이왕 이렇게 된게 Recent Comments같은 문자열까지 한글로 바꿔 버렸다. str_replace에 비용이 좀들어갈 것 같은데, 나중에 시간이 되면 static 페이지를 생성하는 스크립트를 만들어 봐야 겠다. 시간이 더 남으면 open api 형식으로 만들어서, 블로그등에도 가져다 쓸 수 있도록 해야 겠다. 우선은 이것으로 만족. 사이트 옆에 붙여놓은 위젯을 보면 (눈속임)한글화가 된 것을 확인할 수 있다.
Recent Comments 가져오기
function get_recent_comment() { $contents = array(); $handler = fopen('http://disqus.com/forums/joinc/combination_widget.js?num_items=5&color=blue&default_tab=recent','r'); if(!$handler) return 0; while(!feof($handler)) { $line = fgets($handler,1024); $line = iconv('utf-8', 'euckr', $line); if(ereg("^\t +<h3>", $line)) $line = str_replace('Recent Comments', '최근댓글', $line); if(ereg('combo-tab-recent', $line)) { $line = str_replace('Recent','최근댓글', $line); } if(ereg('combo-tab-people', $line)) { $line = str_replace('People','댓글러', $line); } if(ereg('combo-tab-popular', $line)) { $line = str_replace('Popular','높은인기', $line); } if(ereg("dsq-widget-meta", $line)) { $line = str_replace('hours ago','시간 전', $line); $line = str_replace('minutes ago','분 전', $line); $line = str_replace('Some thread attached to test page','FrontPage', $line); } $contents[] = $line; } $text = join($contents); return <<<FOOT <script type="text/javascript"> $text </script> FOOT; }Recent Posts
Archive Posts
Tags