久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 i18next(占位符,值)翻譯自定義屬性

Translate custom attributes with i18next (placeholder, value)(使用 i18next(占位符,值)翻譯自定義屬性)
本文介紹了使用 i18next(占位符,值)翻譯自定義屬性的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在研究 i18next 本地化庫的可能性.

I am investigating what is possible with i18next localization library.

現在我有以下代碼(full Fiddle is here):

Right now I have the following code (full Fiddle is here):

HTML

<div data-i18n="title"></div>
<input placeholder="Hello" value="name">
<div class="holder"></div>
<button class="lang" data-lang="en">Eng</button>
<button class="lang" data-lang="ch">Chi</button>

JS

$(document).ready(function () {
    i18n.init({
        "lng": 'en',
        "resStore": resources,
        "fallbackLng" : 'en'
    }, function (t) {
        $(document).i18n();
    });

    $('.lang').click(function () {
        var lang = $(this).attr('data-lang');
        i18n.init({
            lng: lang
        }, function (t) {
            $(document).i18n();
        });
    });
});

它翻譯所有 text 元素,但問題是我無法翻譯 custom attributes.例如,div 內的文本已翻譯,但我不明白如何翻譯自定義屬性,如 placeholdervalue.

It translates all text elements, but the problem is that I can not translate custom attributes. For example text inside the div is translated, but I can not understand how can I translate custom attributes like placeholder and value.

另一個問題是我的翻譯方式.每當單擊按鈕 Chi, Eng 時,我都會初始化翻譯(但我不確定這是正確的方式).編輯 我想我找到了解決這個問題的方法(我需要使用 setLng):i18n.setLng(lang, function(t) { ... })

Another problem is with my way of translation. Whenever a button Chi, Eng is clicked, I am initializing the translation (but I am not sure this is a correct way). Edit I think I found how to solve this problem (I need to use setLng): i18n.setLng(lang, function(t) { ... })

推薦答案

直接問i18next creator這個問題后,收到了以下回復:我需要的只是將我的自定義屬性放在翻譯元素的前面.這是一個例子:

After asking i18next creator this question directly, I received the following reply: all I need is to put my custom attribute in front of the translation element. Here is an example:

<div data-i18n="[title]titleTransl"></div>
<input data-i18n="[placeholder]placeTransl" value="name">

如果需要多個屬性,請用 ; 分隔它們.

If multiple attributes are needed, separate them by a ;.

我從中學到了兩件事:

  • 我必須閱讀更好的文檔.
  • 118next 的創作者真的很有幫助(這是對他的感謝).

這篇關于使用 i18next(占位符,值)翻譯自定義屬性的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 日韩一区二区三 | 国产91精品看黄网站在线观看 | 第一福利视频导航 | 国产精品九九九九 | 黄色免费片| 在线观看的av网站 | 免费在线播放av | 亚洲精品国产精品国自产观看浪潮 | 九九久久久 | 色妞av| 亚洲成人av在线播放 | 99久久久久久 | 国产二区精品 | 亚洲 欧美 激情 另类 校园 | 黄色片免费网站 | 成人午夜在线观看 | 久久一区二区三区四区 | 日本免费视频 | 91成人精品一区在线播放 | 日韩精品视频在线播放 | 性色av蜜臀av浪潮av老女人 | 天天干天天干天天操 | 这里只有精品视频在线观看 | 亚洲成a| 91精品亚洲| 国产一区二区三区视频在线 | 成人黄色免费视频 | 日本黄色视 | 成人午夜在线视频 | 欧美久久久久久久久 | 黄色小视频在线免费观看 | 亚洲精品中文字幕乱码三区91 | 男人天堂手机在线 | 2018天天操| 免费看色片| 成人视屏在线观看 | 中文字幕免费av | 欧美国产一区二区 | 波多野一区 | 国产成人午夜高潮毛片 | 久久久久久精 |