The recent move to Composer for Known (and eventually Known plugins) has given me the opportunity to improve the experience for plugin developers.
Previously, generating a .pot file for languages would require a script in Known’s central language directory. This meant all sorts of “relative path” hijinks in your Gruntfile.js, and was generally bad.
So, I’ve taken this opportunity to package up the script into its own project that can be installed via composer as a development dependency into your plugin project.
How to use
Create your CoolProject, and add your translation string hooks, and load them as described here.
In your project, add known-language-tools as a dependency using composer require mapkyca/known-language-tools --dev
In the project directory you’ll find a Sample.package.json file. Copy this to your project root as package.json and edit accordingly. Note your project name should be the name of your project.
In the project directory, you’ll find a Sample.Gruntfile.js. Again, copy this into your project root.
Create a languages directory
Run the grunt task, grunt build-lang (if grunt isn’t found, npm install --only=dev first.
In the latest builds of Known, I’ve added support for Gettext translations. This can operate in tandem with the string array mechanism used previously, but it is my hope that using gettext will make translations easier, as there is a more complete tool chain available.
Creating .POT file
The first step, after you’ve used \Idno\Core\Idno::site()->language()->_() to write your strings, is to generate a POT template translation file. To do this, in /languages/ there’s a helpful script, go into this directory and run the script