-
Notifications
You must be signed in to change notification settings - Fork 556
Sample
I've written a sample plugin, illustrating how to power up the engine with new components.
In this sample we create a custom component called trivial_translator
that translates Chinese numbers from pinyin.
Currently the sample works only under Linux.
Building the sample requires gcc>=4.8
, cmake>=2.8
, development packages for google-glog
and librime
.
Note that the version of librime
installed should match the copy of source code containing the sample.
To make sure our sample plugin is compatible with librime, build and install librime from source code.
cd librime
make
sudo make install
The sample project lives in a subfolder named sample
under librime source.
cd sample
mkdir build
cd build
cmake ..
make
This creates a shared library librime-sample.so
.
There is a test for trivial_translator
. Let's verify it is functional:
make test
Once it's built, we can try a sample schema that make use of trivial_translator
.
cd bin
echo jiuqianjiubaijiushijiu | ./sample_console
sample_console
differs from rime_api_console
in that,
besides the default modules, it initializes an additional module sample
.
static RIME_MODULE_LIST(sample_modules, "default", "sample");
int main(int argc, char *argv[]) {
// ...
RIME_STRUCT(RimeTraits, traits);
traits.app_name = "sample.console";
traits.modules = sample_modules; // include module name "sample"
// ...
rime->initialize(&traits);
// ...
}
However, neither rime_api_console
nor ibus-rime
is currently able to dynamically load third-party modules.
This feature is to be implemented in later versions of Rime.