This patch adds gettext support for our new vncviewer. CMake only. The change of the project name is to make the CMake build behave like the Autotools build - define PACKAGE_NAME in the same way.


---
Peter Åstrand           ThinLinc Chief Developer
Cendio AB               http://www.cendio.com
Wallenbergs gata 4
583 30 Linköping        Phone: +46-13-21 46 00
Index: config.h.cmake.in
===================================================================
--- config.h.cmake.in   (revision 4379)
+++ config.h.cmake.in   (arbetskopia)
@@ -12,6 +12,7 @@
 #cmakedefine HAVE_GNUTLS_PK_ALGORITHM_T
 #cmakedefine HAVE_GNUTLS_SIGN_ALGORITHM_T
 #cmakedefine HAVE_FLTK_DEAD_KEYS
+#cmakedefine ENABLE_NLS 1
 
 /* MS Visual Studio 2008 and newer doesn't know ssize_t */
 #if defined(HAVE_GNUTLS) && defined(WIN32) && !defined(__MINGW32__)
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt      (revision 4379)
+++ CMakeLists.txt      (arbetskopia)
@@ -10,7 +10,7 @@
 include(CheckCSourceCompiles)
 include(CheckCXXSourceCompiles)
 
-project(TigerVNC)
+project(tigervnc)
 set(VERSION 1.0.90)
 
 # The RC version must always be four comma-separated numbers
@@ -123,6 +123,11 @@
   set(USE_INCLUDED_ZLIB 1)
 endif()
 
+# Check for gettext
+option(ENABLE_NLS "Enable translation of program messages" ON)
+find_package(Gettext)
+set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale")
+
 # Check for libjpeg
 find_package(JPEG REQUIRED)
 
@@ -199,5 +204,6 @@
 endif()
 
 if(BUILD_NEW_VNCVIEWER)
+  add_subdirectory(po)
   add_subdirectory(vncviewer)
 endif()
Index: po/CMakeLists.txt
===================================================================
--- po/CMakeLists.txt   (revision 0)
+++ po/CMakeLists.txt   (revision 0)
@@ -0,0 +1,63 @@
+# Gettext support - mostly borrowed from the Licq project
+
+set(po_FILES
+    de fr pl ru sk sv
+)
+
+find_package(Gettext REQUIRED)
+
+if (NOT GETTEXT_MSGMERGE_EXECUTABLE AND NOT GETTEXT_MSGFMT_EXECUTABLE)
+  message(FATAL_ERROR "Gettext message catalog tools NOT found")
+endif (NOT GETTEXT_MSGMERGE_EXECUTABLE AND NOT GETTEXT_MSGFMT_EXECUTABLE)
+
+find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
+if (GETTEXT_XGETTEXT_EXECUTABLE)
+  # Get list of all source files
+  file(GLOB_RECURSE po_source
+    RELATIVE ${PROJECT_SOURCE_DIR}
+    ${PROJECT_SOURCE_DIR}/vncviewer/*.h
+    ${PROJECT_SOURCE_DIR}/vncviewer/*.cxx
+  )
+
+  add_custom_target(translations_update
+    ${GETTEXT_XGETTEXT_EXECUTABLE}
+      --directory ${PROJECT_SOURCE_DIR}
+      --output="${CMAKE_CURRENT_SOURCE_DIR}/tigervnc.pot"
+      --default-domain=tigervnc
+      --keyword=_
+      --keyword=N_
+      --copyright-holder='RealVNC Ltd, Constantin Kaplinsky, Peter Astrand, 
Cendio AB'
+      --msgid-bugs-address="tigervnc-devel@lists.sourceforge.net"
+      --sort-output
+      --no-location
+      ${po_source}
+    COMMENT "Updating tigervnc.pot"
+  )
+endif (GETTEXT_XGETTEXT_EXECUTABLE)
+
+foreach(lang ${po_FILES})
+  set(po  "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po")
+  set(mo "${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo")
+
+  # Update po files after pot file
+  add_custom_command(TARGET translations_update POST_BUILD
+    COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none
+      --sort-output ${po} ${CMAKE_CURRENT_SOURCE_DIR}/tigervnc.pot
+    COMMENT "Updating ${lang}.po"
+  )
+
+  # Add command to build X.mo from X.po
+  add_custom_command(OUTPUT ${mo}
+    COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po}
+    DEPENDS ${po}
+  )
+
+  install(FILES ${mo}
+    DESTINATION "${LOCALE_DIR}/${lang}/LC_MESSAGES"
+    RENAME tigervnc.mo
+  )
+
+  set(moFiles ${moFiles} ${mo})
+endforeach(lang)
+
+add_custom_target(translations ALL DEPENDS ${moFiles})
------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to