CodeIgniter: Parse dynamic language captions located in javascript

前端 未结 3 1781
囚心锁ツ
囚心锁ツ 2021-01-06 18:21

I have a javascript code that needs localisation, ie.

function js_proc() {
    var some_data = \'this text needs to be translated dynamically at runtime\';
}         


        
3条回答
  •  臣服心动
    2021-01-06 19:04

    Depending on how big the language file is, a quick way to allow javascript to access your entire language array could be to load the array into a global javascript array;

    
    

    Then access in your javascript like this;

    globalLang['some_lang_key']
    

提交回复
热议问题