1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
# encoding: utf-8
=begin
* Name: SiSU
** Description: documents, structuring, processing, publishing, search
*** pot file generation
** Author: Ralph Amissah
<ralph@amissah.com>
<ralph.amissah@gmail.com>
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
All Rights Reserved.
** License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
If you have Internet connection, the latest version of the GPL should be
available at these locations:
<http://www.fsf.org/licensing/licenses/gpl.html>
<http://www.gnu.org/licenses/gpl.html>
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
** SiSU uses:
* Standard SiSU markup syntax,
* Standard SiSU meta-markup syntax, and the
* Standard SiSU object citation numbering and system
** Hompages:
<http://www.jus.uio.no/sisu>
<http://www.sisudoc.org>
** Git
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/develop/src_po4a_share.rb;hb=HEAD>
=end
#module SiSU_SStm_AO_SStm
module SiSU_Languages_Selected
require_relative 'utils_response' # utils_response.rb
def language
def sisu_languages_available
Px[:lng_lst]
end
def source_language_selected_str
@opt.act[:po4a_lang][:src] \
? @opt.act[:po4a_lang][:src]
: 'en'
end
def translation_languages_selected
@opt.act[:po4a_lang][:trn] \
? @opt.act[:po4a_lang][:trn]
: []
end
def translation_languages_available
sisu_languages_available - [source_language_selected_str]
end
def translation_languages_selected_that_are_available
translation_languages_selected & sisu_languages_available
end
def translation_languages_selected_that_are_available_str
translation_languages_selected_that_are_available.join(' ')
end
def translation_languages_selected_str
@opt.act[:po4a_lang][:trn].join(' ')
end
self
end
end
module SiSU_Po4a_Project
class Po4aCfg
include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
include SiSU_Response
include SiSU_Languages_Selected
def initialize(opt,file)
@opt,@file=opt,file
end
def song
if @opt.lng==language.source_language_selected_str
ans=response?('po4a config file')
if ans
po4a_cfg
end
end
end
def po4a_cfg_filename
'po4a.cfg'
end
def dir
def pwd
Dir.pwd
end
def po4a_
'po4a/' # ''
end
def pot
#po4a_ + 'pot'
'pot'
end
def po
#po4a_ + 'po'
'po'
end
self
end
def po4a_cfg_file
File.open("#{Dir.pwd}/#{po4a_cfg_filename}",'w')
end
def po4a_cfg
lng=language.source_language_selected_str
doc_import_list=composite_and_imported_filenames_array(@opt.fno)
po4a_cfg_arr=[]
po4a_cfg_arr \
<< "[po4a_langs] #{language.translation_languages_selected_that_are_available_str}"
po4a_cfg_arr \
<< "[po4a_paths] #{dir.pot}/$master.pot $lang:#{dir.po}/$lang/$master.po"
doc_import_list.each do |file_src|
file_src_fn=
file_src.gsub(/#{language.source_language_selected_str}\//,'')
po4a_cfg_arr \
<< "[type: text] #{lng}/#{file_src} $lang:$lang/#{file_src_fn}"
end
file=@file.write_file.po4a_cfg
po4a_cfg_arr.each do |txt|
puts txt
file << txt << "\n"
end
file.close
end
end
class Po4aProject
include SiSU_Languages_Selected
include SiSU_Response
def initialize(opt,file)
@opt,@file=opt,file
end
def song
make_paths
if FileTest.directory?(@file.output_path.po4a.dir)
Dir.chdir(@file.output_path.po4a.dir)
dirs=Dir['*/']
dirs_language=[]
dirs.each do |x|
dirs_language << x.gsub(/\/$/,'')
end
dirs_translation = \
(language.translation_languages_available & dirs_language)
end
if (language.translation_languages_available & [@opt.lng]).length == 1
puts %{gettext for: #{dirs_translation}
in #{Dir.pwd}}
ans=response?('gettext?')
if ans
gettext_if_any_build_src_trans_po
end
end
ans=response?('build project?')
if ans
build_src_master_to_pot_and_po_and_srcs
end
end
def flags
def debug
'-d -v'
end
def normal
''
end
def quiet
'-q'
end
self
end
def build_src_master_to_pot_and_po_and_srcs
if SiSU_Sys_Call::SystemCall.new.po4a
pwd=Dir.pwd
#cmd='po4a --keep 0 -M UTF-8 --no-backups ' \
#+ '--package-name ' \
#+ 'sisu-manual' + ' ' \
#+ flags.normal + ' ' \
#+ filename.po4a_cfg
cmd='po4a --keep 0 -M UTF-8' \
+ flags.normal + ' ' \
+ @file.base_filename.po4a_cfg
Dir.chdir(@file.output_path.po4a.dir)
system("
cd #{@file.output_path.po4a.dir}
#{cmd}
cd -
"); puts cmd
Dir.chdir(pwd)
end
end
def gettext_if_any_build_src_trans_po
Dir.chdir(@file.output_path.po4a.dir)
dirs=Dir['*/']
dirs_language=[]
dirs.each do |x|
dirs_language << x.gsub(/\/$/,'')
end
dirs_translation = \
(language.translation_languages_available & dirs_language)
files_src=Dir.glob("./#{source_language_selected_str}/*.ss[tmi]")
dirs_translation.each do |lng|
files_src.each do |file|
fn=file.gsub(/\.\/#{source_language_selected_str}\//,'')
system("
po4a-gettextize -f text -M utf-8 \
-m ./#{source_language_selected_str}/#{fn} \
-l ./#{lng}/#{fn} \
-p ./po/#{lng}/#{fn}.po
")
puts fn
end
end
end
def dir_mk(dir)
unless FileTest.directory?(dir)
FileUtils::mkdir_p(dir)
end
end
def make_paths
dir_mk(@file.output_path.pot.dir)
dir_mk(@file.output_path.po.dir)
end
def clean
#rm -f po/*/*.po~
#rm -rf ../build
FileUtils.rm_f Dir.glob("./#{dir.po}/*/*.po~")
end
def distclean
#rm -f po4a.cfg
#rm -rf $(LANGUAGES)
FileUtils::rm_f(filename.po4a_cfg)
FileUtils::rm_r(language.possible_translations,:force => true)
#FileUtils::rm_r(language.translation_languages_selected_that_are_available,:force => true)
end
end
class Po4aDistClean
include SiSU_Languages_Selected
include SiSU_Response
def initialize(opt,file)
@opt,@file=opt,file
end
def song
pwd=Dir.pwd
if FileTest.directory?(@file.output_path.po4a.dir)
Dir.chdir(@file.output_path.po4a.dir)
dirs=Dir['*/']
dirs_language=[]
dirs.each do |x|
dirs_language << x.gsub(/\/$/,'')
end
dirs_translation = \
(language.translation_languages_available & dirs_language)
if dirs_translation.length > 0
puts %{remove language translation directorie(s): #{dirs_translation}
in #{Dir .pwd}}
ans=response?('disclean?')
if ans
FileUtils::rm_f(@file.base_filename.po4a_cfg)
FileUtils::rm_r(dirs_translation,:force => true)
#FileUtils::rm_r(language.translation_languages_available,:force => true)
end
end
Dir.chdir(pwd)
end
end
end
end
#end
__END__
REMOVE
!\|#\|&*\|-\|/\|_\|{\|}\|~\|&#
tables are problematic, difficult to reconstitute instruction, check
metadata, move to top? and work on
footnotes, different types, asterisk, also do you want to have separate
paragraphs, or breaks within one block?
where no ocn appropriately use ~# or -# or indeed 1~name-
comments in document, what to do about them, not sure they are currently
retained in dal, could be quite valuable to keep
Translate Shell
http://www.soimort.org/translate-shell/
translate.google.com
|