mirror of
https://github.com/eddyem/eddys_snippets.git
synced 2026-03-20 00:30:59 +03:00
first commit
This commit is contained in:
32
simple_gettext/1.c
Normal file
32
simple_gettext/1.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <libintl.h>
|
||||
#include <locale.h>
|
||||
|
||||
#define _(String) gettext(String)
|
||||
#define gettext_noop(String) String
|
||||
#define N_(String) gettext_noop(String)
|
||||
|
||||
int main(int argc, char **argv){
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
|
||||
/*
|
||||
* To run in GUI bullshit (like qt or gtk) you must do:
|
||||
* bind_textdomain_codeset(PACKAGE, "UTF8");
|
||||
*/
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
/*
|
||||
* In case when you need both GUI and CLI, you should
|
||||
* do this:
|
||||
* char*old = bind_textdomain_codeset (PACKAGE, "");
|
||||
* before printf calling
|
||||
* To restore GUI hrunicode do
|
||||
* bind_textdomain_codeset (PACKAGE, old);
|
||||
* at the end of printf's
|
||||
*/
|
||||
/// ðÅÒÅ×ÅÄÅÎÏ ÇÅÔÔÅËÓÔÏÍ\n
|
||||
printf(_("Translated by gettext\n"));
|
||||
/// ÷ÐÏÌÎÅ ÒÁÂÏÔÁÅÔ × ÌÀÂÏÊ ËÏÄÉÒÏ×ËÅ\n
|
||||
printf(_("This works fine in any charset\n"));
|
||||
return 0;
|
||||
}
|
||||
31
simple_gettext/Makefile
Normal file
31
simple_gettext/Makefile
Normal file
@@ -0,0 +1,31 @@
|
||||
PROGRAM = test
|
||||
LDFLAGS =
|
||||
DEFINES = -D_XOPEN_SOURCE=501 -DGETTEXT_PACKAGE=\"$(PROGRAM)\" -DLOCALEDIR=\".\"
|
||||
SRCS = 1.c
|
||||
CC = gcc
|
||||
CXX = gcc
|
||||
CFLAGS = -Wall -Werror $(DEFINES)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
PO_FILE = $(PROGRAM).po
|
||||
RU_FILE = $(PROGRAM)_ru.po
|
||||
LDIR = "ru/LC_MESSAGES"
|
||||
MO_FILE = $(LDIR)/$(PROGRAM).mo
|
||||
|
||||
all : $(PROGRAM) $(MO_FILE)
|
||||
|
||||
$(PROGRAM) : $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(PROGRAM)
|
||||
|
||||
$(PO_FILE): $(SRCS)
|
||||
xgettext -D. --from-code=koi8-r $(SRCS) -c -k_ -kN_ -o $(PO_FILE)
|
||||
sed -i 's/charset=.*\\n/charset=koi8-r\\n/' $(PO_FILE) && enconv $(PO_FILE)
|
||||
$(RU_FILE): $(PO_FILE)
|
||||
[ -e $(RU_FILE) ] && msgmerge -Uis $(RU_FILE) $(PO_FILE) || cp $(PO_FILE) $(RU_FILE)
|
||||
$(MO_FILE): $(LDIR) $(RU_FILE)
|
||||
msgfmt $(RU_FILE) -o $(MO_FILE)
|
||||
$(LDIR):
|
||||
[ -e $(LDIR) ] || mkdir -p $(LDIR)
|
||||
clean:
|
||||
/bin/rm -f *.o *~
|
||||
depend:
|
||||
$(CXX) -MM $(CXX.SRCS)
|
||||
29
simple_gettext/test_ru.po
Normal file
29
simple_gettext/test_ru.po
Normal file
@@ -0,0 +1,29 @@
|
||||
# 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 <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr "Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-04-24 18:13+0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=koi8-r\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. / ÷ÐÏÌÎÅ ÒÁÂÏÔÁÅÔ × ÌÀÂÏÊ ËÏÄÉÒÏ×ËÅ\n
|
||||
#: 1.c:17
|
||||
#, c-format
|
||||
msgid "This works fine in any charset\n"
|
||||
msgstr "÷ÐÏÌÎÅ ÒÁÂÏÔÁÅÔ × ÌÀÂÏÊ ËÏÄÉÒÏ×ËÅ\n"
|
||||
|
||||
#. / ðÅÒÅ×ÅÄÅÎÏ ÇÅÔÔÅËÓÔÏÍ\n
|
||||
#: 1.c:15
|
||||
#, c-format
|
||||
msgid "Translated by gettext\n"
|
||||
msgstr "ðÅÒÅ×ÅÄÅÎÏ ÇÅÔÔÅËÓÔÏÍ\n"
|
||||
Reference in New Issue
Block a user