Skip to content

Commit

Permalink
Add localization to libopenrave, libopenrave-core, and openrave pytho…
Browse files Browse the repository at this point in the history
…ng binding.
  • Loading branch information
ziyan committed Aug 10, 2015
1 parent 842c9c6 commit ffa18d9
Show file tree
Hide file tree
Showing 50 changed files with 2,614 additions and 337 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -164,6 +164,7 @@ endif()
set(OPENRAVE_PLUGINS_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_PLUGINS_INSTALL_DIR}" CACHE PATH "Absolute dir for plugins on target OS path, used to write to header file")
set(OPENRAVE_DATA_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_DATA_INSTALL_DIR}" CACHE PATH "Absolute dir for data on target OS path, used to write to header file")
set(OPENRAVE_PYTHON_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/${OPENRAVE_PYTHON_INSTALL_DIR}" CACHE PATH "Absolute dir for python on target OS path, used to write to header file")
set(OPENRAVE_LOCALE_INSTALL_ABSOLUTE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE PATH "Absolute dir for translation files on target OS path, used to write to header file")

# The RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" "${OPENRAVE_PLUGINS_INSTALL_ABSOLUTE_DIR}")
Expand Down Expand Up @@ -731,6 +732,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)

add_subdirectory(src)
add_subdirectory(octave_matlab)
add_subdirectory(locale)

if(OPT_PYTHON AND PYTHON_EXECUTABLE)
set(OPENRAVE_USE_LOCAL_SYMPY 1)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Expand Up @@ -56,6 +56,7 @@
#define OPENRAVE_PLUGINS_INSTALL_DIR "@OPENRAVE_PLUGINS_INSTALL_ABSOLUTE_DIR@"
#define OPENRAVE_DATA_INSTALL_DIR "@OPENRAVE_DATA_INSTALL_ABSOLUTE_DIR@"
#define OPENRAVE_PYTHON_INSTALL_DIR "@OPENRAVE_PYTHON_INSTALL_ABSOLUTE_DIR@"
#define OPENRAVE_LOCALE_INSTALL_DIR "@OPENRAVE_LOCALE_INSTALL_ABSOLUTE_DIR@"

// the python path that OpenRAVE was compiled with
#define OPENRAVE_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@"
Expand Down
20 changes: 14 additions & 6 deletions include/openrave/openrave.h
Expand Up @@ -572,19 +572,19 @@ DefineRavePrintfA(_VERBOSELEVEL)

#define IS_DEBUGLEVEL(level) ((OpenRAVE::RaveGetDebugLevel()&OpenRAVE::Level_OutputMask)>=(level))

#define OPENRAVE_EXCEPTION_FORMAT0(s, errorcode) OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] " s)%(__PRETTY_FUNCTION__)%(__LINE__)),errorcode)
#define OPENRAVE_EXCEPTION_FORMAT0(s, errorcode) OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s")%(__PRETTY_FUNCTION__)%(__LINE__)%(s)),errorcode)

/// adds the function name and line number to an openrave exception
#define OPENRAVE_EXCEPTION_FORMAT(s, args,errorcode) OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] " s)%(__PRETTY_FUNCTION__)%(__LINE__)%args),errorcode)
#define OPENRAVE_EXCEPTION_FORMAT(s, args, errorcode) OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] ")%(__PRETTY_FUNCTION__)%(__LINE__)) + boost::str(boost::format(s)%args),errorcode)

#define OPENRAVE_ASSERT_FORMAT(testexpr, s, args, errorcode) { if( !(testexpr) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] (%s) failed " s)%(__PRETTY_FUNCTION__)%(__LINE__)%(# testexpr)%args),errorcode); } }
#define OPENRAVE_ASSERT_FORMAT(testexpr, s, args, errorcode) { if( !(testexpr) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] (%s) failed ")%(__PRETTY_FUNCTION__)%(__LINE__)%(# testexpr)) + boost::str(boost::format(s)%args),errorcode); } }

#define OPENRAVE_ASSERT_FORMAT0(testexpr, s, errorcode) { if( !(testexpr) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] (%s) failed " s)%(__PRETTY_FUNCTION__)%(__LINE__)%(# testexpr)),errorcode); } }
#define OPENRAVE_ASSERT_FORMAT0(testexpr, s, errorcode) { if( !(testexpr) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] (%s) failed %s")%(__PRETTY_FUNCTION__)%(__LINE__)%(# testexpr)%(s)),errorcode); } }

// note that expr1 and expr2 will be evaluated twice if not equal
#define OPENRAVE_ASSERT_OP_FORMAT(expr1,op,expr2,s, args, errorcode) { if( !((expr1) op (expr2)) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s %s %s, (eval %s %s %s) " s)%(__PRETTY_FUNCTION__)%(__LINE__)%(# expr1)%(# op)%(# expr2)%(expr1)%(# op)%(expr2)%args),errorcode); } }
#define OPENRAVE_ASSERT_OP_FORMAT(expr1,op,expr2,s, args, errorcode) { if( !((expr1) op (expr2)) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s %s %s, (eval %s %s %s) ")%(__PRETTY_FUNCTION__)%(__LINE__)%(# expr1)%(# op)%(# expr2)%(expr1)%(# op)%(expr2)) + boost::str(boost::format(s)%args),errorcode); } }

#define OPENRAVE_ASSERT_OP_FORMAT0(expr1,op,expr2,s, errorcode) { if( !((expr1) op (expr2)) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s %s %s, (eval %s %s %s) " s)%(__PRETTY_FUNCTION__)%(__LINE__)%(# expr1)%(# op)%(# expr2)%(expr1)%(# op)%(expr2)),errorcode); } }
#define OPENRAVE_ASSERT_OP_FORMAT0(expr1,op,expr2,s, errorcode) { if( !((expr1) op (expr2)) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s %s %s, (eval %s %s %s) %s")%(__PRETTY_FUNCTION__)%(__LINE__)%(# expr1)%(# op)%(# expr2)%(expr1)%(# op)%(expr2)%(s)),errorcode); } }

#define OPENRAVE_ASSERT_OP(expr1,op,expr2) { if( !((expr1) op (expr2)) ) { throw OpenRAVE::openrave_exception(boost::str(boost::format("[%s:%d] %s %s %s, (eval %s %s %s) ")%(__PRETTY_FUNCTION__)%(__LINE__)%(# expr1)%(# op)%(# expr2)%(expr1)%(# op)%(expr2)),ORE_Assert); } }

Expand Down Expand Up @@ -2783,6 +2783,14 @@ OPENRAVE_API void RaveSetDataAccess(int accessoptions);
/// \see RaveSetDataAccess
OPENRAVE_API int RaveGetDataAccess();

/** \brief Returns the gettext translated string of the given message id
\param domainname translation domain name
\param msgid message id to look for
\return if a translation was found, it is converted to the locale's codeset and returned. The resulting string is statically allocated and must not be modified or freed. Otherwise msgid is returned.
*/
OPENRAVE_API const char *RaveGetText(const std::string& domainname, const char *msgid);

//@}

/// \deprecated (11/06/03), use \ref SpaceSamplerBase
Expand Down
3 changes: 3 additions & 0 deletions locale/.gitignore
@@ -0,0 +1,3 @@
*.mo
*.pot
*~
39 changes: 39 additions & 0 deletions locale/CMakeLists.txt
@@ -0,0 +1,39 @@
set(LANGUAGES
en_US
ja_JP
)
set(DOMAINS openrave)

find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
if(NOT GETTEXT_MSGFMT_EXECUTABLE)
message(FATAL_ERROR "msgfmt not found")
endif(NOT GETTEXT_MSGFMT_EXECUTABLE)

foreach(LANG ${LANGUAGES})
foreach(DOMAIN ${DOMAINS})

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES
)

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES/${DOMAIN}.mo
COMMAND
${GETTEXT_MSGFMT_EXECUTABLE} --verbose --check-format --check-domain --output-file=${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES/${DOMAIN}.mo ${DOMAIN}.po
DEPENDS
${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES
${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES/${DOMAIN}.po
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES
)

install(FILES ${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES/${DOMAIN}.mo
DESTINATION ${OPENRAVE_LOCALE_INSTALL_ABSOLUTE_DIR}/${LANG}/LC_MESSAGES)

set(locale-deps ${locale-deps} ${CMAKE_SOURCE_DIR}/locale/${LANG}/LC_MESSAGES/${DOMAIN}.mo)

endforeach(DOMAIN ${DOMAINS})
endforeach(LANG ${LANGUAGES})

add_custom_target(locale ALL DEPENDS ${locale-deps})

1 comment on commit ffa18d9

@CRubertRob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, since this commit, shadow_hand model is not loaded properly in Ubuntu 14.04. There is no error message, so I'm not sure where the problem is. I'm still looking how to fix it, but someone could try also to check for that.

In Ubuntu Mate 14.04 it works fine, so it seems to be something related to libraries locations or versions.

Please sign in to comment.