mirror of https://gitee.com/bigwinds/arangodb
Added option --default-language to arangod
This commit is contained in:
parent
5f86ce2df3
commit
c90d7f5f27
|
@ -48,6 +48,7 @@
|
|||
#include "Basics/ProgramOptions.h"
|
||||
#include "Basics/ProgramOptionsDescription.h"
|
||||
#include "Basics/Random.h"
|
||||
#include "Basics/Utf8Helper.h"
|
||||
#include "BasicsC/files.h"
|
||||
#include "BasicsC/init.h"
|
||||
#include "BasicsC/strings.h"
|
||||
|
@ -219,6 +220,9 @@ ArangoServer::ArangoServer (int argc, char** argv)
|
|||
|
||||
// set working directory and database directory
|
||||
_workingDirectory = "/var/tmp";
|
||||
#ifdef TRI_HAVE_ICU
|
||||
_defaultLanguage = Utf8Helper::DefaultUtf8Helper.getCollatorLanguage();
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -330,6 +334,9 @@ void ArangoServer::buildApplicationServer () {
|
|||
("pid-file", &_pidFile, "pid-file in daemon mode")
|
||||
("supervisor", "starts a supervisor and runs as daemon")
|
||||
("working-directory", &_workingDirectory, "working directory in daemon mode")
|
||||
#ifdef TRI_HAVE_ICU
|
||||
("default-language", &_defaultLanguage, "ISO-639 language code")
|
||||
#endif
|
||||
;
|
||||
|
||||
// .............................................................................
|
||||
|
@ -403,6 +410,13 @@ void ArangoServer::buildApplicationServer () {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// set language of default collator
|
||||
// .............................................................................
|
||||
#ifdef TRI_HAVE_ICU
|
||||
Utf8Helper::DefaultUtf8Helper.setCollatorLanguage(_defaultLanguage);
|
||||
LOGGER_INFO << "using default language '" << Utf8Helper::DefaultUtf8Helper.getCollatorLanguage() << "'";
|
||||
#endif
|
||||
// .............................................................................
|
||||
// disable access to the HTML admin interface
|
||||
// .............................................................................
|
||||
|
|
|
@ -410,6 +410,16 @@ namespace triagens {
|
|||
|
||||
vector<string> _scriptParameters;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief server default language
|
||||
///
|
||||
/// @CMDOPT{--default-language @CA{script-parameter}}
|
||||
///
|
||||
/// Parameter to script.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string _defaultLanguage;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief vocbase
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -184,6 +184,20 @@ void Utf8Helper::setCollatorLanguage (const string& lang) {
|
|||
#ifdef TRI_HAVE_ICU
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
if (_coll) {
|
||||
ULocDataLocaleType type = ULOC_ACTUAL_LOCALE;
|
||||
const Locale& locale = _coll->getLocale(type, status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
LOGGER_ERROR << "error in Collator::getLocale(...): " << u_errorName(status);
|
||||
return;
|
||||
}
|
||||
if (lang == locale.getName()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Collator* coll;
|
||||
if (lang == "") {
|
||||
coll = Collator::createInstance(status);
|
||||
|
@ -216,6 +230,22 @@ void Utf8Helper::setCollatorLanguage (const string& lang) {
|
|||
#endif
|
||||
}
|
||||
|
||||
string Utf8Helper::getCollatorLanguage () {
|
||||
#ifdef TRI_HAVE_ICU
|
||||
if (_coll) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ULocDataLocaleType type = ULOC_VALID_LOCALE;
|
||||
const Locale& locale = _coll->getLocale(type, status);
|
||||
|
||||
if(U_FAILURE(status)) {
|
||||
LOGGER_ERROR << "error in Collator::getLocale(...): " << u_errorName(status);
|
||||
return "";
|
||||
}
|
||||
return locale.getLanguage();
|
||||
}
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
|
|
|
@ -115,6 +115,12 @@ namespace triagens {
|
|||
|
||||
void setCollatorLanguage (const string& lang);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set collator by language
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string getCollatorLanguage ();
|
||||
|
||||
private:
|
||||
#ifdef TRI_HAVE_ICU
|
||||
Collator* _coll;
|
||||
|
|
|
@ -3,10 +3,16 @@ dnl -*- mode: Autoconf; -*-
|
|||
dnl ----------------------------------------------------------------------------
|
||||
dnl --SECTION-- V8
|
||||
dnl ----------------------------------------------------------------------------
|
||||
# -ffunction-sections -fdata-sections
|
||||
ICU_CPPFLAGS="-D_REENTRANT -I${srcdir}/3rdParty/icu/BUILD/include"
|
||||
ICU_LDFLAGS=""
|
||||
ICU_LIBS=" -lpthread -ldl -lm ${srcdir}/3rdParty/icu/BUILD/libs/libicui18n.a ${srcdir}/3rdParty/icu/BUILD/libs/libicuuc.a ${srcdir}/3rdParty/icu/BUILD/libs/libicudata.a ${srcdir}/3rdParty/icu/BUILD/libs/libicuio.a ${srcdir}/3rdParty/icu/BUILD/libs/libicule.a ${srcdir}/3rdParty/icu/BUILD/libs/libiculx.a"
|
||||
|
||||
icu_build_dir="${srcdir}/3rdParty/icu/BUILD"
|
||||
icu_lib_dir="${icu_build_dir}/libs"
|
||||
|
||||
dnl --- do we need "-ffunction-sections -fdata-sections" in ICU_CPPFLAGS?
|
||||
dnl --- ICU_LIBS was: " -lpthread -ldl -lm ${icu_lib_dir}/libicui18n.a ${icu_lib_dir}/libicuuc.a ${icu_lib_dir}/libicudata.a ${icu_lib_dir}/libicuio.a ${icu_lib_dir}/libicule.a ${icu_lib_dir}/libiculx.a -lpthread -ldl -lm "
|
||||
|
||||
ICU_CPPFLAGS="-D_REENTRANT -I${icu_build_dir}/include"
|
||||
ICU_LDFLAGS=" -ldl -lm "
|
||||
ICU_LIBS=" ${icu_lib_dir}/libicui18n.a ${icu_lib_dir}/libicuuc.a ${icu_lib_dir}/libicudata.a "
|
||||
|
||||
TRI_ICU_VERSION="49.1.2"
|
||||
|
||||
|
|
|
@ -4,10 +4,6 @@ dnl ----------------------------------------------------------------------------
|
|||
dnl --SECTION-- ICU
|
||||
dnl ----------------------------------------------------------------------------
|
||||
|
||||
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
|
||||
AC_MSG_NOTICE([CHECKING FOR ICU])
|
||||
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
|
||||
|
||||
AC_LANG(C)
|
||||
|
||||
AC_ARG_ENABLE(icu,
|
||||
|
@ -16,22 +12,14 @@ AC_ARG_ENABLE(icu,
|
|||
tr_ICU="maybe"
|
||||
)
|
||||
|
||||
AC_ARG_WITH(ICU,
|
||||
AS_HELP_STRING([--with-icu=DIR], [where the ICU library and includes are located]),
|
||||
[ICU_CPPFLAGS="-I$withval/include"
|
||||
ICU_LDFLAGS="-L$withval/lib"
|
||||
ICU="$withval"]
|
||||
)
|
||||
|
||||
AC_ARG_WITH(ICU-lib,
|
||||
AS_HELP_STRING([--with-icu-lib=DIR], [where the ICU library is located]),
|
||||
[ICU_LDFLAGS="-L$withval"]
|
||||
AC_ARG_WITH(icu-config,
|
||||
AS_HELP_STRING([--with-icu-config=FILE], [where the icu-config program is located]),
|
||||
[ICU_CONFIG="$withval"]
|
||||
)
|
||||
|
||||
TR_STATIC_ENABLE([ICU])
|
||||
|
||||
if test "x$tr_ICU" = xyes; then
|
||||
|
||||
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
|
||||
AC_MSG_NOTICE([CHECKING FOR ICU])
|
||||
AC_MSG_NOTICE([--------------------------------------------------------------------------------])
|
||||
|
@ -40,18 +28,20 @@ if test "x$tr_ICU" = xyes; then
|
|||
dnl checks for the icu-config
|
||||
dnl ----------------------------------------------------------------------------
|
||||
|
||||
ICU_CONFIG="icu-config"
|
||||
if test "x$ICU_CONFIG" == "x" ; then
|
||||
ICU_CONFIG="icu-config"
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for "${ICU_CONFIG} --version"])
|
||||
|
||||
if $ICU_CONFIG --version > /dev/null 2>&1; then
|
||||
ICU_CPPFLAGS="$($ICU_CONFIG --cppflags)"
|
||||
ICU_LDFLAGS="$($ICU_CONFIG --ldflags)"
|
||||
ICU_LIBS=""
|
||||
ICU_LIBS=""
|
||||
TRI_ICU_VERSION="$($ICU_CONFIG --version)"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
ICU_CPPFLAGS="$ICU_CPPFLAGS"
|
||||
ICU_LDFLAGS="$ICU_LDFLAGS"
|
||||
ICU_LIBS="-licui18n -licuuc -licudata -licuio -licule -liculx"
|
||||
TRI_ICU_VERSION="unknown"
|
||||
AC_MSG_ERROR([config program "${ICU_CONFIG}" not found.])
|
||||
fi
|
||||
|
||||
ICU_CPPFLAGS="${ICU_CPPFLAGS} -DTRI_ICU_VERSION='\"${TRI_ICU_VERSION}\"' -DTRI_HAVE_ICU=1"
|
||||
|
|
Loading…
Reference in New Issue