From 585df1d09c79fd5bd0d7209af127c2e036b70b5a Mon Sep 17 00:00:00 2001 From: Aleksey Lobanov Date: Sat, 14 Nov 2020 18:57:00 +0300 Subject: [PATCH] hw9: New homework --- 09_I18nL10n/Makefile | 24 ++++++++++++++++++++ 09_I18nL10n/main.c | 35 +++++++++++++++++++++++++++++ 09_I18nL10n/po/main.pot | 33 +++++++++++++++++++++++++++ 09_I18nL10n/po/ru/main.po | 34 ++++++++++++++++++++++++++++ 09_I18nL10n/ru/LC_MESSAGES/main.mo | Bin 0 -> 769 bytes 5 files changed, 126 insertions(+) create mode 100644 09_I18nL10n/Makefile create mode 100644 09_I18nL10n/main.c create mode 100644 09_I18nL10n/po/main.pot create mode 100644 09_I18nL10n/po/ru/main.po create mode 100644 09_I18nL10n/ru/LC_MESSAGES/main.mo 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 0000000000000000000000000000000000000000..ad5f67ec124d234061ca8945be7dc90f392889f6 GIT binary patch literal 769 zcmZ8fL2DC16kfGn_NW&R9$vu~i=8@?_7FDNR;?`*QVby#M4?QQG1+!^CeF;36nd~0 zR1iEA^y0z4P>U&%(*6Puvwy&|Kf||KwAg`f-h1=D@4d%ke%+Y(+(uLp*AXue z`ROC>AYLIR5uXt^5hKLME1vfg?GoboRnM!T{et!u+TUm~J+6BVEr!Ke?kQyiMAC|` z&@ceo;}#fHL-g@tl=@yh792_Kg4wskt;Uw@L@_Fc#ZJ>_SboxKuk(<*^uSwv+aQINBBox4k)? zE}~9$Q{EM%DR>e*qeyL}wWih;e~k9j03 zxEZdEu;E5?m6R`d`D`zRCM&Y7I+5%KP;N!mug9t8F7g)o>wq#|m0y6!!KC33BKRY8YxtGZo)+huH`B%?-2H zZj`-oL&)B`p*wZwx%&>^_VWM+vlwCi{PHJoUy*v^j@)T>;C^KL$T^w?cYLX;J07<< fE9xE~t9UqZ-?8198@VC=7kB86viJXWE