dictionaries 0.3.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +354 -0
- data/bin/dictionaries +7 -0
- data/bin/unique_words_in_this_file +7 -0
- data/dictionaries.gemspec +84 -0
- data/doc/README.gen +292 -0
- data/doc/todo/todo.md +8 -0
- data/lib/dictionaries/ask_english_word.rb +141 -0
- data/lib/dictionaries/ask_italian_word.rb +84 -0
- data/lib/dictionaries/base/base.rb +78 -0
- data/lib/dictionaries/class/class.rb +903 -0
- data/lib/dictionaries/commandline/parse_commandline.rb +85 -0
- data/lib/dictionaries/constants/constants.rb +134 -0
- data/lib/dictionaries/gui/tk/README.md +2 -0
- data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
- data/lib/dictionaries/gui/universal_widgets/dictionary/dictionary.rb +516 -0
- data/lib/dictionaries/helper_module/helper_module.rb +60 -0
- data/lib/dictionaries/project/project.rb +36 -0
- data/lib/dictionaries/require_project/require_project.rb +14 -0
- data/lib/dictionaries/sinatra/app.rb +123 -0
- data/lib/dictionaries/sinatra/english_to_german.rb +84 -0
- data/lib/dictionaries/spell_checker/README.md +5 -0
- data/lib/dictionaries/spell_checker/spell_checker.rb +133 -0
- data/lib/dictionaries/statistics/statistics.rb +59 -0
- data/lib/dictionaries/toplevel_methods/e.rb +16 -0
- data/lib/dictionaries/toplevel_methods/english_to_german.rb +31 -0
- data/lib/dictionaries/toplevel_methods/has_key.rb +32 -0
- data/lib/dictionaries/toplevel_methods/is_on_roebe.rb +16 -0
- data/lib/dictionaries/toplevel_methods/main_file.rb +88 -0
- data/lib/dictionaries/toplevel_methods/misc.rb +231 -0
- data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
- data/lib/dictionaries/toplevel_methods/show_help.rb +31 -0
- data/lib/dictionaries/version/version.rb +19 -0
- data/lib/dictionaries/yaml/chinese.yml +25 -0
- data/lib/dictionaries/yaml/danish.yml +4 -0
- data/lib/dictionaries/yaml/deutsche_fremdw/303/266rter.yml +1 -0
- data/lib/dictionaries/yaml/dutch.yml +3 -0
- data/lib/dictionaries/yaml/english.yml +3263 -0
- data/lib/dictionaries/yaml/farsi.yml +8 -0
- data/lib/dictionaries/yaml/finnish.yml +2 -0
- data/lib/dictionaries/yaml/italian.yml +532 -0
- data/lib/dictionaries/yaml/japanese.yml +15 -0
- data/lib/dictionaries/yaml/norwegian.yml +26 -0
- data/lib/dictionaries/yaml/polish.yml +2 -0
- data/lib/dictionaries/yaml/portugese.yml +41 -0
- data/lib/dictionaries/yaml/russian.yml +10 -0
- data/lib/dictionaries/yaml/spanish.yml +147 -0
- data/lib/dictionaries/yaml/swedish.yml +104 -0
- data/lib/dictionaries.rb +1 -0
- data/test/translation_example.html +2758 -0
- metadata +211 -0
@@ -0,0 +1,516 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === Dictionaries::GUI::UniversalWidgets::Dictionary
|
6
|
+
#
|
7
|
+
# Usage example:
|
8
|
+
#
|
9
|
+
# Dictionaries::GUI::UniversalWidgets::Dictionary.new(ARGV)
|
10
|
+
#
|
11
|
+
# =========================================================================== #
|
12
|
+
# require 'dictionaries/gui/universal_widgets/dictionary/dictionary.rb'
|
13
|
+
# Dictionaries::GUI::UniversalWidgets::Dictionary.run
|
14
|
+
# =========================================================================== #
|
15
|
+
require 'dictionaries/base/base.rb'
|
16
|
+
|
17
|
+
module Dictionaries
|
18
|
+
|
19
|
+
module GUI
|
20
|
+
|
21
|
+
module UniversalWidgets
|
22
|
+
|
23
|
+
class Dictionary < ::Dictionaries::Base # === Dictionaries::GUI::UniversalWidgets::Dictionary
|
24
|
+
|
25
|
+
require 'universal_widgets/base_module/base_module.rb'
|
26
|
+
include ::UniversalWidgets::BaseModule
|
27
|
+
|
28
|
+
require 'dictionaries/toplevel_methods/e.rb'
|
29
|
+
require 'dictionaries/toplevel_methods/misc.rb'
|
30
|
+
require 'dictionaries/class/class.rb'
|
31
|
+
|
32
|
+
# ========================================================================= #
|
33
|
+
# === TITLE
|
34
|
+
# ========================================================================= #
|
35
|
+
TITLE = 'Dictionary'
|
36
|
+
|
37
|
+
# ========================================================================= #
|
38
|
+
# === WIDTH
|
39
|
+
# ========================================================================= #
|
40
|
+
WIDTH = '28% or minimum 280px'
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === HEIGHT
|
44
|
+
# ========================================================================= #
|
45
|
+
HEIGHT = '26% or minimum 240px'
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === USE_THIS_FONT
|
49
|
+
# ========================================================================= #
|
50
|
+
USE_THIS_FONT = :dejavu_condensed_22
|
51
|
+
|
52
|
+
# ========================================================================= #
|
53
|
+
# === LARGER_FONT
|
54
|
+
# ========================================================================= #
|
55
|
+
LARGER_FONT = :hack_25
|
56
|
+
|
57
|
+
# ========================================================================= #
|
58
|
+
# === SMALLER_FONT
|
59
|
+
#
|
60
|
+
# This one should be relative to the font used above.
|
61
|
+
# ========================================================================= #
|
62
|
+
SMALLER_FONT = :dejavu_condensed_18
|
63
|
+
|
64
|
+
# ========================================================================= #
|
65
|
+
# === initialize
|
66
|
+
# ========================================================================= #
|
67
|
+
def initialize(
|
68
|
+
commandline_arguments = nil,
|
69
|
+
run_already = true
|
70
|
+
)
|
71
|
+
super(:vertical) if use_gtk3?
|
72
|
+
determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
|
73
|
+
reset
|
74
|
+
set_commandline_arguments(
|
75
|
+
commandline_arguments
|
76
|
+
)
|
77
|
+
on_delete_event_quit_the_application
|
78
|
+
run if run_already
|
79
|
+
end
|
80
|
+
|
81
|
+
# ========================================================================= #
|
82
|
+
# === reset (reset tag)
|
83
|
+
# ========================================================================= #
|
84
|
+
def reset
|
85
|
+
super() if respond_to?(:super)
|
86
|
+
reset_the_shared_module # This can come early.
|
87
|
+
reset_the_base_module
|
88
|
+
reset_the_internal_variables
|
89
|
+
infer_the_namespace
|
90
|
+
# ======================================================================= #
|
91
|
+
# === @configuration
|
92
|
+
# ======================================================================= #
|
93
|
+
@configuration = [true, __dir__, namespace?]
|
94
|
+
# ======================================================================= #
|
95
|
+
# === Set the title, width, height and the font in use.
|
96
|
+
# ======================================================================= #
|
97
|
+
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
|
98
|
+
if use_gtk3?
|
99
|
+
handle_CSS_rules
|
100
|
+
end
|
101
|
+
infer_the_size_automatically
|
102
|
+
# ======================================================================= #
|
103
|
+
# === @dictionaries
|
104
|
+
# ======================================================================= #
|
105
|
+
@dictionaries = Dictionaries.new(:do_not_run_yet)
|
106
|
+
Dictionaries.set_main_file(:default)
|
107
|
+
@dictionaries.load_the_english_file
|
108
|
+
# ======================================================================= #
|
109
|
+
# === @array_style_these_buttons
|
110
|
+
# ======================================================================= #
|
111
|
+
@array_style_these_buttons = []
|
112
|
+
end
|
113
|
+
|
114
|
+
# ========================================================================= #
|
115
|
+
# === smaller_font?
|
116
|
+
# ========================================================================= #
|
117
|
+
def smaller_font?
|
118
|
+
SMALLER_FONT
|
119
|
+
end
|
120
|
+
|
121
|
+
# ========================================================================= #
|
122
|
+
# === handle_CSS_rules (CSS tag)
|
123
|
+
# ========================================================================= #
|
124
|
+
def handle_CSS_rules
|
125
|
+
use_gtk_paradise_project_css_file
|
126
|
+
append_project_css_file
|
127
|
+
more_CSS_then_apply_it '
|
128
|
+
|
129
|
+
'
|
130
|
+
end
|
131
|
+
|
132
|
+
# ========================================================================= #
|
133
|
+
# === reset_the_shared_module
|
134
|
+
# ========================================================================= #
|
135
|
+
def reset_the_shared_module
|
136
|
+
end
|
137
|
+
|
138
|
+
# ========================================================================= #
|
139
|
+
# === e
|
140
|
+
# ========================================================================= #
|
141
|
+
def e(i = '')
|
142
|
+
::Dictionaries.e(i)
|
143
|
+
end
|
144
|
+
|
145
|
+
# ========================================================================= #
|
146
|
+
# === update_the_statistics_frame (update tag)
|
147
|
+
# ========================================================================= #
|
148
|
+
def update_the_statistics_frame(
|
149
|
+
i = return_currently_selected_file
|
150
|
+
)
|
151
|
+
@label_currently_selected_file.set_text(i)
|
152
|
+
@label_currently_selected_file.do_markify
|
153
|
+
end
|
154
|
+
|
155
|
+
# ========================================================================= #
|
156
|
+
# === add_ask_the_question_button
|
157
|
+
# ========================================================================= #
|
158
|
+
def add_ask_the_question_button
|
159
|
+
button = bold_button('_Translate into german')
|
160
|
+
button.clear_background
|
161
|
+
button.bblack2
|
162
|
+
button.hint =
|
163
|
+
'Click this button in order to <b>translate the english '\
|
164
|
+
'word into the german equivalent word</b>.'
|
165
|
+
button.on_clicked {
|
166
|
+
button_pressed_so_try_to_convert_the_input
|
167
|
+
}
|
168
|
+
@array_style_these_buttons << button
|
169
|
+
hbox1 = create_hbox
|
170
|
+
hbox1.minimal(button, 1)
|
171
|
+
hbox1.halign_center
|
172
|
+
return hbox1
|
173
|
+
end
|
174
|
+
|
175
|
+
# ========================================================================= #
|
176
|
+
# === padding?
|
177
|
+
# ========================================================================= #
|
178
|
+
def padding?
|
179
|
+
2
|
180
|
+
end
|
181
|
+
|
182
|
+
# ========================================================================= #
|
183
|
+
# === border_size?
|
184
|
+
# ========================================================================= #
|
185
|
+
def border_size?
|
186
|
+
2
|
187
|
+
end
|
188
|
+
|
189
|
+
# ========================================================================= #
|
190
|
+
# === create_the_header_bar
|
191
|
+
# ========================================================================= #
|
192
|
+
def create_the_header_bar
|
193
|
+
# ======================================================================= #
|
194
|
+
# === @header_bar
|
195
|
+
# ======================================================================= #
|
196
|
+
@header_bar = default_header_bar
|
197
|
+
@header_bar.title = 'Dictionary'
|
198
|
+
end
|
199
|
+
|
200
|
+
# ========================================================================= #
|
201
|
+
# === create_answer_field
|
202
|
+
#
|
203
|
+
# This method builds up the "answer-widget".
|
204
|
+
# ========================================================================= #
|
205
|
+
def create_answer_field
|
206
|
+
# ======================================================================= #
|
207
|
+
# === @answer_field
|
208
|
+
# ======================================================================= #
|
209
|
+
@answer_field = create_input_field
|
210
|
+
@answer_field.center
|
211
|
+
@answer_field.hint = 'The translated string may appear here.'
|
212
|
+
@answer_field.very_light_yellow_background
|
213
|
+
end
|
214
|
+
|
215
|
+
# ========================================================================= #
|
216
|
+
# === button_pressed_so_try_to_convert_the_input (click tag)
|
217
|
+
#
|
218
|
+
# This action is called when the user clicks on the button.
|
219
|
+
# ========================================================================= #
|
220
|
+
def button_pressed_so_try_to_convert_the_input
|
221
|
+
user_input = @input_field.return_input
|
222
|
+
unless user_input.empty? # We check whether the user did input something.
|
223
|
+
translated_word = @dictionaries.translate(user_input)
|
224
|
+
e "#{::Colours.sfancy(user_input)} → "\
|
225
|
+
"#{::Colours.simp(translated_word)}"
|
226
|
+
@answer_field.set_text(translated_word)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# ========================================================================= #
|
231
|
+
# === add_the_widget_for_remote_query_of_the_dictionary_at_leo (bottom tag)
|
232
|
+
#
|
233
|
+
# This is the bottom widget.
|
234
|
+
# ========================================================================= #
|
235
|
+
def add_the_widget_for_remote_query_of_the_dictionary_at_leo
|
236
|
+
bottom_vbox = create_vbox
|
237
|
+
bold_label = bold_label(
|
238
|
+
'Query from a remote website instead (more entries available)'
|
239
|
+
)
|
240
|
+
bottom_vbox.minimal(bold_label, 15)
|
241
|
+
# This is the user-input entry at the bottom.
|
242
|
+
@entry_for_the_remote_query = create_entry
|
243
|
+
@entry_for_the_remote_query.center
|
244
|
+
@entry_for_the_remote_query.on_key_press_event { |widget, event|
|
245
|
+
case Gdk::Keyval.to_name(event.keyval)
|
246
|
+
when 'Return', 'KP_Enter'
|
247
|
+
do_perform_a_remote_query_to_the_leo_dictionary
|
248
|
+
end
|
249
|
+
}
|
250
|
+
bottom_vbox.minimal(@entry_for_the_remote_query)
|
251
|
+
# ======================================================================= #
|
252
|
+
# === button_for_the_remote_query
|
253
|
+
# ======================================================================= #
|
254
|
+
button_for_the_remote_query = button(
|
255
|
+
'_Query from a remote dictionary'
|
256
|
+
)
|
257
|
+
button_for_the_remote_query.clear_background
|
258
|
+
button_for_the_remote_query.bblack2
|
259
|
+
button_for_the_remote_query.make_bold
|
260
|
+
button_for_the_remote_query.hint =
|
261
|
+
'This will <b>query the remote dictionary</b> at leo instead. '\
|
262
|
+
'The <b>advantage</b> here is that the dataset at leo will '\
|
263
|
+
'contain many more entries than does the knowledgebase '\
|
264
|
+
'distributed with the <b>dictionaries gem</b>.'
|
265
|
+
button_for_the_remote_query.on_clicked {
|
266
|
+
do_perform_a_remote_query_to_the_leo_dictionary
|
267
|
+
}
|
268
|
+
bottom_vbox.minimal(
|
269
|
+
@entry_at_the_bottom_showing_the_result_from_online_leo, 2
|
270
|
+
)
|
271
|
+
@array_style_these_buttons << button_for_the_remote_query
|
272
|
+
small_hbox = create_hbox
|
273
|
+
small_hbox.minimal(button_for_the_remote_query, 1)
|
274
|
+
small_hbox.halign_center
|
275
|
+
bottom_vbox.minimal(
|
276
|
+
small_hbox, 2
|
277
|
+
)
|
278
|
+
return bottom_vbox
|
279
|
+
end
|
280
|
+
|
281
|
+
# ========================================================================= #
|
282
|
+
# === return_input_field_on_top
|
283
|
+
#
|
284
|
+
# This is the main widget for user input. The user types in some
|
285
|
+
# words, and then hits the main button on the bottom, in order
|
286
|
+
# to translate the (english) word to german.
|
287
|
+
# ========================================================================= #
|
288
|
+
def return_input_field_on_top
|
289
|
+
text_for_the_label = 'Input an english word in the field below'
|
290
|
+
text = label(text_for_the_label)
|
291
|
+
text.slateblue
|
292
|
+
text.set_markup(
|
293
|
+
'<span size="x-large" weight="bold">'+text_for_the_label+'</span>',
|
294
|
+
use_underline: true
|
295
|
+
)
|
296
|
+
# ======================================================================= #
|
297
|
+
# Add the "input field" next for the english word that is to
|
298
|
+
# be translated.
|
299
|
+
# ======================================================================= #
|
300
|
+
@input_field = create_input_field
|
301
|
+
@input_field.hint = 'Input the word that should be translated '\
|
302
|
+
'here. Then, press the "enter" key or the button '\
|
303
|
+
'"Translate into german" below.'
|
304
|
+
@input_field.very_light_yellow_background
|
305
|
+
completion = create_entry_completion
|
306
|
+
@input_field.completion = completion # Assign the completion.
|
307
|
+
completion_model = ::Gtk::ListStore.new(String)
|
308
|
+
@dictionaries.array.each { |word|
|
309
|
+
iter = completion_model.append
|
310
|
+
iter[0] = word
|
311
|
+
}
|
312
|
+
completion.model = completion_model
|
313
|
+
# ======================================================================= #
|
314
|
+
# Use model column 0 as the text column
|
315
|
+
# ======================================================================= #
|
316
|
+
completion.text_column = 0
|
317
|
+
@input_field.center
|
318
|
+
@input_field.on_key_press_event { |widget, event|
|
319
|
+
case Gdk::Keyval.to_name(event.keyval)
|
320
|
+
when 'Return', 'KP_Enter'
|
321
|
+
button_pressed_so_try_to_convert_the_input
|
322
|
+
end
|
323
|
+
}
|
324
|
+
hbox_holding_label_and_input_field = create_vbox(
|
325
|
+
text, @input_field
|
326
|
+
)
|
327
|
+
return hbox_holding_label_and_input_field
|
328
|
+
end
|
329
|
+
|
330
|
+
# ========================================================================= #
|
331
|
+
# === connect_the_skeleton (connect tag)
|
332
|
+
# ========================================================================= #
|
333
|
+
def connect_the_skeleton
|
334
|
+
abort_on_exception
|
335
|
+
|
336
|
+
outer_box = create_vbox
|
337
|
+
|
338
|
+
outer_box.add(add_the_header_bar)
|
339
|
+
outer_box.add(return_input_field_on_top)
|
340
|
+
outer_box.add(add_the_answer_field)
|
341
|
+
outer_box.add(add_ask_the_question_button)
|
342
|
+
outer_box.add(add_the_widget_for_remote_query_of_the_dictionary_at_leo)
|
343
|
+
outer_box.add(add_the_statistics_frame)
|
344
|
+
|
345
|
+
window = create_window_or_runner(nil, width?, height?, title?)
|
346
|
+
window << outer_box
|
347
|
+
|
348
|
+
properly_prepare_this_window(window,
|
349
|
+
{
|
350
|
+
title: title?,
|
351
|
+
font: font?,
|
352
|
+
width: width?,
|
353
|
+
height: height?,
|
354
|
+
padding: padding?,
|
355
|
+
border_size: border_size?
|
356
|
+
}
|
357
|
+
)
|
358
|
+
window.show_all
|
359
|
+
window.top_left
|
360
|
+
do_all_startup_related_actions
|
361
|
+
run_main
|
362
|
+
end
|
363
|
+
|
364
|
+
# ========================================================================= #
|
365
|
+
# === do_all_startup_related_actions
|
366
|
+
# ========================================================================= #
|
367
|
+
def do_all_startup_related_actions
|
368
|
+
update_the_statistics_frame
|
369
|
+
do_style_the_important_buttons
|
370
|
+
end
|
371
|
+
|
372
|
+
# ========================================================================= #
|
373
|
+
# === do_style_the_important_buttons
|
374
|
+
# ========================================================================= #
|
375
|
+
def do_style_the_important_buttons
|
376
|
+
@array_style_these_buttons.each {|this_button|
|
377
|
+
this_button.modify_background(:normal, :khaki) # ← default colour
|
378
|
+
this_button.modify_background(:prelight, :paleturquoise) # ← mouse-on-over events
|
379
|
+
this_button.modify_background(:active, :slategray) # ← colour on mouse-press-event
|
380
|
+
}
|
381
|
+
end
|
382
|
+
|
383
|
+
# ========================================================================= #
|
384
|
+
# === do_perform_a_remote_query_to_the_leo_dictionary
|
385
|
+
# ========================================================================= #
|
386
|
+
def do_perform_a_remote_query_to_the_leo_dictionary(
|
387
|
+
i = @entry_for_the_remote_query.text.to_s
|
388
|
+
)
|
389
|
+
if i and !i.empty?
|
390
|
+
array = ::Dictionaries.return_array_of_translated_words_from_online_leo(i)
|
391
|
+
result = array.first
|
392
|
+
@entry_at_the_bottom_showing_the_result_from_online_leo.set_text(result)
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
# ========================================================================= #
|
397
|
+
# === return_currently_selected_file
|
398
|
+
# ========================================================================= #
|
399
|
+
def return_currently_selected_file
|
400
|
+
'Currently selected file: <b>'+
|
401
|
+
File.basename(
|
402
|
+
@dictionaries.currently_selected_file?.to_s
|
403
|
+
)+'</b>'
|
404
|
+
end
|
405
|
+
|
406
|
+
# ========================================================================= #
|
407
|
+
# === create_the_entries (entries tag, entry tag)
|
408
|
+
# ========================================================================= #
|
409
|
+
def create_the_entries
|
410
|
+
# ======================================================================= #
|
411
|
+
# === @entry_at_the_bottom_showing_the_result_from_online_leo
|
412
|
+
# ======================================================================= #
|
413
|
+
@entry_at_the_bottom_showing_the_result_from_online_leo = create_entry
|
414
|
+
@entry_at_the_bottom_showing_the_result_from_online_leo.center
|
415
|
+
end
|
416
|
+
|
417
|
+
# ========================================================================= #
|
418
|
+
# === add_the_header_bar
|
419
|
+
# ========================================================================= #
|
420
|
+
def add_the_header_bar
|
421
|
+
return @header_bar
|
422
|
+
end
|
423
|
+
|
424
|
+
# ========================================================================= #
|
425
|
+
# === add_the_statistics_frame
|
426
|
+
# ========================================================================= #
|
427
|
+
def add_the_statistics_frame
|
428
|
+
return @frame_statistics
|
429
|
+
end
|
430
|
+
|
431
|
+
# ========================================================================= #
|
432
|
+
# === add_the_answer_field
|
433
|
+
# ========================================================================= #
|
434
|
+
def add_the_answer_field
|
435
|
+
return @answer_field # ← Translation appears here.
|
436
|
+
end
|
437
|
+
|
438
|
+
# ========================================================================= #
|
439
|
+
# === create_the_skeleton (create tag, skeleton tag)
|
440
|
+
# ========================================================================= #
|
441
|
+
def create_the_skeleton
|
442
|
+
create_the_entries
|
443
|
+
create_the_header_bar
|
444
|
+
create_answer_field
|
445
|
+
create_the_statistics_frame
|
446
|
+
end
|
447
|
+
|
448
|
+
# ========================================================================= #
|
449
|
+
# === create_the_statistics_frame
|
450
|
+
# ========================================================================= #
|
451
|
+
def create_the_statistics_frame
|
452
|
+
# ======================================================================= #
|
453
|
+
# === @frame_statistics
|
454
|
+
# ======================================================================= #
|
455
|
+
@frame_statistics = create_frame
|
456
|
+
@frame_statistics.set_label((' Statistics '))
|
457
|
+
@frame_statistics.make_bold
|
458
|
+
@frame_statistics.use_this_font = smaller_font?
|
459
|
+
vbox = create_vbox
|
460
|
+
@label_currently_selected_file = label(return_currently_selected_file)
|
461
|
+
vbox.minimal(
|
462
|
+
@label_currently_selected_file, 0
|
463
|
+
)
|
464
|
+
@frame_statistics.add(vbox)
|
465
|
+
end
|
466
|
+
|
467
|
+
# ========================================================================= #
|
468
|
+
# === run (run tag)
|
469
|
+
# ========================================================================= #
|
470
|
+
def run
|
471
|
+
run_super
|
472
|
+
end
|
473
|
+
|
474
|
+
# ========================================================================= #
|
475
|
+
# === Dictionaries::GUI::Gtk::Dictionary.run
|
476
|
+
# ========================================================================= #
|
477
|
+
def self.run(
|
478
|
+
i = ARGV
|
479
|
+
)
|
480
|
+
require 'gtk_paradise/run'
|
481
|
+
_ = ::Dictionaries::GUI::Gtk::Dictionary.new(i)
|
482
|
+
r = ::Gtk.run
|
483
|
+
_.set_parent_widget(r) # Must come before we enable the key-combinations.
|
484
|
+
r << _
|
485
|
+
r.automatic_size_then_automatic_title
|
486
|
+
r.enable_quick_exit
|
487
|
+
r.set_background :white
|
488
|
+
r.border_width = 12
|
489
|
+
r.top_left_then_run
|
490
|
+
end; self.instance_eval { alias start_gui_application run } # === Dictionaries::GUI::Gtk::Dictionary.start_gui_application
|
491
|
+
|
492
|
+
# ========================================================================= #
|
493
|
+
# === Dictionaries::GUI::UniversalWidgets::Dictionary[]
|
494
|
+
# ========================================================================= #
|
495
|
+
def self.[](i = ARGV)
|
496
|
+
new(i)
|
497
|
+
end
|
498
|
+
|
499
|
+
end; end; end
|
500
|
+
|
501
|
+
# =========================================================================== #
|
502
|
+
# === Dictionaries.gtk_widget
|
503
|
+
#
|
504
|
+
# This toplevel-method can be used to return the gtk-widget, which
|
505
|
+
# can then be embedded by other ruby-gtk applications, in particular
|
506
|
+
# admin_panel.rb of the gtk_paradise project.
|
507
|
+
# =========================================================================== #
|
508
|
+
def self.gtk_widget
|
509
|
+
Dictionaries::GUI::Gtk::Dictionary.new
|
510
|
+
end
|
511
|
+
|
512
|
+
end
|
513
|
+
|
514
|
+
if __FILE__ == $PROGRAM_NAME
|
515
|
+
Dictionaries::GUI::UniversalWidgets::Dictionary.new(ARGV)
|
516
|
+
end # guishell
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'dictionaries/helper_module/helper_module.rb'
|
6
|
+
# include Dictionaries::HelperModule
|
7
|
+
# =========================================================================== #
|
8
|
+
module Dictionaries
|
9
|
+
|
10
|
+
module HelperModule
|
11
|
+
|
12
|
+
require 'html_tags'
|
13
|
+
include HtmlTags
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === Dictionaries::HelperModule.return_search_button
|
17
|
+
# ========================================================================= #
|
18
|
+
def self.return_search_button
|
19
|
+
'<input type="submit" name="user_input_submit" value="Search" '\
|
20
|
+
'style="font-weight: bold; font-size: larger; '\
|
21
|
+
'border: 2px dotted slateblue; margin: 4px; margin-left: 2em">'
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === Dictionaries::HelperModule.html_header_default_title_and_start_of_the_body_tag
|
26
|
+
# ========================================================================= #
|
27
|
+
def self.html_header_default_title_and_start_of_the_body_tag
|
28
|
+
"<html>\n"\
|
29
|
+
"<title>Dictionaries</title>\n"\
|
30
|
+
"<body>\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
# ========================================================================= #
|
34
|
+
# === Dictionaries::HelperModule.return_english_to_german_form
|
35
|
+
# ========================================================================= #
|
36
|
+
def self.return_english_to_german_form
|
37
|
+
route_to_this_action = '/english_to_german/'
|
38
|
+
html_header_default_title_and_start_of_the_body_tag+
|
39
|
+
HtmlTags.h5('Input an english word to see the translation.')+
|
40
|
+
HtmlTags.div(css_style: 'padding: 0.1em') {
|
41
|
+
HtmlTags.p(
|
42
|
+
'<b>Enter the word here:</b>',
|
43
|
+
css_style: 'padding: 0.15em'
|
44
|
+
)+
|
45
|
+
HtmlTags.form(action: route_to_this_action,
|
46
|
+
id: 'english_to_german',
|
47
|
+
css_style: 'margin-left:1em; margin-top:2px') {
|
48
|
+
'<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px"><br>'+
|
49
|
+
return_search_button
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
end; end
|
55
|
+
|
56
|
+
if __FILE__ == $PROGRAM_NAME
|
57
|
+
alias e puts
|
58
|
+
include Dictionaries::HelperModule
|
59
|
+
e Dictionaries::HelperModule.return_english_to_german_form
|
60
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# This file will point to the yaml directory of the Dictionaries project.
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'dictionaries/project/project.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
module Dictionaries
|
10
|
+
|
11
|
+
# ========================================================================= #
|
12
|
+
# === Dictionaries::PROJECT_BASE_DIRECTORY
|
13
|
+
# ========================================================================= #
|
14
|
+
PROJECT_BASE_DIRECTORY =
|
15
|
+
File.absolute_path("#{__dir__}/..")+'/'
|
16
|
+
|
17
|
+
# ========================================================================= #
|
18
|
+
# === Dictionaries.project_base_dir?
|
19
|
+
# ========================================================================= #
|
20
|
+
def self.project_base_dir?
|
21
|
+
PROJECT_BASE_DIRECTORY
|
22
|
+
end
|
23
|
+
|
24
|
+
# ========================================================================= #
|
25
|
+
# === PROJECT_YAML_DIRECTORY
|
26
|
+
# ========================================================================= #
|
27
|
+
PROJECT_YAML_DIRECTORY = "#{PROJECT_BASE_DIRECTORY}yaml/"
|
28
|
+
|
29
|
+
# ========================================================================= #
|
30
|
+
# === Dictionaries.project_yaml_dir?
|
31
|
+
# ========================================================================= #
|
32
|
+
def self.project_yaml_dir?
|
33
|
+
PROJECT_YAML_DIRECTORY
|
34
|
+
end; self.instance_eval { alias dictionary_directory? project_yaml_dir? } # === Dictionaries.dictionary_directory?
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'dictionaries/require_project/require_project.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'dictionaries/project/project.rb'
|
8
|
+
require 'dictionaries/ask_italian_word.rb'
|
9
|
+
require 'dictionaries/toplevel_methods/has_key.rb' # This file requires the files above.
|
10
|
+
require 'dictionaries/toplevel_methods/module_methods.rb'
|
11
|
+
require 'dictionaries/toplevel_methods/english_to_german.rb'
|
12
|
+
require 'dictionaries/toplevel_methods/is_on_roebe.rb'
|
13
|
+
require 'dictionaries/sinatra/app.rb'
|
14
|
+
require 'dictionaries/statistics/statistics.rb'
|