English 中文(简体)
j 翻译
原标题:Charset issues for jQuery XML translation

Iam采用人工语言翻译的混合方法,使用jquery-translate libray进行gogle翻译。 我已经放弃了正确工作的权宜之计,但 go光缺乏我的雇主客户需要的一些语言。

因此,我用jquery读过一个带有 english + french canadian语文的xml文档,作为样本,我读了xml,并使用NodeContainsText替换一页的文字,但我这样做的时候。 案文精彩地通过斜角译本展示。

因此,我的问题是,如何将xml数据作为正确的查点/联系类型,以便正确显示这一点。

$(document).ready(function()
{
  $.ajax({
    type: "GET",
    url: "xmldata.xml",
    dataType: "xml",
    success: parseXml
  });
});
function parseXml(xml)
{

  //find every Tutorial and print the author
  $(xml).find("english").each(function()
  {
    $(this).find( phrase ).each(function(){
        english[count] = $(this).text();
        console.log( Adding to english array..[ +english[count]+ ] );
        count = count + 1;
    });
  });
  count = 1;
  $(xml).find("french_canadian").each(function()
  {
    $(this).find( phrase ).each(function(){
        frca[count] = $(this).text();
        console.log( Adding to frca array..[ +frca[count]+ ] );
        count = count + 1;
    });
  });

$( body ).nodesContainingText().each(function(){

    // step 1 search through all text nodes

    var $el = $(this), text = $el.text() || $el.val();
    var nn = this.nodeName;


    // step 2 find position in english array for word
    for(var i=0;i<english.length;i++) {
        // step 3 replace with french canadian version from array
        if (english[i] == text) {
            // which node dot text = value
            console.log( Replacing... +english[i]+  with  +frca[i]);
            $el.text(frca[i]);
        }
    }
});

}

你可以看到,我正在使用奥索尔。 在内容/任务问题产生于......时,通过火力 log计标

我似乎无法抓住yn子,把从xml文档中获取的数据转换成正确的编码。

我知道它本应是.html(),但我补充说,它只是造成错误。 因此,有人会给我一个cl子吗?

谢谢。

最佳回答

我最终找到了解决办法,将Xml文档的果园直接换成。

<?xml version="1.0" encoding="ISO-8859-1"?>

这使得从其他语文学到的所有学生都能即时看到......

感谢。

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签