diff --git a/09_I18nL10n/Makefile b/09_I18nL10n/Makefile new file mode 100644 index 0000000..00532ff --- /dev/null +++ b/09_I18nL10n/Makefile @@ -0,0 +1,24 @@ +CFLAGS = -Wall -Wextra -std=c99 -g +CPPFLAGS = -I. +LDFLAGS = + +EXEC = main + +all: $(EXEC) po/ru/$(EXEC).mo + +$(EXEC): $(EXEC).c + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LDFLAGS) + +po/ru/$(EXEC).mo: po/ru/$(EXEC).po + msgfmt --output-file=$@ $< + +po/ru/$(EXEC).po: po/$(EXEC).pot + msgmerge --update $@ $< + +po/$(EXEC).pot: $(EXEC).c + xgettext -k_ -j -lC -c -s -o po/main.pot main.c + +clean: + @rm -f $(EXEC) po/ru/*.mo *~ + +.PHONY: clean \ No newline at end of file diff --git a/09_I18nL10n/main.c b/09_I18nL10n/main.c new file mode 100644 index 0000000..7f9179b --- /dev/null +++ b/09_I18nL10n/main.c @@ -0,0 +1,35 @@ +#include +#include + +#include +#include + +#define _(STRING) gettext(STRING) + +int main() { + setlocale (LC_ALL, ""); + bindtextdomain ("al_main", "." + //getenv("PWD") + ); + textdomain ("al_main"); + + printf(_("Choose integer x that 1 <= x <= 100\n")); + int begin = 1; + int end = 100 + 1; + while (end - begin > 1) + { + int cur = (begin + end) / 2; + printf(_("Please choose correct statement:\n")); + printf("1: x < %d\n", cur); + printf("2: x >= %d\n", cur); + int user_input; + scanf("%d", &user_input); + if ( user_input == 1 ){ + end = cur; + } else { + begin = cur; + } + } + printf(_("Your number is: %d\n"), begin); + return 0; +} \ No newline at end of file diff --git a/09_I18nL10n/po/main.pot b/09_I18nL10n/po/main.pot new file mode 100644 index 0000000..f8a0ecb --- /dev/null +++ b/09_I18nL10n/po/main.pot @@ -0,0 +1,33 @@ +# 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: 2020-11-14 18:54+0300\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=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.c:12 main.c:16 +#, c-format +msgid "Choose integer x that 1 <= x <= 100\n" +msgstr "" + +#: main.c:18 main.c:22 +#, c-format +msgid "Please choose correct statement:\n" +msgstr "" + +#: main.c:29 main.c:33 +#, c-format +msgid "Your number is: %d\n" +msgstr "" diff --git a/09_I18nL10n/po/ru/main.po b/09_I18nL10n/po/ru/main.po new file mode 100644 index 0000000..51ff12f --- /dev/null +++ b/09_I18nL10n/po/ru/main.po @@ -0,0 +1,34 @@ +# Russian translations for I18nL10n package. +# Copyright (C) 2020 THE I18nL10n'S COPYRIGHT HOLDER +# This file is distributed under the same license as the I18nL10n package. +# Aleksey Lobanov , 2020. +# +msgid "" +msgstr "" +"Project-Id-Version: I18nL10n 0.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-11-14 18:54+0300\n" +"PO-Revision-Date: 2020-11-14 18:01+0300\n" +"Last-Translator: Aleksey Lobanov \n" +"Language-Team: Russian\n" +"Language: ru_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" + +#: main.c:12 main.c:16 +#, c-format +msgid "Choose integer x that 1 <= x <= 100\n" +msgstr "Выберите целое число x, что 1 <= x <= 100\n" + +#: main.c:18 main.c:22 +#, c-format +msgid "Please choose correct statement:\n" +msgstr "Пожалуйста, выберите верное утверждение:\n" + +#: main.c:29 main.c:33 +#, c-format +msgid "Your number is: %d\n" +msgstr "Ваше число: %d\n" diff --git a/09_I18nL10n/ru/LC_MESSAGES/main.mo b/09_I18nL10n/ru/LC_MESSAGES/main.mo new file mode 100644 index 0000000..ad5f67e Binary files /dev/null and b/09_I18nL10n/ru/LC_MESSAGES/main.mo differ