Skip to content

Commit cb9dfc6

Browse files
authored
Translate Official Ruby FAQ (ru) (#3928)
* Translation draft FAQ (ru) * One translation clarification on page 6
1 parent 1d5f1cd commit cb9dfc6

12 files changed

Lines changed: 799 additions & 1188 deletions

File tree

ru/documentation/faq/1/index.md

Lines changed: 154 additions & 156 deletions
Large diffs are not rendered by default.

ru/documentation/faq/10/index.md

Lines changed: 43 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,115 @@
11
---
22
layout: page
3-
title: "Official Ruby FAQ"
3+
title: "Официальный FAQ по Ruby"
44
lang: ru
55

66
header: |
77
<div class="multi-page">
8-
<a href="../" title="Content">Content</a>
8+
<a href="../" title="Оглавление">Оглавление</a>
99
<span class="separator"> | </span>
10-
<a href="../1/" title="Part 1">1</a>
10+
<a href="../1/" title="Часть 1">1</a>
1111
<span class="separator"> | </span>
12-
<a href="../2/" title="Part 2">2</a>
12+
<a href="../2/" title="Часть 2">2</a>
1313
<span class="separator"> | </span>
14-
<a href="../3/" title="Part 3">3</a>
14+
<a href="../3/" title="Часть 3">3</a>
1515
<span class="separator"> | </span>
16-
<a href="../4/" title="Part 4">4</a>
16+
<a href="../4/" title="Часть 4">4</a>
1717
<span class="separator"> | </span>
18-
<a href="../5/" title="Part 5">5</a>
18+
<a href="../5/" title="Часть 5">5</a>
1919
<span class="separator"> | </span>
20-
<a href="../6/" title="Part 6">6</a>
20+
<a href="../6/" title="Часть 6">6</a>
2121
<span class="separator"> | </span>
22-
<a href="../7/" title="Part 7">7</a>
22+
<a href="../7/" title="Часть 7">7</a>
2323
<span class="separator"> | </span>
24-
<a href="../8/" title="Part 8">8</a>
24+
<a href="../8/" title="Часть 8">8</a>
2525
<span class="separator"> | </span>
26-
<a href="../9/" title="Part 9">9</a>
26+
<a href="../9/" title="Часть 9">9</a>
2727
<span class="separator"> | </span>
2828
<strong>10</strong>
2929
<span class="separator"> | </span>
30-
<a href="../11/" title="Part 11">11</a>
30+
<a href="../11/" title="Часть 11">11</a>
3131
</div>
32-
<h1>Official Ruby FAQ</h1>
32+
<h1>Официальный FAQ по Ruby</h1>
3333
3434
---
3535

3636
{% include faq-notice.md %}
3737

38-
## Extension library
38+
## Библиотека расширений
3939

40-
### How can I use Ruby interactively?
40+
### Как я могу использовать Ruby интерактивно?
4141
{: #irb}
4242

4343
{% include warnings/faq-out-of-date.html %}
4444

45-
You can try using `irb`. The following is paraphrased from Kentaro Goto
46-
(Gotoken), and originally appeared in [\[ruby-talk:444\]][ruby-talk:444].
47-
48-
1. Get the latest tarball of `irb` from the
49-
[contrib directory](ftp://ftp.netlab.co.jp/pub/lang/ruby/contrib/)
50-
in the Ruby archive.
51-
2. Extract the `irb` directory tree.
52-
3. Add the location of the `irb/` directory to the `$RUBYLIB`
53-
environment variable.
54-
4. Make a symbolic link from `$RUBYLIB/irb/irb.rb` to a file called `irb`
55-
somewhere in your path.
45+
Вы можете попробовать использовать `irb`. Ниже приведено переложение текста Kentaro Goto (Gotoken), который изначально появился в [\[ruby-talk:444\]][ruby-talk:444].
46+
47+
1. Получите последний тарбол `irb` из [директории contrib](ftp://ftp.netlab.co.jp/pub/lang/ruby/contrib/) в архиве Ruby.
48+
2. Распакуйте дерево директорий `irb`.
49+
3. Добавьте путь к директории `irb/` в переменную окружения `$RUBYLIB`.
50+
4. Создайте символическую ссылку из `$RUBYLIB/irb/irb.rb` на файл с именем `irb` где-нибудь в вашем пути PATH.
5651
5. `chmod +x $RUBYLIB/irb/irb.rb`
57-
6. Possibly use `rehash` to tell your login shell about the new command.
58-
7. Type `irb`.
52+
6. Возможно, используйте `rehash`, чтобы сообщить вашей оболочке о новой команде.
53+
7. Введите `irb`.
5954

60-
If the readline extension module works with your interpreter, it makes `irb`
61-
a lot more fun to use.
55+
Если модуль расширения readline работает с вашим интерпретатором, это сделает использование `irb` гораздо приятнее.
6256

63-
There is also a simple program, `eval`, in the `samples/` directory of the
64-
Ruby distribution. It lets you enter expressions and view their values.
65-
You can copy `eval` into the `site_ruby` directory in the Ruby tree, and
66-
then invoke it using:
57+
В директории `samples/` дистрибутива Ruby также есть простая программа `eval`. Она позволяет вводить выражения и просматривать их значения. Вы можете скопировать `eval` в директорию `site_ruby` в дереве Ruby, а затем вызывать её с помощью:
6758

6859
~~~
6960
ruby -r eval -e0
7061
~~~
7162

7263
[ruby-talk:444]: https://blade.ruby-lang.org/ruby-talk/444
7364

74-
### Is there a debugger for Ruby?
65+
### Есть ли отладчик для Ruby?
7566

76-
There is a gdb-like debugger for Ruby.
67+
Для Ruby существует gdb-подобный отладчик.
7768

7869
~~~
7970
ruby -r debug your_program
8071
~~~
8172

82-
### How can I use a library written in C from Ruby?
73+
### Как я могу использовать библиотеку, написанную на C, из Ruby?
8374

84-
Of all the scripting languages, Ruby is probably the easiest to extend.
85-
There are no problems with reference counting and variable types, and very
86-
few interfaces to learn. In fact, C code used to extend Ruby often ends up
87-
looking surprisingly like Ruby code itself.
75+
Из всех скриптовых языков Ruby, вероятно, проще всего расширять. Здесь нет проблем с подсчетом ссылок и типами переменных, и нужно изучить совсем немного интерфейсов. На самом деле код на C, используемый для расширения Ruby, часто в итоге выглядит удивительно похожим на сам код Ruby.
8876

89-
First, read the `doc/extension.rdoc` file in the Ruby source,
90-
or read [extension.rdoc on docs.ruby-lang.org][extension-rdoc].
91-
This is a good document, not only if you are writing an extension library,
92-
but also if you want to understand Ruby more deeply.
77+
Сначала прочитайте файл `doc/extension.rdoc` в исходниках Ruby или прочитайте [extension.rdoc на docs.ruby-lang.org][extension-rdoc]. Это отличный документ не только если вы пишете библиотеку расширения, но и если вы хотите глубже понять Ruby.
9378

94-
Then, the RubyGems site provides a
95-
[guide on creating gems with extensions][rubygems-guide].
96-
It shows how to setup a gem with C extensions that are built at install time.
97-
It has also links to some existing gems that wrap C libraries and
98-
to further reading.
79+
Затем сайт RubyGems предоставляет [руководство по созданию гемов с расширениями][rubygems-guide]. В нем показано, как настроить гем с расширениями на C, которые собираются во время установки. Там также есть ссылки на некоторые существующие гемы, которые оборачивают библиотеки на C, и материалы для дальнейшего чтения.
9980

100-
You might also want to have a look at the source of the interpreter itself,
101-
and at the various supplied extensions in the `ext/` directory
102-
(you can browse the [Ruby repository on GitHub][ruby-github]).
81+
Вы также можете взглянуть на исходный код самого интерпретатора и на различные поставляемые расширения в директории `ext/` (вы можете просмотреть [репозиторий Ruby на GitHub][ruby-github]).
10382

10483
[extension-rdoc]: https://docs.ruby-lang.org/en/master/extension_rdoc.html
10584
[rubygems-guide]: http://guides.rubygems.org/gems-with-extensions/
10685
[ruby-github]: https://github.com/ruby/ruby
10786

108-
### Can I use Tcl/Tk in Ruby?
87+
### Могу ли я использовать Tcl/Tk в Ruby?
10988

11089
{% include warnings/faq-out-of-date.html %}
11190

112-
There are two interfaces to Tcl/Tk included in the standard distribution.
113-
One is under `ext/tcltk/` and loaded with `require "tcltk"`. The syntax is
114-
very close to that Tcl which is passed on to the Tcl interpreter.
115-
Unfortunately, the description for this library is written in Japanese.
91+
В стандартный дистрибутив включены два интерфейса к Tcl/Tk. Один находится в `ext/tcltk/` и загружается с помощью `require "tcltk"`. Синтаксис очень близок к синтаксису Tcl, который передается интерпретатору Tcl. К сожалению, описание этой библиотеки написано на японском языке.
11692

117-
The other is under `ext/tk/` and loaded with `require "tk"`. Its syntax
118-
is closer to the style of the Tk interface provided by the Perl and Python
119-
interfaces.
93+
Другой находится в `ext/tk/` и загружается с помощью `require "tk"`. Его синтаксис ближе к стилю интерфейса Tk, предоставляемого интерфейсами Perl и Python.
12094

121-
### Tk won't work. Why?
95+
### Tk не работает. Почему?
12296

12397
{% include warnings/faq-out-of-date.html %}
12498

125-
Your Tk version may be old, try a newer version.
99+
Ваша версия Tk может быть старой, попробуйте более новую версию.
126100

127-
### Can I use gtk+ or xforms interfaces in Ruby?
101+
### Могу ли я использовать интерфейсы gtk+ или xforms в Ruby?
128102

129103
{% include warnings/faq-out-of-date.html %}
130104

131-
You will find `ruby-gtk-x.xx.tar.gz` and `ruby-forms-x.x.tar.gz`
132-
under `contrib/` on the Ruby ftp sites.
105+
Вы найдете `ruby-gtk-x.xx.tar.gz` и `ruby-forms-x.x.tar.gz` в директории `contrib/` на ftp-сайтах Ruby.
133106

134-
### How can I do date arithmetic?
107+
### Как я могу выполнять арифметические операции с датами?
135108

136109
{% include warnings/faq-out-of-date.html %}
137110

138-
A `Time` object can express only the dates between Jan 1, 1970 and
139-
Jan 19, 2038.
111+
Объект `Time` может выражать только даты между 1 января 1970 года и 19 января 2038 года.
140112

141-
Two standard extension library modules are provided:
142-
`require "date"`, which is simple and uses the English calendar,
143-
and `require "date2"`, which is more general purpose.
113+
Предоставляются два стандартных модуля библиотеки расширений: `require "date"`, который прост и использует английский календарь, и `require "date2"`, который более универсален.
144114

145-
Also see `sample/cal.rb`.
115+
Также смотрите `sample/cal.rb`.

ru/documentation/faq/11/index.md

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,63 @@
11
---
22
layout: page
3-
title: "Official Ruby FAQ"
3+
title: "Официальный FAQ по Ruby"
44
lang: ru
55

66
header: |
77
<div class="multi-page">
8-
<a href="../" title="Content">Content</a>
8+
<a href="../" title="Оглавление">Оглавление</a>
99
<span class="separator"> | </span>
10-
<a href="../1/" title="Part 1">1</a>
10+
<a href="../1/" title="Часть 1">1</a>
1111
<span class="separator"> | </span>
12-
<a href="../2/" title="Part 2">2</a>
12+
<a href="../2/" title="Часть 2">2</a>
1313
<span class="separator"> | </span>
14-
<a href="../3/" title="Part 3">3</a>
14+
<a href="../3/" title="Часть 3">3</a>
1515
<span class="separator"> | </span>
16-
<a href="../4/" title="Part 4">4</a>
16+
<a href="../4/" title="Часть 4">4</a>
1717
<span class="separator"> | </span>
18-
<a href="../5/" title="Part 5">5</a>
18+
<a href="../5/" title="Часть 5">5</a>
1919
<span class="separator"> | </span>
20-
<a href="../6/" title="Part 6">6</a>
20+
<a href="../6/" title="Часть 6">6</a>
2121
<span class="separator"> | </span>
22-
<a href="../7/" title="Part 7">7</a>
22+
<a href="../7/" title="Часть 7">7</a>
2323
<span class="separator"> | </span>
24-
<a href="../8/" title="Part 8">8</a>
24+
<a href="../8/" title="Часть 8">8</a>
2525
<span class="separator"> | </span>
26-
<a href="../9/" title="Part 9">9</a>
26+
<a href="../9/" title="Часть 9">9</a>
2727
<span class="separator"> | </span>
28-
<a href="../10/" title="Part 10">10</a>
28+
<a href="../10/" title="Часть 10">10</a>
2929
<span class="separator"> | </span>
3030
<strong>11</strong>
3131
</div>
32-
<h1>Official Ruby FAQ</h1>
32+
<h1>Официальный FAQ по Ruby</h1>
3333
3434
---
3535

3636
{% include faq-notice.md %}
3737

38-
## Other features
38+
## Другие возможности
3939

40-
### What does `a ? b : c` mean?
40+
### Что означает `a ? b : c`?
4141

42-
This is the so-called “ternary operator” and is the same as saying
43-
`if a then b else c end`.
42+
Это так называемый «тернарный оператор», и он эквивалентен записи `if a then b else c end`.
4443

45-
### How can I count the number of lines in a file?
44+
### Как я могу подсчитать количество строк в файле?
4645

47-
The following code may give the fastest result.
46+
Следующий код может дать самый быстрый результат.
4847

4948
~~~
5049
File.readlines("example").size # => 3
5150
~~~
5251

53-
### What do `MatchData#begin` and `MatchData#end` return?
52+
### Что возвращают `MatchData#begin` и `MatchData#end`?
5453

55-
They act with `$~`, and return the start index and the end index of
56-
the matched data in the original string. See an example in
57-
[tab expansion](../9/#tab-expansion).
54+
Они работают с `$~` и возвращают начальный и конечный индексы совпавших данных в исходной строке. Смотрите пример в разделе [развертывание табуляции](../9/#tab-expansion).
5855

59-
### How can I sum the elements in an array?
56+
### Как я могу просуммировать элементы массива?
6057

6158
{% include warnings/faq-out-of-date.html %}
6259

63-
Rather than solve the specific problem, let's solve the general case.
64-
The first thing we will do is produce a method that will iterate over
65-
an `Enumerable` object and collect a single result. Smalltalk calls that
66-
method inject, so we will too:
60+
Вместо решения конкретной задачи, давайте решим её в общем виде. Первое, что мы сделаем — создадим метод, который будет итерироваться по объекту `Enumerable` и собирать единый результат. В Smalltalk этот метод называется inject, так же назовем его и мы:
6761

6862
~~~
6963
module Enumerable
@@ -77,12 +71,7 @@ module Enumerable
7771
end
7872
~~~
7973

80-
Notice how we have added the method to `Enumerable`. This means that anything
81-
that includes Enumerable can now use `inject`. But how do we use it? It takes
82-
a single argument `n` and a block. For each element in the thing being
83-
enumerated, it calls the block, passing in `n` and the element itself.
84-
The result of the block is assigned back to `n`. So, to define `sum`,
85-
we could write:
74+
Обратите внимание, как мы добавили метод в `Enumerable`. Это означает, что все, что включает в себя Enumerable, теперь может использовать `inject`. Но как нам его использовать? Он принимает один аргумент `n` и блок. Для каждого перечисляемого элемента он вызывает блок, передавая `n` и сам элемент. Результат выполнения блока присваивается обратно в `n`. Таким образом, чтобы определить `sum`, мы могли бы написать:
8675

8776
~~~
8877
module Enumerable
@@ -95,17 +84,13 @@ end
9584
(1..100).sum # => 5050
9685
~~~
9786

98-
### How can I use continuations?
87+
### Как я могу использовать продолжения (continuations)?
9988

10089
{% include warnings/faq-out-of-date.html %}
10190

102-
Ruby's continuations allow you to create an object representing a place in a
103-
Ruby program, and then return to that place at any time (even if it has
104-
apparently gone out of scope). Continuations can be used to implement complex
105-
control structures, but are typically more useful as ways of confusing people.
91+
Продолжения (continuations) в Ruby позволяют создать объект, представляющий определенное место в программе на Ruby, а затем вернуться в это место в любое время (даже если оно, казалось бы, вышло за пределы области видимости). Продолжения можно использовать для реализации сложных структур управления, но обычно они более полезны как способ запутать людей.
10692

107-
In [\[ruby-talk:4482\]][ruby-talk:4482], Jim Weirich posted the following
108-
examples of continuations:
93+
В [\[ruby-talk:4482\]][ruby-talk:4482], Jim Weirich опубликовал следующие примеры использования продолжений:
10994

11095
~~~
11196
# --------------------------------------------------------------------

0 commit comments

Comments
 (0)