內容簡介
WordPress有wp_localize_scripts函數可以用來翻譯,但傳送給它的字串必須是硬編碼的。 直到您解析.js文件,並使用快速正則表達式掃描_e()的出現次數並使用WordPress _e函數本地化數據來本地化它們。*注意*。您的.po文件必須包括來自JavaScript文件的字符串。要在Poedit中執行此操作,請參閱http://stackoverflow.com/questions/16557327/how-to-generate-po-file-from-js-file-using-poedit。
外掛標籤
開發者團隊
原文外掛簡介
WordPress has the function wp_localize_scripts for translation, but the strings passed to it have to be hard-coded. Until you parse the .js-files and scan for occurrences of _e() with a fast regexp, and localize them with the data using the WordPress _e-function to localize from a .po file. *Note*. Your po-file has to include strings from javascript files. To do this in Poedit, see http://stackoverflow.com/questions/16557327/how-to-generate-po-file-from-js-file-using-poedit.
