<i id='w9l6X'><tr id='w9l6X'><dt id='w9l6X'><q id='w9l6X'><span id='w9l6X'><b id='w9l6X'><form id='w9l6X'><ins id='w9l6X'></ins><ul id='w9l6X'></ul><sub id='w9l6X'></sub></form><legend id='w9l6X'></legend><bdo id='w9l6X'><pre id='w9l6X'><center id='w9l6X'></center></pre></bdo></b><th id='w9l6X'></th></span></q></dt></tr></i><div id='w9l6X'><tfoot id='w9l6X'></tfoot><dl id='w9l6X'><fieldset id='w9l6X'></fieldset></dl></div>

<small id='w9l6X'></small><noframes id='w9l6X'>

        <bdo id='w9l6X'></bdo><ul id='w9l6X'></ul>

      1. <tfoot id='w9l6X'></tfoot><legend id='w9l6X'><style id='w9l6X'><dir id='w9l6X'><q id='w9l6X'></q></dir></style></legend>

        如何使用 jquery-i18n-properties 和 JavaScript 动态更改语言?

        How to dynamically change language using jquery-i18n-properties and JavaScript?(如何使用 jquery-i18n-properties 和 JavaScript 动态更改语言?)

          <i id='wSJce'><tr id='wSJce'><dt id='wSJce'><q id='wSJce'><span id='wSJce'><b id='wSJce'><form id='wSJce'><ins id='wSJce'></ins><ul id='wSJce'></ul><sub id='wSJce'></sub></form><legend id='wSJce'></legend><bdo id='wSJce'><pre id='wSJce'><center id='wSJce'></center></pre></bdo></b><th id='wSJce'></th></span></q></dt></tr></i><div id='wSJce'><tfoot id='wSJce'></tfoot><dl id='wSJce'><fieldset id='wSJce'></fieldset></dl></div>

          <legend id='wSJce'><style id='wSJce'><dir id='wSJce'><q id='wSJce'></q></dir></style></legend>
        • <tfoot id='wSJce'></tfoot>
            <tbody id='wSJce'></tbody>
            <bdo id='wSJce'></bdo><ul id='wSJce'></ul>

                <small id='wSJce'></small><noframes id='wSJce'>

                • 本文介绍了如何使用 jquery-i18n-properties 和 JavaScript 动态更改语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 jquery-i18n-properties 插件向我的网站提供 i18n.我已经更改了我的 HTML 并执行以下操作以加载所需的 .properties:

                  I'm providing i18n to my website using jquery-i18n-properties plugin. I have already changed my HTML and do the following in order to load the .properties that is required:

                  jQuery.i18n.properties({
                      name: 'Messages', 
                      path: 'bundle/', 
                      mode: 'both',
                      language: lang, 
                      callback: function() {
                          $("#msg_welcome").text(jQuery.i18n.prop('msg_welcome'));
                          ...
                      }
                  });
                  

                  一切正常.我现在要做的是允许用户按下按钮更改语言.有没有办法只使用 javascript 或这个插件而不重新加载页面?谢谢.

                  Everything works fine. What I want to do now is allow the user to change the language pressing a button. Is there a way to do it using only javascript or this plugin without reloading the page? Thanks.

                  推荐答案

                  是的,很简单.事实上,在 jQuery.i18n.properties 网站 (http://codingwithcoffee.com/files/trunk/index.html).

                  Yeah it's easy. In fact, there's example that does just that on jQuery.i18n.properties site (http://codingwithcoffee.com/files/trunk/index.html).

                  诀窍是用新语言简单地重新初始化插件.将您当前的代码抽象到另一个函数中,该函数接受 lang 作为参数.使用某种默认语言进行初始化,一旦用户更改了当前语言,就将其传递给该函数.

                  Trick is, to simply reinitialize plugin with new language. Abstract your current code into another function, that accepts lang as parameter. Initialize with some default language, and once user changes the current language, pass it to that function.

                  function changeLang(lang) {
                      jQuery.i18n.properties({
                          name: 'Messages', 
                          path: 'bundle/', 
                          mode: 'both',
                          language: lang, 
                          callback: function() {
                              $("#msg_welcome").text(jQuery.i18n.prop('msg_welcome'));
                              ...
                          }
                      });
                  }
                  
                  // somewhere else in your code
                  // change to english
                  changeLang('en_EN');
                  // change to other
                  changeLang('pt_PT');
                  

                  这篇关于如何使用 jquery-i18n-properties 和 JavaScript 动态更改语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                  <tfoot id='2ZdwZ'></tfoot>
                    <tbody id='2ZdwZ'></tbody>
                • <legend id='2ZdwZ'><style id='2ZdwZ'><dir id='2ZdwZ'><q id='2ZdwZ'></q></dir></style></legend>

                    • <i id='2ZdwZ'><tr id='2ZdwZ'><dt id='2ZdwZ'><q id='2ZdwZ'><span id='2ZdwZ'><b id='2ZdwZ'><form id='2ZdwZ'><ins id='2ZdwZ'></ins><ul id='2ZdwZ'></ul><sub id='2ZdwZ'></sub></form><legend id='2ZdwZ'></legend><bdo id='2ZdwZ'><pre id='2ZdwZ'><center id='2ZdwZ'></center></pre></bdo></b><th id='2ZdwZ'></th></span></q></dt></tr></i><div id='2ZdwZ'><tfoot id='2ZdwZ'></tfoot><dl id='2ZdwZ'><fieldset id='2ZdwZ'></fieldset></dl></div>

                      <small id='2ZdwZ'></small><noframes id='2ZdwZ'>

                          <bdo id='2ZdwZ'></bdo><ul id='2ZdwZ'></ul>