From 1882501451ff4b0025369d1ba39126afc73e5acf Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Mon, 24 Sep 2012 16:11:06 +0400 Subject: [PATCH] gettext example --- c/gettext-gtk/Makefile | 106 ++++++++++++++++++ c/gettext-gtk/helloworld.c | 43 +++++++ c/gettext-gtk/locale/helloworld.pot | 26 +++++ .../locale/ru/LC_MESSAGES/helloworld.po | 27 +++++ c/gettext-gtk/make_po.sh | 3 + c/gettext_cmake/CMakeLists.txt | 12 ++ c/gettext_cmake/README | 1 + .../cmake/MacroOptionalAddSubdirectory.cmake | 31 +++++ c/gettext_cmake/po/CMakeLists.txt | 9 ++ c/gettext_cmake/po/gettextex1.pot | 28 +++++ c/gettext_cmake/po/it/CMakeLists.txt | 2 + c/gettext_cmake/po/it/gettextex1.po | 28 +++++ c/gettext_cmake/po/ru/CMakeLists.txt | 2 + c/gettext_cmake/po/ru/gettextex1.po | 29 +++++ c/gettext_cmake/src/.keep | 0 c/gettext_cmake/test/CMakeLists.txt | 13 +++ c/gettext_cmake/test/gettextex1.c | 21 ++++ c/gettext_cmake/util/borland_test.bat | 18 +++ c/gettext_cmake/util/gcc_test.sh | 11 ++ c/gettext_cmake/util/mingw32_test.sh | 11 ++ c/gettext_cmake/util/msvc_test.bat | 18 +++ c/gettext_cmake/util/update-po.sh | 38 +++++++ c/gettext_lib_cmake/CMakeLists.txt | 20 ++++ .../cmake/MacroOptionalAddSubdirectory.cmake | 31 +++++ c/gettext_lib_cmake/po/CMakeLists.txt | 9 ++ c/gettext_lib_cmake/po/gettextex2.pot | 28 +++++ c/gettext_lib_cmake/po/it/CMakeLists.txt | 2 + c/gettext_lib_cmake/po/it/gettextex2.po | 28 +++++ c/gettext_lib_cmake/po/ru/CMakeLists.txt | 2 + c/gettext_lib_cmake/po/ru/gettextex2.po | 29 +++++ c/gettext_lib_cmake/src/.keep | 0 c/gettext_lib_cmake/src/CMakeLists.txt | 13 +++ c/gettext_lib_cmake/src/gettext_config.h | 12 ++ c/gettext_lib_cmake/src/gettextex2.c | 42 +++++++ c/gettext_lib_cmake/src/gettextex2.h | 8 ++ c/gettext_lib_cmake/src/gettextex2_export.h | 14 +++ c/gettext_lib_cmake/test/CMakeLists.txt | 13 +++ c/gettext_lib_cmake/test/gettextex2_test.c | 14 +++ c/gettext_lib_cmake/util/borland_test.bat | 28 +++++ c/gettext_lib_cmake/util/gcc_test.sh | 18 +++ c/gettext_lib_cmake/util/mingw32_test.sh | 18 +++ c/gettext_lib_cmake/util/msvc_test.bat | 28 +++++ c/gettext_lib_cmake/util/update-po.sh | 38 +++++++ 43 files changed, 872 insertions(+) create mode 100644 c/gettext-gtk/Makefile create mode 100644 c/gettext-gtk/helloworld.c create mode 100644 c/gettext-gtk/locale/helloworld.pot create mode 100644 c/gettext-gtk/locale/ru/LC_MESSAGES/helloworld.po create mode 100755 c/gettext-gtk/make_po.sh create mode 100644 c/gettext_cmake/CMakeLists.txt create mode 100644 c/gettext_cmake/README create mode 100644 c/gettext_cmake/cmake/MacroOptionalAddSubdirectory.cmake create mode 100644 c/gettext_cmake/po/CMakeLists.txt create mode 100644 c/gettext_cmake/po/gettextex1.pot create mode 100644 c/gettext_cmake/po/it/CMakeLists.txt create mode 100644 c/gettext_cmake/po/it/gettextex1.po create mode 100644 c/gettext_cmake/po/ru/CMakeLists.txt create mode 100644 c/gettext_cmake/po/ru/gettextex1.po create mode 100644 c/gettext_cmake/src/.keep create mode 100644 c/gettext_cmake/test/CMakeLists.txt create mode 100644 c/gettext_cmake/test/gettextex1.c create mode 100644 c/gettext_cmake/util/borland_test.bat create mode 100755 c/gettext_cmake/util/gcc_test.sh create mode 100755 c/gettext_cmake/util/mingw32_test.sh create mode 100644 c/gettext_cmake/util/msvc_test.bat create mode 100755 c/gettext_cmake/util/update-po.sh create mode 100644 c/gettext_lib_cmake/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/cmake/MacroOptionalAddSubdirectory.cmake create mode 100644 c/gettext_lib_cmake/po/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/po/gettextex2.pot create mode 100644 c/gettext_lib_cmake/po/it/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/po/it/gettextex2.po create mode 100644 c/gettext_lib_cmake/po/ru/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/po/ru/gettextex2.po create mode 100644 c/gettext_lib_cmake/src/.keep create mode 100644 c/gettext_lib_cmake/src/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/src/gettext_config.h create mode 100644 c/gettext_lib_cmake/src/gettextex2.c create mode 100644 c/gettext_lib_cmake/src/gettextex2.h create mode 100644 c/gettext_lib_cmake/src/gettextex2_export.h create mode 100644 c/gettext_lib_cmake/test/CMakeLists.txt create mode 100644 c/gettext_lib_cmake/test/gettextex2_test.c create mode 100644 c/gettext_lib_cmake/util/borland_test.bat create mode 100755 c/gettext_lib_cmake/util/gcc_test.sh create mode 100755 c/gettext_lib_cmake/util/mingw32_test.sh create mode 100644 c/gettext_lib_cmake/util/msvc_test.bat create mode 100755 c/gettext_lib_cmake/util/update-po.sh diff --git a/c/gettext-gtk/Makefile b/c/gettext-gtk/Makefile new file mode 100644 index 0000000..2bae7c6 --- /dev/null +++ b/c/gettext-gtk/Makefile @@ -0,0 +1,106 @@ +# Makefile generated by command: smake.sh -t helloworld -Pglib-2.0 -Pgtk+-2.0 +# This file is generated with smake.sh. +# You can use this make file with instruction make to +# use one of build mode: debug, profile, develop, release. +# No need to call make clean if You make with other mode, +# because the Makefile containes rules for automatically clean. +# Some usage examples: +# make # default mode is debug +# CFLAGS="-O2 -march=core2 -mtune=core2 -msse4.1 -mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=develop +# CFLAGS="-O2 -march=amdfam10 -mtune=amdfam10 -msse4a --mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=profile +# CFLAGS="-O2 -march=k6-2 -mtune=k6-2 -m3dnow --mfpmath=387 -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=release +# Report bugs to + +#_________________________________ +# ENVIRONMENT | +#________________________________| +TARGET0=helloworld +TARGETS= $(TARGET0) +CC=cc +CXX=c++ +CFLAGS := $(CFLAGS) +CXXFLAGS := $(CXXFLAGS) +LDFLAGS := $(LDFLAGS) +LIBS=-latk-1.0 -lcairo -lfontconfig -lfreetype -lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lgtk-x11-2.0 -lpango-1.0 -lpangocairo-1.0 -lpangoft2-1.0 -lrt -pthread +SRC= +INCLUDES=-D_REENTRANT -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/directfb -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/include/gtk-2.0 -I/usr/include/libdrm -I/usr/include/libpng15 -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/lib64/glib-2.0/include -I/usr/lib64/gtk-2.0/include -pthread +#________________________________________ +# BUILD SCRIPT (don't change) | +#_______________________________________| +ifeq ($(mode),) + mode = debug +endif +ifeq ($(mode),debug) + CFLAGS := -O0 -g -DDEBUG -std=c99 -pedantic -Wextra -Wconversion $(CFLAGS) + LDFLAGS := $(LDFLAGS) +endif +ifeq ($(mode),profile) + CFLAGS := -O0 -g -DDEBUG -std=c99 -p -ftest-coverage -Wcoverage-mismatch $(CFLAGS) + LDFLAGS := -g -p $(LDFLAGS) +endif +ifeq ($(mode),develop) + CFLAGS := -O2 -g -DDEBUG -std=c99 $(CFLAGS) + LDFLAGS := -O1 $(LDFLAGS) +endif +ifeq ($(mode),release) + CFLAGS := -O2 -std=c99 $(CFLAGS) + LDFLAGS := -O1 $(LDFLAGS) +endif + +CFLAGS += -Wall $(INCLUDES) +LDFLAGS += -Wall + +all: + @make change_make_options &>/dev/null + +make $(TARGETS) + +ifneq ($(mode),debug) +ifneq ($(mode),profile) +ifneq ($(mode),develop) +ifneq ($(mode),release) + @echo "Invalid build mode." + @echo "Please use 'make mode=release', 'make mode=develop', 'make mode=profile' or 'make mode=debug'" + @exit 1 +endif +endif +endif +endif + @echo ".........................." + @echo "Building on "$(mode)" mode " + @echo "CFLAGS=$(CFLAGS)" + @echo "LDFLAGS=$(LDFLAGS)" + @echo ".........................." + +OLD_BUILD_MODE=$(shell grep ^MODE make_options.out 2>/dev/null | sed 's~^MODE=~~') +OLD_BUILD_CFLAGS=$(shell grep ^CFLAGS make_options.out 2>/dev/null | sed 's~^CFLAGS=~~') +OLD_BUILD_LDFLAGS=$(shell grep ^LDFLAGS make_options.out 2>/dev/null | sed 's~^LDFLAGS=~~') +change_make_options: +ifneq ($(mode)|$(CFLAGS)|$(LDFLAGS), $(OLD_BUILD_MODE)|$(OLD_BUILD_CFLAGS)|$(OLD_BUILD_LDFLAGS)) + @echo CLEANING... + @make clean + @echo "MODE=$(mode)" > make_options.out + @echo "CFLAGS=$(CFLAGS)" >> make_options.out + @echo "LDFLAGS=$(LDFLAGS)" >> make_options.out +endif + +%.o : + $(CC) -c $(CFLAGS) $(SRC) -o $@ $< + +clean: + $(RM) *.o *.out callgrind.out.* *.gcno $(TARGETS) + +.PHONY: all change_make_options clean + +#_________________________________ +# R U L E S | +#________________________________| +target_objs0 = \ + helloworld.o + +$(TARGET0): $(target_objs0) + $(CC) $(LDFLAGS) -o $@ $(target_objs0) $(LIBS) + + +helloworld.o: \ + helloworld.c + diff --git a/c/gettext-gtk/helloworld.c b/c/gettext-gtk/helloworld.c new file mode 100644 index 0000000..e8c384d --- /dev/null +++ b/c/gettext-gtk/helloworld.c @@ -0,0 +1,43 @@ +#include +#include +#define _(String) gettext (String) +//#define gettext_noop(String) String +#////////////define N_(String) gettext_noop (String) +#define GETTEXT_PACKAGE "helloworld" +//#define LOCALEDIR "./locale" +static void button_clicked(GtkWidget * widget, gpointer data) +{ + g_print("Button pressed!\n"); +} +static gboolean delete_event(GtkWidget * widget, GdkEvent * event, gpointer data) +{ + g_print("Delete event occurred\n"); + return FALSE; +} +static void destroy(GtkWidget * widget, gpointer data) +{ + g_print("Destroy signal sent\n"); + gtk_main_quit(); +} +int main(int argc, char ** argv) +{ + GtkWidget * window; + GtkWidget * button; + //bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + //bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + gtk_init(&argc, &argv); + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(window), _("Hello World!")); + gtk_container_set_border_width(GTK_CONTAINER(window), 10); + g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); + button = gtk_button_new_with_label(_("Quit")); + g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), NULL); + g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT(window)); + gtk_container_add(GTK_CONTAINER(window), button); + gtk_widget_show(button); + gtk_widget_show(window); + gtk_main(); + return 0; +} diff --git a/c/gettext-gtk/locale/helloworld.pot b/c/gettext-gtk/locale/helloworld.pot new file mode 100644 index 0000000..a873f52 --- /dev/null +++ b/c/gettext-gtk/locale/helloworld.pot @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-19 18:16+0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: helloworld.c:31 +msgid "Hello World!" +msgstr "" + +#: helloworld.c:35 +msgid "Quit" +msgstr "" diff --git a/c/gettext-gtk/locale/ru/LC_MESSAGES/helloworld.po b/c/gettext-gtk/locale/ru/LC_MESSAGES/helloworld.po new file mode 100644 index 0000000..53b542d --- /dev/null +++ b/c/gettext-gtk/locale/ru/LC_MESSAGES/helloworld.po @@ -0,0 +1,27 @@ +# Russian translations for PACKAGE package. +# Copyright (C) 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-19 18:16+0400\n" +"PO-Revision-Date: 2012-09-19 18:16+0400\n" +"Last-Translator: \n" +"Language-Team: Russian\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#: helloworld.c:31 +msgid "Hello World!" +msgstr "Привет, Мир!" + +#: helloworld.c:35 +msgid "Quit" +msgstr "Выход" diff --git a/c/gettext-gtk/make_po.sh b/c/gettext-gtk/make_po.sh new file mode 100755 index 0000000..9d16bd1 --- /dev/null +++ b/c/gettext-gtk/make_po.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +xgettext -C helloworld.c -k_ diff --git a/c/gettext_cmake/CMakeLists.txt b/c/gettext_cmake/CMakeLists.txt new file mode 100644 index 0000000..d0d737d --- /dev/null +++ b/c/gettext_cmake/CMakeLists.txt @@ -0,0 +1,12 @@ +project (gettextex1) + +cmake_minimum_required (VERSION 2.8) + +set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +include(MacroOptionalAddSubdirectory) + +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/run") + +set (LOCALE_INSTALL_DIR "share/locale") +macro_optional_add_subdirectory (po) +add_subdirectory (test) diff --git a/c/gettext_cmake/README b/c/gettext_cmake/README new file mode 100644 index 0000000..f7920b2 --- /dev/null +++ b/c/gettext_cmake/README @@ -0,0 +1 @@ +To fix Borland varrags.h && stdarg.h error just comment #error line in them. diff --git a/c/gettext_cmake/cmake/MacroOptionalAddSubdirectory.cmake b/c/gettext_cmake/cmake/MacroOptionalAddSubdirectory.cmake new file mode 100644 index 0000000..545048b --- /dev/null +++ b/c/gettext_cmake/cmake/MacroOptionalAddSubdirectory.cmake @@ -0,0 +1,31 @@ +# - MACRO_OPTIONAL_ADD_SUBDIRECTORY() combines ADD_SUBDIRECTORY() with an OPTION() +# MACRO_OPTIONAL_ADD_SUBDIRECTORY( ) +# If you use MACRO_OPTIONAL_ADD_SUBDIRECTORY() instead of ADD_SUBDIRECTORY(), +# this will have two effects +# 1 - CMake will not complain if the directory doesn't exist +# This makes sense if you want to distribute just one of the subdirs +# in a source package, e.g. just one of the subdirs in kdeextragear. +# 2 - If the directory exists, it will offer an option to skip the +# subdirectory. +# This is useful if you want to compile only a subset of all +# directories. + +# Copyright (c) 2007, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) + GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) + IF(EXISTS ${_fullPath}) + IF(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" ${ARGV1}) + ELSE(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE) + ENDIF(${ARGC} EQUAL 2) + IF(BUILD_${_dir}) + ADD_SUBDIRECTORY(${_dir}) + ENDIF(BUILD_${_dir}) + ENDIF(EXISTS ${_fullPath}) +ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY) diff --git a/c/gettext_cmake/po/CMakeLists.txt b/c/gettext_cmake/po/CMakeLists.txt new file mode 100644 index 0000000..7fc66e3 --- /dev/null +++ b/c/gettext_cmake/po/CMakeLists.txt @@ -0,0 +1,9 @@ +find_package(Gettext REQUIRED) +if (NOT GETTEXT_MSGMERGE_EXECUTABLE) +MESSAGE(FATAL_ERROR "Please install msgmerge binary") +endif (NOT GETTEXT_MSGMERGE_EXECUTABLE) +if (NOT GETTEXT_MSGFMT_EXECUTABLE) +MESSAGE(FATAL_ERROR "Please install msgmerge binary") +endif (NOT GETTEXT_MSGFMT_EXECUTABLE) +add_subdirectory(ru) +add_subdirectory(it) diff --git a/c/gettext_cmake/po/gettextex1.pot b/c/gettext_cmake/po/gettextex1.pot new file mode 100644 index 0000000..53f4e09 --- /dev/null +++ b/c/gettext_cmake/po/gettextex1.pot @@ -0,0 +1,28 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "" diff --git a/c/gettext_cmake/po/it/CMakeLists.txt b/c/gettext_cmake/po/it/CMakeLists.txt new file mode 100644 index 0000000..eba335a --- /dev/null +++ b/c/gettext_cmake/po/it/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB _po_files *.po) +GETTEXT_PROCESS_PO_FILES(it ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} PO_FILES ${_po_files} ) diff --git a/c/gettext_cmake/po/it/gettextex1.po b/c/gettext_cmake/po/it/gettextex1.po new file mode 100644 index 0000000..103c58a --- /dev/null +++ b/c/gettext_cmake/po/it/gettextex1.po @@ -0,0 +1,28 @@ +# Italian translations for gettextex1 package. +# Copyright (C) 2012 THE gettextex1'S COPYRIGHT HOLDER +# This file is distributed under the same license as the gettextex1 package. +# , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: 2012-09-21 13:32+0400\n" +"Last-Translator: \n" +"Language-Team: Italian\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "" diff --git a/c/gettext_cmake/po/ru/CMakeLists.txt b/c/gettext_cmake/po/ru/CMakeLists.txt new file mode 100644 index 0000000..5b39538 --- /dev/null +++ b/c/gettext_cmake/po/ru/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB _po_files *.po) +GETTEXT_PROCESS_PO_FILES(ru ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} PO_FILES ${_po_files} ) diff --git a/c/gettext_cmake/po/ru/gettextex1.po b/c/gettext_cmake/po/ru/gettextex1.po new file mode 100644 index 0000000..48f4b5b --- /dev/null +++ b/c/gettext_cmake/po/ru/gettextex1.po @@ -0,0 +1,29 @@ +# Russian translations for gettextex1 package. +# Copyright (C) 2012 THE gettextex1'S COPYRIGHT HOLDER +# This file is distributed under the same license as the gettextex1 package. +# , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: 2012-09-21 13:32+0400\n" +"Last-Translator: \n" +"Language-Team: Russian\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "Привет, Мир!" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "Выход" diff --git a/c/gettext_cmake/src/.keep b/c/gettext_cmake/src/.keep new file mode 100644 index 0000000..e69de29 diff --git a/c/gettext_cmake/test/CMakeLists.txt b/c/gettext_cmake/test/CMakeLists.txt new file mode 100644 index 0000000..b14fbf0 --- /dev/null +++ b/c/gettext_cmake/test/CMakeLists.txt @@ -0,0 +1,13 @@ +find_package (PkgConfig REQUIRED) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) + +include_directories (${GLIB2_INCLUDE_DIRS}) +link_directories (${GLIB2_LIBRARY_DIRS}) + +if (CMAKE_COMPILER_IS_GNUCC) + add_definitions (${GLIB2_CFLAGS_OTHER}) +endif () + +# add the executable +add_executable (gettextex1 gettextex1.c) +target_link_libraries (gettextex1 ${GLIB2_LIBRARIES}) diff --git a/c/gettext_cmake/test/gettextex1.c b/c/gettext_cmake/test/gettextex1.c new file mode 100644 index 0000000..b1c45b2 --- /dev/null +++ b/c/gettext_cmake/test/gettextex1.c @@ -0,0 +1,21 @@ +#include +#include +#include + +#define _(String) gettext (String) +#define GETTEXT_PACKAGE "gettextex1" +#define LOCALEDIR "./locale" +int main(void) +{ + setlocale (LC_ALL, ""); + + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + //bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + g_printf (_("Hello World!")); + g_printf ("\n"); + g_printf (_("Quit")); + + return 0; +} diff --git a/c/gettext_cmake/util/borland_test.bat b/c/gettext_cmake/util/borland_test.bat new file mode 100644 index 0000000..af0e9a0 --- /dev/null +++ b/c/gettext_cmake/util/borland_test.bat @@ -0,0 +1,18 @@ +@echo off +echo a +del /s/q/f build-borland +rmdir /s/q build-borland +mkdir build-borland +cd build-borland +cmake -G "Borland Makefiles" -DCMAKE_C_FLAGS="-Ic:/usr-bcb/include" .. +make +mkdir run\locale +mkdir run\locale\ru +mkdir run\locale\ru\LC_MESSAGES +mkdir run\locale\it +mkdir run\locale\it\LC_MESSAGES +copy po\ru\gettextex1.gmo run\locale\ru\LC_MESSAGES\gettextex1.mo +copy po\it\gettextex1.gmo run\locale\it\LC_MESSAGES\gettextex1.mo +cd run +gettextex1.exe +cd ..\.. diff --git a/c/gettext_cmake/util/gcc_test.sh b/c/gettext_cmake/util/gcc_test.sh new file mode 100755 index 0000000..d576b95 --- /dev/null +++ b/c/gettext_cmake/util/gcc_test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +rm -rf build-gcc +mkdir build-gcc && cd build-gcc && cmake .. && make +[ 0 != $? ] && echo "make failed ;-(" && exit 1 +mkdir -p run/locale/ru/LC_MESSAGES +mkdir -p run/locale/it/LC_MESSAGES +cp po/ru/gettextex1.gmo run/locale/ru/LC_MESSAGES/gettextex1.mo +cp po/it/gettextex1.gmo run/locale/it/LC_MESSAGES/gettextex1.mo +cd run +./gettextex1 diff --git a/c/gettext_cmake/util/mingw32_test.sh b/c/gettext_cmake/util/mingw32_test.sh new file mode 100755 index 0000000..7deb3c8 --- /dev/null +++ b/c/gettext_cmake/util/mingw32_test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +rm -rf build-mingw +mkdir build-mingw && cd build-mingw && cmake -G "MSYS Makefiles" .. && make +[ 0 != $? ] && echo "make failed ;-(" && exit 1 +mkdir -p run/locale/ru/LC_MESSAGES +mkdir -p run/locale/it/LC_MESSAGES +cp po/ru/gettextex1.gmo run/locale/ru/LC_MESSAGES/gettextex1.mo +cp po/it/gettextex1.gmo run/locale/it/LC_MESSAGES/gettextex1.mo +cd run +./gettextex1 diff --git a/c/gettext_cmake/util/msvc_test.bat b/c/gettext_cmake/util/msvc_test.bat new file mode 100644 index 0000000..1b1bcc5 --- /dev/null +++ b/c/gettext_cmake/util/msvc_test.bat @@ -0,0 +1,18 @@ +@echo off +echo a +del /s/q/f build-msvc +rmdir /s/q build-msvc +mkdir build-msvc +cd build-msvc +cmake -G "NMake Makefiles" -DCMAKE_C_FLAGS="-Ic:/usr/include" .. +nmake +mkdir run\locale +mkdir run\locale\ru +mkdir run\locale\ru\LC_MESSAGES +mkdir run\locale\it +mkdir run\locale\it\LC_MESSAGES +copy po\ru\gettextex1.gmo run\locale\ru\LC_MESSAGES\gettextex1.mo +copy po\it\gettextex1.gmo run\locale\it\LC_MESSAGES\gettextex1.mo +cd run +gettextex1.exe +cd ..\.. diff --git a/c/gettext_cmake/util/update-po.sh b/c/gettext_cmake/util/update-po.sh new file mode 100755 index 0000000..ad5eb90 --- /dev/null +++ b/c/gettext_cmake/util/update-po.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## +# settings +## +PROJECT=gettextex1 +PO_DIR_NAME=po + +SCRIPT_PATH=`readlink -f $0` +SCRIPT_DIR=${SCRIPT_PATH%/*} +PRJDIR=${SCRIPT_DIR%/*} + +FILELIST="${PRJDIR}/test/*.c" + +## +# code +## +echo $FILELIST +xgettext --package-name=$PROJECT --default-domain=$PROJECT --add-comments=/// \ + -k_ -kQ_ -kC_ -kN_ -kNC_ -kg_dgettext -kg_dcgettext \ + -kg_dngettext -kg_dpgettext -kg_dpgettext2 -kg_strip_context -F -n -o \ + $PRJDIR/$PO_DIR_NAME/$PROJECT.pot $FILELIST + +[ 0 != $? ] && echo "xgettext failed ;-(" && exit 1 +[ ! -e $PRJDIR/$PO_DIR_NAME/$PROJECT.pot ] && echo "No strings found ;-(" && exit 1 + +for d in $PRJDIR/$PO_DIR_NAME/*; do + [ ! -d $d ] && continue + + if [ -e $d/$PROJECT.po ]; then + echo "Merging '${d##*/}' locale" && msgmerge -F -U $d/$PROJECT.po $PRJDIR/$PO_DIR_NAME/$PROJECT.pot + [ 0 != $? ] && echo "msgmerge failed ;(" && exit 1 + else + echo "Creating '${d##*/}' locale" && msginit -l ${d##*/} -o $d/$PROJECT.po -i $PRJDIR/$PO_DIR_NAME/$PROJECT.pot + [ 0 != $? ] && echo "msginit failed ;(" && exit 1 + fi + +done diff --git a/c/gettext_lib_cmake/CMakeLists.txt b/c/gettext_lib_cmake/CMakeLists.txt new file mode 100644 index 0000000..ac20d54 --- /dev/null +++ b/c/gettext_lib_cmake/CMakeLists.txt @@ -0,0 +1,20 @@ +project (gettextex2) + +cmake_minimum_required (VERSION 2.8) + +set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +include(MacroOptionalAddSubdirectory) + +set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/run") + +include_directories ("${CMAKE_BINARY_DIR}") +include_directories ("${PROJECT_SOURCE_DIR}/src") + +if (NOT "" STREQUAL "${CUSTOM_INCLUDE_PATH}") + include_directories ("${CUSTOM_INCLUDE_PATH}") +endif () + +add_subdirectory (src) +set (LOCALE_INSTALL_DIR "share/locale") +macro_optional_add_subdirectory (po) +add_subdirectory (test) diff --git a/c/gettext_lib_cmake/cmake/MacroOptionalAddSubdirectory.cmake b/c/gettext_lib_cmake/cmake/MacroOptionalAddSubdirectory.cmake new file mode 100644 index 0000000..545048b --- /dev/null +++ b/c/gettext_lib_cmake/cmake/MacroOptionalAddSubdirectory.cmake @@ -0,0 +1,31 @@ +# - MACRO_OPTIONAL_ADD_SUBDIRECTORY() combines ADD_SUBDIRECTORY() with an OPTION() +# MACRO_OPTIONAL_ADD_SUBDIRECTORY( ) +# If you use MACRO_OPTIONAL_ADD_SUBDIRECTORY() instead of ADD_SUBDIRECTORY(), +# this will have two effects +# 1 - CMake will not complain if the directory doesn't exist +# This makes sense if you want to distribute just one of the subdirs +# in a source package, e.g. just one of the subdirs in kdeextragear. +# 2 - If the directory exists, it will offer an option to skip the +# subdirectory. +# This is useful if you want to compile only a subset of all +# directories. + +# Copyright (c) 2007, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) + GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) + IF(EXISTS ${_fullPath}) + IF(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" ${ARGV1}) + ELSE(${ARGC} EQUAL 2) + OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE) + ENDIF(${ARGC} EQUAL 2) + IF(BUILD_${_dir}) + ADD_SUBDIRECTORY(${_dir}) + ENDIF(BUILD_${_dir}) + ENDIF(EXISTS ${_fullPath}) +ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY) diff --git a/c/gettext_lib_cmake/po/CMakeLists.txt b/c/gettext_lib_cmake/po/CMakeLists.txt new file mode 100644 index 0000000..7fc66e3 --- /dev/null +++ b/c/gettext_lib_cmake/po/CMakeLists.txt @@ -0,0 +1,9 @@ +find_package(Gettext REQUIRED) +if (NOT GETTEXT_MSGMERGE_EXECUTABLE) +MESSAGE(FATAL_ERROR "Please install msgmerge binary") +endif (NOT GETTEXT_MSGMERGE_EXECUTABLE) +if (NOT GETTEXT_MSGFMT_EXECUTABLE) +MESSAGE(FATAL_ERROR "Please install msgmerge binary") +endif (NOT GETTEXT_MSGFMT_EXECUTABLE) +add_subdirectory(ru) +add_subdirectory(it) diff --git a/c/gettext_lib_cmake/po/gettextex2.pot b/c/gettext_lib_cmake/po/gettextex2.pot new file mode 100644 index 0000000..53f4e09 --- /dev/null +++ b/c/gettext_lib_cmake/po/gettextex2.pot @@ -0,0 +1,28 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "" diff --git a/c/gettext_lib_cmake/po/it/CMakeLists.txt b/c/gettext_lib_cmake/po/it/CMakeLists.txt new file mode 100644 index 0000000..eba335a --- /dev/null +++ b/c/gettext_lib_cmake/po/it/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB _po_files *.po) +GETTEXT_PROCESS_PO_FILES(it ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} PO_FILES ${_po_files} ) diff --git a/c/gettext_lib_cmake/po/it/gettextex2.po b/c/gettext_lib_cmake/po/it/gettextex2.po new file mode 100644 index 0000000..103c58a --- /dev/null +++ b/c/gettext_lib_cmake/po/it/gettextex2.po @@ -0,0 +1,28 @@ +# Italian translations for gettextex1 package. +# Copyright (C) 2012 THE gettextex1'S COPYRIGHT HOLDER +# This file is distributed under the same license as the gettextex1 package. +# , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: 2012-09-21 13:32+0400\n" +"Last-Translator: \n" +"Language-Team: Italian\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "" diff --git a/c/gettext_lib_cmake/po/ru/CMakeLists.txt b/c/gettext_lib_cmake/po/ru/CMakeLists.txt new file mode 100644 index 0000000..5b39538 --- /dev/null +++ b/c/gettext_lib_cmake/po/ru/CMakeLists.txt @@ -0,0 +1,2 @@ +file(GLOB _po_files *.po) +GETTEXT_PROCESS_PO_FILES(ru ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} PO_FILES ${_po_files} ) diff --git a/c/gettext_lib_cmake/po/ru/gettextex2.po b/c/gettext_lib_cmake/po/ru/gettextex2.po new file mode 100644 index 0000000..48f4b5b --- /dev/null +++ b/c/gettext_lib_cmake/po/ru/gettextex2.po @@ -0,0 +1,29 @@ +# Russian translations for gettextex1 package. +# Copyright (C) 2012 THE gettextex1'S COPYRIGHT HOLDER +# This file is distributed under the same license as the gettextex1 package. +# , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gettextex1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-09-21 14:30+0400\n" +"PO-Revision-Date: 2012-09-21 13:32+0400\n" +"Last-Translator: \n" +"Language-Team: Russian\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:14 +#, c-format +msgid "Hello World!" +msgstr "Привет, Мир!" + +#: /home/kolan/dev/c/gettext/test/gettextex1.c:16 +#, c-format +msgid "Quit" +msgstr "Выход" diff --git a/c/gettext_lib_cmake/src/.keep b/c/gettext_lib_cmake/src/.keep new file mode 100644 index 0000000..e69de29 diff --git a/c/gettext_lib_cmake/src/CMakeLists.txt b/c/gettext_lib_cmake/src/CMakeLists.txt new file mode 100644 index 0000000..eddc89e --- /dev/null +++ b/c/gettext_lib_cmake/src/CMakeLists.txt @@ -0,0 +1,13 @@ +find_package (PkgConfig REQUIRED) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) + +include_directories (${GLIB2_INCLUDE_DIRS}) +link_directories (${GLIB2_LIBRARY_DIRS}) + +if (CMAKE_COMPILER_IS_GNUCC) + add_definitions (${GLIB2_CFLAGS_OTHER}) +endif () + +# add the main library +add_library (gettextex2 SHARED gettextex2.c) +target_link_libraries (gettextex2 ${GLIB2_LIBRARIES}) diff --git a/c/gettext_lib_cmake/src/gettext_config.h b/c/gettext_lib_cmake/src/gettext_config.h new file mode 100644 index 0000000..87e4ea2 --- /dev/null +++ b/c/gettext_lib_cmake/src/gettext_config.h @@ -0,0 +1,12 @@ +#define GETTEXT_PACKAGE "gettextex2" +#if !defined (__STDC__) && !defined(_MSC_VER) +#define __STDC__ 1 +#include +#undef __STDC__ +#else +#ifdef __MINGW32__ +#include +#else +#include +#endif +#endif diff --git a/c/gettext_lib_cmake/src/gettextex2.c b/c/gettext_lib_cmake/src/gettextex2.c new file mode 100644 index 0000000..fb8e642 --- /dev/null +++ b/c/gettext_lib_cmake/src/gettextex2.c @@ -0,0 +1,42 @@ +#if defined(_MSC_VER) || defined(__BORLANDC__) +#include +#endif + +#include "gettext_config.h" + +#include + +#include "gettextex2.h" + +#ifdef LOCALEDIR +#undef LOCALEDIR +#define LOCALEDIR "./locale" +#endif + +#ifdef __GNUC__ +void __attribute__ ((constructor)) texparser_load (void) +#elif defined (_MSC_VER) || defined (__BORLANDC__) +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) +#else +#error Unknown compiler +#endif +{ +#ifdef LOCALEDIR + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); // remove if standard path used +#endif + textdomain (GETTEXT_PACKAGE); +#if defined(_MSC_VER) || defined(__BORLANDC__) + (void) hInstance; + (void) dwReason; + (void) lpReserved; + return TRUE; +#endif +} + +void +gettextex2 (void) +{ + g_printf (_("Hello World!")); + g_printf ("\n"); + g_printf (_("Quit")); +} diff --git a/c/gettext_lib_cmake/src/gettextex2.h b/c/gettext_lib_cmake/src/gettextex2.h new file mode 100644 index 0000000..bd751b0 --- /dev/null +++ b/c/gettext_lib_cmake/src/gettextex2.h @@ -0,0 +1,8 @@ +#ifndef __GETTEXTEX2_H__ +#define __GETTEXTEX2_H__ + +#include "gettextex2_export.h" + +GETTEXTEX2_EXPRT void gettextex2 (void); + +#endif // __GETTEXTEX2_H__ diff --git a/c/gettext_lib_cmake/src/gettextex2_export.h b/c/gettext_lib_cmake/src/gettextex2_export.h new file mode 100644 index 0000000..0ad9592 --- /dev/null +++ b/c/gettext_lib_cmake/src/gettextex2_export.h @@ -0,0 +1,14 @@ +#ifndef __GETTEXTEX2_EXPORT_H__ +#define __GETTEXTEX2_EXPORT_H__ + +#ifdef WIN32 +# ifdef gettextex2_EXPORTS +# define GETTEXTEX2_EXPRT __declspec(dllexport) +# else +# define GETTEXTEX2_EXPRT __declspec(dllimport) +# endif +#else +# define GETTEXTEX2_EXPRT +#endif + +#endif /* __GETTEXTEX2_EXPORT_H__ */ diff --git a/c/gettext_lib_cmake/test/CMakeLists.txt b/c/gettext_lib_cmake/test/CMakeLists.txt new file mode 100644 index 0000000..e537219 --- /dev/null +++ b/c/gettext_lib_cmake/test/CMakeLists.txt @@ -0,0 +1,13 @@ +find_package (PkgConfig REQUIRED) +pkg_check_modules (GLIB2 REQUIRED glib-2.0) + +include_directories (${GLIB2_INCLUDE_DIRS}) +link_directories (${GLIB2_LIBRARY_DIRS}) + +if (CMAKE_COMPILER_IS_GNUCC) + add_definitions (${GLIB2_CFLAGS_OTHER}) +endif () + +# add the executable +add_executable (gettextex2_test gettextex2_test.c) +target_link_libraries (gettextex2_test gettextex2 ${GLIB2_LIBRARIES}) diff --git a/c/gettext_lib_cmake/test/gettextex2_test.c b/c/gettext_lib_cmake/test/gettextex2_test.c new file mode 100644 index 0000000..ec2741c --- /dev/null +++ b/c/gettext_lib_cmake/test/gettextex2_test.c @@ -0,0 +1,14 @@ +#include + +#include + +#include "gettextex2.h" + +int main(void) +{ + setlocale (LC_ALL, ""); + + gettextex2 (); + + return 0; +} diff --git a/c/gettext_lib_cmake/util/borland_test.bat b/c/gettext_lib_cmake/util/borland_test.bat new file mode 100644 index 0000000..971e410 --- /dev/null +++ b/c/gettext_lib_cmake/util/borland_test.bat @@ -0,0 +1,28 @@ +@echo off +echo a +del /s/q/f build-borland +rmdir /s/q build-borland +mkdir build-borland +cd build-borland +cmake -G "Borland Makefiles" -DCMAKE_C_FLAGS="-DLOCALEDIR" -DCUSTOM_INCLUDE_PATH="c:/usr-bcb/include" .. +make + +mkdir src\locale +mkdir src\locale\ru +mkdir src\locale\ru\LC_MESSAGES +mkdir src\locale\it +mkdir src\locale\it\LC_MESSAGES +copy po\ru\gettextex2.gmo src\locale\ru\LC_MESSAGES\gettextex2.mo +copy po\it\gettextex2.gmo src\locale\it\LC_MESSAGES\gettextex2.mo + +mkdir run\locale +mkdir run\locale\ru +mkdir run\locale\ru\LC_MESSAGES +mkdir run\locale\it +mkdir run\locale\it\LC_MESSAGES +copy po\ru\gettextex2.gmo run\locale\ru\LC_MESSAGES\gettextex2.mo +copy po\it\gettextex2.gmo run\locale\it\LC_MESSAGES\gettextex2.mo + +cd run +gettextex2_test.exe +cd ..\.. diff --git a/c/gettext_lib_cmake/util/gcc_test.sh b/c/gettext_lib_cmake/util/gcc_test.sh new file mode 100755 index 0000000..244fca5 --- /dev/null +++ b/c/gettext_lib_cmake/util/gcc_test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +rm -rf build-gcc +mkdir build-gcc && cd build-gcc && cmake -DCMAKE_C_FLAGS="-DLOCALEDIR" .. && make +[ 0 != $? ] && echo "make failed ;-(" && exit 1 + +mkdir -p src/locale/ru/LC_MESSAGES +mkdir -p src/locale/it/LC_MESSAGES +cp po/ru/gettextex2.gmo src/locale/ru/LC_MESSAGES/gettextex2.mo +cp po/it/gettextex2.gmo src/locale/it/LC_MESSAGES/gettextex2.mo + +mkdir -p run/locale/ru/LC_MESSAGES +mkdir -p run/locale/it/LC_MESSAGES +cp po/ru/gettextex2.gmo run/locale/ru/LC_MESSAGES/gettextex2.mo +cp po/it/gettextex2.gmo run/locale/it/LC_MESSAGES/gettextex2.mo + +cd run +./gettextex2_test diff --git a/c/gettext_lib_cmake/util/mingw32_test.sh b/c/gettext_lib_cmake/util/mingw32_test.sh new file mode 100755 index 0000000..b142485 --- /dev/null +++ b/c/gettext_lib_cmake/util/mingw32_test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +rm -rf build-mingw +mkdir build-mingw && cd build-mingw && cmake -G "MSYS Makefiles" -DCMAKE_C_FLAGS="-DLOCALEDIR" .. && make +[ 0 != $? ] && echo "make failed ;-(" && exit 1 + +mkdir -p src/locale/ru/LC_MESSAGES +mkdir -p src/locale/it/LC_MESSAGES +cp po/ru/gettextex2.gmo src/locale/ru/LC_MESSAGES/gettextex2.mo +cp po/it/gettextex2.gmo src/locale/it/LC_MESSAGES/gettextex2.mo + +mkdir -p run/locale/ru/LC_MESSAGES +mkdir -p run/locale/it/LC_MESSAGES +cp po/ru/gettextex2.gmo run/locale/ru/LC_MESSAGES/gettextex2.mo +cp po/it/gettextex2.gmo run/locale/it/LC_MESSAGES/gettextex2.mo + +cd run +./gettextex2_test diff --git a/c/gettext_lib_cmake/util/msvc_test.bat b/c/gettext_lib_cmake/util/msvc_test.bat new file mode 100644 index 0000000..b1c7842 --- /dev/null +++ b/c/gettext_lib_cmake/util/msvc_test.bat @@ -0,0 +1,28 @@ +@echo off +echo a +del /s/q/f build-msvc +rmdir /s/q build-msvc +mkdir build-msvc +cd build-msvc +cmake -G "NMake Makefiles" -DCUSTOM_INCLUDE_PATH="c:/usr/include" -DCMAKE_C_FLAGS="-DLOCALEDIR" .. +nmake + +mkdir src\locale +mkdir src\locale\ru +mkdir src\locale\ru\LC_MESSAGES +mkdir src\locale\it +mkdir src\locale\it\LC_MESSAGES +copy po\ru\gettextex2.gmo src\locale\ru\LC_MESSAGES\gettextex2.mo +copy po\it\gettextex2.gmo src\locale\it\LC_MESSAGES\gettextex2.mo + +mkdir run\locale +mkdir run\locale\ru +mkdir run\locale\ru\LC_MESSAGES +mkdir run\locale\it +mkdir run\locale\it\LC_MESSAGES +copy po\ru\gettextex2.gmo run\locale\ru\LC_MESSAGES\gettextex2.mo +copy po\it\gettextex2.gmo run\locale\it\LC_MESSAGES\gettextex2.mo + +cd run +gettextex2_test.exe +cd ..\.. diff --git a/c/gettext_lib_cmake/util/update-po.sh b/c/gettext_lib_cmake/util/update-po.sh new file mode 100755 index 0000000..ad5eb90 --- /dev/null +++ b/c/gettext_lib_cmake/util/update-po.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## +# settings +## +PROJECT=gettextex1 +PO_DIR_NAME=po + +SCRIPT_PATH=`readlink -f $0` +SCRIPT_DIR=${SCRIPT_PATH%/*} +PRJDIR=${SCRIPT_DIR%/*} + +FILELIST="${PRJDIR}/test/*.c" + +## +# code +## +echo $FILELIST +xgettext --package-name=$PROJECT --default-domain=$PROJECT --add-comments=/// \ + -k_ -kQ_ -kC_ -kN_ -kNC_ -kg_dgettext -kg_dcgettext \ + -kg_dngettext -kg_dpgettext -kg_dpgettext2 -kg_strip_context -F -n -o \ + $PRJDIR/$PO_DIR_NAME/$PROJECT.pot $FILELIST + +[ 0 != $? ] && echo "xgettext failed ;-(" && exit 1 +[ ! -e $PRJDIR/$PO_DIR_NAME/$PROJECT.pot ] && echo "No strings found ;-(" && exit 1 + +for d in $PRJDIR/$PO_DIR_NAME/*; do + [ ! -d $d ] && continue + + if [ -e $d/$PROJECT.po ]; then + echo "Merging '${d##*/}' locale" && msgmerge -F -U $d/$PROJECT.po $PRJDIR/$PO_DIR_NAME/$PROJECT.pot + [ 0 != $? ] && echo "msgmerge failed ;(" && exit 1 + else + echo "Creating '${d##*/}' locale" && msginit -l ${d##*/} -o $d/$PROJECT.po -i $PRJDIR/$PO_DIR_NAME/$PROJECT.pot + [ 0 != $? ] && echo "msginit failed ;(" && exit 1 + fi + +done