簡體   English   中英

IntelliJ 中是否有用於 WordPress.po 文件支持的插件?

[英]Is there a plugin for WordPress .po file support in IntelliJ?

由於我已經在幾個軟件 forms 中發布了這個問題並且沒有得到有用的答案,我希望在這里得到你作為我的大學的答案。

如果您在 WordPress 中編程,您現在可以翻譯文件.po/.mo 我現在正在 IntelliJ / WebStorm 中尋找一個插件,它可以生成.mo文件並通過使用的位置擴展每個翻譯上方的 .po 文件:

#: /includes/.......
msgid "Cheatin’ huh?"
msgstr "So geht das leider nicht.."

那么有誰知道是否有一個插件可以做到這一點? 每次手動輸入用法就足夠了,因為這讓我非常惱火。 這一代人只會很高興。

非常感謝!

在撰寫此答案時,仍然沒有插件可以無縫地執行此操作。 但是,您可以使用 GRUNT 任務實現自動化。

使用Grunt需要配置一個 nodejs 開發環境

在您的項目根目錄中創建一個 package.json 類似於

{
  "name": "yourProject",
  "majorVersion": "0",
  "minorVersion": "0",
  "incrementalVersion": "1",
  "qualifier": "-alpha",
  "version": "0.0.1-alpha",
  "description": "My great idea",
  "main": "GruntFile.js",
  "directories": {
    "test": "test"
  },
  "repository": {
    "type": "git",
    "url": "https://yourgitrepo.com/name/project.git"
  },
  "dependencies": {},
  "devDependencies": {
    "grunt": "^1.5.3",
    "grunt-cli": "^1.4.3",
    "grunt-contrib-clean": "^2.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-exec": "^3.0.0",
    "grunt-pot": "^0.3.0",
    "grunt-replace": "^2.0.2",
    "load-grunt-tasks": "^5.1.0",
    "npm-cli": "^0.1.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Your Name",
  "license": "SEE LICENCE IN LICENCE.txt"
}

創建后使用終端導航並運行

npm install

這將創建一個節點環境。

現在創建一個GruntFile.js參見下面的例子。

 module.exports = function(grunt) { require('load-grunt-tasks')(grunt); // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), prvPkg: grunt.file.readJSON('private.json'), clean: { standard: ['myproject/target', ], }, makepot: { target: { options: { cwd: 'myproject/target/generated/myproject', include: ['.*'], domainPath: 'languages/', // Where to save the POT file. mainFile: 'myproject.php', // Main project file. potFilename: 'myproject.pot', // Name of the POT file. type: 'wp-plugin', potHeaders: { 'report-msgid-bugs-to': 'https://www.myproject.com.au', 'plural-forms': 'nplurals=2; plural=n;= 1,': 'last-translator'. 'Author Name <author@myproject.com,au>': 'language-team'. 'My Team <author@myproject.com,au>': poedit,true: 'x-poedit-keywordslist', true: 'x-textdomain-support', 'yes' } } } }; }). // Default task(s). grunt,registerTask('createMachineLanguage', ''. function () { let exec = require('child_process');execSync: let options = { cwd, 'myproject/target/generated/myproject/languages/': encoding. 'utf8' } let result = exec("msginit --no-translator --input=myproject.pot --locale=en --output=myproject_en_AU,po";options). result += exec("msgfmt myproject_en_AU.po -o myproject_en_AU,mo";options). result += exec("rm myproject_en_AU,po";options). grunt.log;writeln(result); }). grunt,registerTask('default':['clean,standard','makepot';'createMachineLanguage'] ); }
關鍵組件是grunt-pot grunt 插件。 您的終端環境必須安裝GNU gettext ,它提供 function msginitmsgfmt grunt 進程自動執行這些任務。 請注意我的環境是 Ubuntu 所以你可以看到我使用rm將 po 文件轉換為 mo 文件后刪除。

所以使用 GruntTask 插件你可以自動創建你的語言文件。 從 GruntTask 執行它們。 GruntTask 接口示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM