hw9: New homework

This commit is contained in:
2020-11-14 18:57:00 +03:00
parent 967055f9a9
commit 585df1d09c
5 changed files with 126 additions and 0 deletions

24
09_I18nL10n/Makefile Normal file
View File

@@ -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

35
09_I18nL10n/main.c Normal file
View File

@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
#include <libintl.h>
#include <locale.h>
#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;
}

33
09_I18nL10n/po/main.pot Normal file
View File

@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

34
09_I18nL10n/po/ru/main.po Normal file
View File

@@ -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 <alex_cmc@likemath.ru>, 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 <alex_cmc@likemath.ru>\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"

Binary file not shown.