mirror of
https://github.com/ars3niy/tdlib-purple
synced 2025-08-22 09:57:52 +00:00
Introduce Translations as a default feature
This commit is contained in:
parent
277e4ddfc1
commit
6aff5ac9c8
@ -12,6 +12,7 @@ set(NoPkgConfig FALSE CACHE BOOL "Do not use pkg-config")
|
||||
set(NoWebp FALSE CACHE BOOL "Do not decode webp stickers")
|
||||
set(NoBundledLottie FALSE CACHE BOOL "Do not use bundled rlottie library")
|
||||
set(NoLottie FALSE CACHE BOOL "Disable animated sticker conversion")
|
||||
set(NoTranslations FALSE CACHE BOOL "Disable translation support")
|
||||
set(API_ID 94575 CACHE STRING "API id")
|
||||
set(API_HASH a3406de8d171bb422bb6ddf3bbd800e2 CACHE STRING "API hash")
|
||||
set(STUFF "" CACHE STRING "")
|
||||
@ -88,6 +89,22 @@ if (NOT DEFINED SHARE_INSTALL_PREFIX)
|
||||
set(SHARE_INSTALL_PREFIX "share")
|
||||
endif (NOT DEFINED SHARE_INSTALL_PREFIX)
|
||||
|
||||
if (NOT NoTranslations)
|
||||
find_package(Gettext REQUIRED)
|
||||
file(STRINGS po/LINGUAS _linguas)
|
||||
foreach(_lang ${_linguas})
|
||||
GETTEXT_PROCESS_PO_FILES(
|
||||
${_lang} ALL
|
||||
INSTALL_DESTINATION "${SHARE_INSTALL_PREFIX}/locale"
|
||||
PO_FILES "${CMAKE_SOURCE_DIR}/po/${_lang}.po"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
find_package(Intl REQUIRED)
|
||||
target_include_directories(telegram-tdlib PRIVATE ${Intl_INCLUDE_DIRS})
|
||||
target_link_libraries(telegram-tdlib PRIVATE ${Intl_LIBRARIES})
|
||||
endif (NOT NoTranslations)
|
||||
|
||||
install(TARGETS telegram-tdlib DESTINATION "${PURPLE_PLUGIN_DIR}")
|
||||
install(FILES data/telegram16.png DESTINATION "${PURPLE_DATA_DIR}/pixmaps/pidgin/protocols/16" RENAME telegram.png)
|
||||
install(FILES data/telegram22.png DESTINATION "${PURPLE_DATA_DIR}/pixmaps/pidgin/protocols/22" RENAME telegram.png)
|
||||
|
@ -7,4 +7,6 @@
|
||||
|
||||
#cmakedefine NoLottie
|
||||
|
||||
#cmakedefine NoTranslations
|
||||
|
||||
#endif
|
||||
|
3
format.h
3
format.h
@ -2,6 +2,7 @@
|
||||
#define _FORMAT_H
|
||||
|
||||
#include <string>
|
||||
#include "translate.h"
|
||||
|
||||
std::string formatMessage(const char *fmt, std::initializer_list<std::string> args);
|
||||
std::string formatMessage(const char *fmt, const std::string &s);
|
||||
@ -12,6 +13,4 @@ std::string formatMessage(const char *fmt, T arg)
|
||||
return formatMessage(fmt, {std::to_string(arg)});
|
||||
}
|
||||
|
||||
static inline char *_(const char *s) { return const_cast<char *>(s); }
|
||||
|
||||
#endif
|
||||
|
23
translate.h
Normal file
23
translate.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef _TRANSLATE_H
|
||||
#define _TRANSLATE_H
|
||||
|
||||
#include "buildopt.h"
|
||||
|
||||
#ifndef NoTranslations
|
||||
# define GETTEXT_PACKAGE "tdlib-purple"
|
||||
# include <glib/gi18n-lib.h>
|
||||
# define P_(Singular,Plural,N) ((char *) g_dngettext (GETTEXT_PACKAGE, Singular, Plural, N))
|
||||
#else
|
||||
// The correct way to handle it is:
|
||||
//# define _(String) String
|
||||
//# define P_(Singular,Plural,N) Plural
|
||||
//# define N_(String) String
|
||||
//# define gettext(String) String
|
||||
// But glib isn't const-correct, and gcc treats this as a fatal error.
|
||||
# define _(String) const_cast<char *>(String)
|
||||
# define P_(Singular,Plural,N) const_cast<char *>(Plural)
|
||||
# define N_(String) const_cast<char *>(String)
|
||||
# define gettext(String) const_cast<char *>(String)
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user