forked from aldebaran/libqi-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpytranslator.cpp
More file actions
43 lines (36 loc) · 1.29 KB
/
pytranslator.cpp
File metadata and controls
43 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
** Copyright (C) 2020 SoftBank Robotics Europe
** See COPYING for the license
*/
#include <qipython/pytranslator.hpp>
#include <qipython/common.hpp>
#include <qipython/pyguard.hpp>
#include <pybind11/pybind11.h>
namespace py = pybind11;
namespace qi
{
namespace py
{
void exportTranslator(::py::module& m)
{
using namespace ::py;
using namespace ::py::literals;
GILAcquire lock;
class_<Translator>(m, "Translator")
.def(init([](const std::string& name) { return new Translator(name); }),
call_guard<GILRelease>(), "name"_a)
.def("translate", &Translator::translate, call_guard<GILRelease>(),
"msg"_a, "domain"_a = "", "locale"_a = "", "context"_a = "",
doc("Translate a message from a domain to a locale."))
.def("translate", &Translator::translateContext,
call_guard<GILRelease>(), "msg"_a, "context"_a,
doc("Translate a message with a context."))
.def("setCurrentLocale", &Translator::setCurrentLocale,
call_guard<GILRelease>(), "locale"_a, doc("Set the locale."))
.def("setDefaultDomain", &Translator::setDefaultDomain, "domain"_a,
call_guard<GILRelease>(), doc("Set the domain."))
.def("addDomain", &Translator::addDomain, "domain"_a,
doc("Add a new domain."));
}
} // namespace py
} // namespace qi