CodeIgniter: Parse dynamic language captions located in javascript

前端 未结 3 1810
囚心锁ツ
囚心锁ツ 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 18:56

    Create a json object in the global scope of the page output for your javascript strings:

    
    

    Then you can use it throughout your Javascript app using the syntax:

    oGlobalStrings.some_data
    

    Works very well and can be handled very easily throughout your app.

提交回复
热议问题