Commit 838b541b authored by Link Mauve's avatar Link Mauve

Add support for i18n.

parent a43fb352
Pipeline #1443 failed with stages
in 37 seconds
......@@ -99,6 +99,8 @@ mark_as_advanced(PANDOC_EXECUTABLE)
## Set this search path for cmake, to find our custom search modules
#
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
find_package(Intl REQUIRED)
find_package(Gettext REQUIRED)
find_package(ICONV REQUIRED)
find_package(LIBUUID REQUIRED)
find_package(EXPAT REQUIRED)
......@@ -366,6 +368,24 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/biboumi.service DESTINATION lib/syst
file(GLOB policy_files conf/*policy.txt)
install(FILES ${policy_files} DESTINATION /etc/biboumi COMPONENT configuration)
#
## i18n target
## Compiles the gettext po files into mo files
#
file(GLOB po_files ${CMAKE_SOURCE_DIR}/po/*.po)
set(mo_dir ${CMAKE_CURRENT_BINARY_DIR}/mo)
foreach(po ${po_files})
get_filename_component(lang ${po} NAME_WE)
set(mo ${mo_dir}/${lang}.mo)
target_sources(biboumi PRIVATE ${mo})
add_custom_command(OUTPUT ${mo}
COMMAND ${CMAKE_COMMAND} -E make_directory ${mo_dir}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po}
DEPENDS ${po}
)
install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES RENAME biboumi.mo)
endforeach()
#
## Dist target
## Generate a release tarball from the git sources
......
#!/bin/sh
cd "$(dirname "$0")"/..
PO_DIR=po
POT_FILE=$PO_DIR/biboumi.pot
find "$PO_DIR" -name \*.po \
-exec msgmerge --quiet --update --backup=none -s {} $POT_FILE \;
#!/bin/sh
cd "$(dirname "$0")"/..
SRC_DIR=src
PO_DIR=po
POT_FILE=$PO_DIR/biboumi.pot
mkdir -p "$PO_DIR"
find "$SRC_DIR" -name \*.cpp -o -name \*.hpp | \
xgettext -d biboumi -s --keyword=_ --add-comments=i18n -p "$PO_DIR" \
-o biboumi.pot -f - --package-name='Biboumi' --package-version='9.0~dev' \
--msgid-bugs-address='https://lab.louiz.org/louiz/biboumi/issues'
sed -i "s/SOME DESCRIPTIVE TITLE\./Translation of biboumi.pot to LANGUAGE/" "$POT_FILE"
sed -i "s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2013-2018/" "$POT_FILE"
sed -i "s/CHARSET/UTF-8/" "$POT_FILE"
......@@ -5,6 +5,7 @@
#include <logger/logger.hpp>
#include <utils/xdg.hpp>
#include <utils/reload.hpp>
#include <utils/i18n.hpp>
#ifdef UDNS_FOUND
# include <network/dns_handler.hpp>
......@@ -57,6 +58,10 @@ static void sigusr_handler(int, siginfo_t*, void*)
int main(int ac, char** av)
{
setlocale(LC_ALL, "");
bindtextdomain("biboumi", "/usr/share/locale");
textdomain("biboumi");
if (ac > 1)
{
const std::string arg = av[1];
......
#include <libintl.h>
#define _(s) gettext(s)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment