aboutsummaryrefslogtreecommitdiffstats
path: root/check_for_translation_work.sh
blob: 13c1e8bb6153b08ef1e866c92d87e2e2e5a246a1 (plain)
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
#!/bin/bash
# turn tracing on with /bin/bash -x
#
# Check for translation work by checking out / updating from GIT, SVN and
# displaying the project name when your language.po has fuzzy strings or
# empty string messages. Also useful for translation of web pages.
#
# Filip Komar, 2012, 2013, 2014
# Remco Rijnders, 2012
# $Id: check_for_translation_work.sh 2014-02-03 16:58:00 UTC filip $
#
# Please see git for a list of changes to this script.
#
# More information about this script is in README file.

if [ -f ~/.mageia-i18n-config ]; then
    source ~/.mageia-i18n-config
else
    cat > ~/.mageia-i18n-config << "EOF"
# Please change the below values to match your needs:
language_code=xx

# Where to put the files from repositories and your working directory,
# please make sure those directories exist before running the script!!!
# Don't use tilde character (~) for directory expansion as it doesn't work!
svn_directory="/home/user/Mageia/i18n/svn"
git_directory="/home/user/Mageia/i18n/git" # added after git transition
working_translations_directory="/home/user/Mageia/i18n/translations/$language_code"

# choose svn method:
# 1. anonymous (no commit access)
svn_method="svn://"

# 2. public ssh key svn access. Remember to upload it to identity!
# Otherwise it will prompt you for password everytime for every resource.
#svn_method="svn+ssh://"

# The following lines can be changed if you desire, but this is
# not needed to properly use this script.

# set checking syntax of po files with 1
check_po_syntax=1

# set copying of po files with 1
copying_po=1

# uncomment next line to exclude copying of desktop files
#copying_desktop_files=no

# uncomment next line to exclude work on software desktop files resources
#work_on_docs_and_tools=no

# uncomment next line to exclude work on software desktop files resources
#work_on_desktop_files=no

# uncomment next line to exclude work on unofficial software resources
#work_on_unofficial=no

# uncomment next line to exclude work on html software resources
#work_on_html_software_files=no

# uncomment next line to exclude copying of html software resources
#copying_html_software_files=no

# uncomment next line to exclude all work on web pages translation
#work_on_web_pages_translation=no

# set copying of web page files with 1
copying_wp=1

# uncomment next line to exclude work on software resources for mageia 3
#work_on_mga3=no

# ADVANCED SETTINGS
# set checking syntax of pot files with 1
check_pot_syntax=0

# set copying options (-i: interactive, -v: verbose, -u: update, -r: recursive)
copy_options="-ivur"

# choose log filename
log_filename="updated_translations_in_git_$language_code"
log_directory="$git_directory"
logfile="$git_directory/$log_filename"

# switch of logging by uncommenting the following line
#logfile="/dev/null"

# checkout whole website www.mageia.org and mognase navigation
checkout_whole_website=0

# set searching for new *.pot files in svn with 1
searching_for_new_pot_files_in_svn=0

# whether to look for new versions of the script and list of translatable resources
check_updates=1

# red color for differences from last time (green 32, blue 34)
color_for_differences=31

# uncomment next line to show log with differences from last run
#stop_showing_differences_from_last_run=yes

# uncomment next line to prevent creation of working copy of po file
#create_a_working_copy_of_po_file=no

EOF

    echo -e "\E[31m"
    echo "This script has not been configured yet for you. A template"
    echo "configuration file named .mageia-i18n-config has been made in your"
    echo "home directory. Please edit it according to your needs and remember"
    echo "to create apropriate directories before running this script again."
    echo
    echo "For more information about this script please read README file."
    echo -e "\E[m"
    exit 1
fi
if [ -z "$git_directory" ]; then
    echo -e "\E[31m"
    echo "Please first set git_directory variable in your configuration file"
    echo "named .mageia-i18n-config in your home directory before running"
    echo "this script again."
    echo -e "\E[m"
    exit 2
fi
if [ ! -f ~/.gitconfig ]; then
    cat > ~/.gitconfig << "EOF"
[user]
     name = Your Name
     email = your_email@example.com
[color]
     ui = true
[url "git://git.mageia.org/"]
     insteadof = mga:
[url "ssh://git@git.mageia.org/"]
     pushInsteadof = mga:
[alias]
     ci = commit
     up = pull --rebase
[push]
     default = matching
EOF
    echo "It seems that you didn't configured git yet" > "$log_directory"/list_of_resources_for_translation_$language_code.txt
    echo "Please edit ~/.gitconfig See: https://wiki.mageia.org/en/Git_usage_for_l10n_and_doc" > "$log_directory"/list_of_resources_for_translation_$language_code.txt
    echo -e "\E[31m"
    echo "It seems that you didn't configured git yet. A template configuration" | tee -a "$logfile"_this_run.log
    echo "file named ~/.gitconfig has been made in your home directory." | tee -a "$logfile"_this_run.log
    echo "Please edit it according to your needs. There is a guide in our wiki:" | tee -a "$logfile"_this_run.log
    echo "https://wiki.mageia.org/en/Git_usage_for_l10n_and_doc" | tee -a "$logfile"_this_run.log
    echo ""
    read -p "Please read information above and then press any key to continue... " -n1 -s
    echo -e "\E[m"
fi

# save pwd to saved_dir
saved_dir=$(pwd)

if [ -f "$logfile"_this_run.log ]; then
    mv "$logfile"_this_run.log "$logfile"_previous_run.log
fi
separator="-----------------------------------------------------"

# Check if directories exist and create them if not
if [ -z "$work_on_web_pages_translation" ]; then
    if [ ! -d "$svn_directory" ]; then
        mkdir -vp "$svn_directory/" # | tee -a "$logfile"_this_run.log
    fi
fi
if [ ! -d "$git_directory" ]; then
    mkdir -vp "$git_directory/" # | tee -a "$logfile"_this_run.log
fi
if [ ! -d "$working_translations_directory" ]; then
    mkdir -vp "$working_translations_directory/" | tee -a "$logfile"_this_run.log
fi

echo "" | tee -a "$logfile"_this_run.log
echo "script started at  :" `date` | tee -a "$logfile"_this_run.log
echo "version of script  :" `head -20 "${BASH_SOURCE[0]}" | grep check_for_translation_work.sh | cut -c38-61` | tee -a "$logfile"_this_run.log

# Check if a newer version of this script is available. If yes, show the changes.
if [ $check_updates -eq 1 ]; then
    if [ -f "$git_directory"/translation_projects.dat ]; then
        cp "$git_directory"/translation_projects.dat "$git_directory"/translation_projects.dat_previous
    fi
    wget -Nq http://gitweb.mageia.org/software/i18n/tools/plain/translation_projects.dat -P "$git_directory"/
    if [ -f "$git_directory"/check_for_translation_work.sh ]; then
        cp "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous
    fi
    wget -Nq http://gitweb.mageia.org/software/i18n/tools/plain/check_for_translation_work.sh -P "$git_directory"/
    if [ -f "$git_directory"/check_for_translation_work.sh_previous ]; then
        diff -q "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous > /dev/null
        if [ $? -eq 1 ]; then # there are differences
            echo -e "\E[33m"
            echo $separator | tee -a "$logfile"_this_run.log
            echo You are running an old revision of this script. You may consider updating. Changes are: | tee -a "$logfile"_this_run.log
            diff "$git_directory"/check_for_translation_work.sh "$git_directory"/check_for_translation_work.sh_previous | tee -a "$logfile".log
            echo -e "\E[m"
            echo "" | tee -a "$logfile"_this_run.log
        fi
    fi
    echo ""
fi

declare -A git_addresses
declare -A translate_projects_po
declare -A translate_projects_desktop
declare -A translate_projects_help
declare -A web_pages
if [ -f "$git_directory"/translation_projects.dat ]; then
    source "$git_directory/translation_projects.dat"
    echo "version of database:" `head -1 "$git_directory/translation_projects.dat"| cut -c53-76` | tee -a "$logfile"_this_run.log
else
    echo -e "\E[31m"
    echo "Please set check_updates=1 in your configuration file first or copy"
    echo "translation_projects.dat file manually into $git_directory/ before"
    echo "running this script again."
    echo -e "\E[m"
    exit 2
fi

echo "LIST OF RESOURCES WITH FUZZY OR EMPTY STRINGS (in $language_code language)" > "$log_directory"/list_of_resources_for_translation_$language_code.txt

# clone / pull git repositories
echo -e "\E[32m"
echo "Clone / pull git repositories:" | tee -a "$logfile"_this_run.log
echo -e "\E[m"
for git_address in "${!git_addresses[@]}"
do
    echo $separator | tee -a "$logfile"_this_run.log
    if [ -d "$git_directory/$git_address" ]; then
        echo Pull git repository "${git_addresses[$git_address]}" to "$git_address". | tee -a "$logfile"_this_run.log
        cd "$git_directory/$git_address"
#       just echo $language_code.po or *.pot file line if they are updated
        git pull --stat --rebase -q | grep -E "$language_code.po\>|.pot\>|.desktop\>|.html\>" | tee -a "$logfile"_this_run.log
#       git diff --name-status ORIG_HEAD.. | grep -E "$language_code.po|[\.]pot"
    else
        echo Clone git repository "${git_addresses[$git_address]}" to "$git_address". | tee -a "$logfile"_this_run.log
        cd "$git_directory/"
#       echo "${git_addresses[$git_address]}" # debug
        git clone -q --single-branch mga:${git_addresses[$git_address]} $git_address | tee -a "$logfile"_this_run.log
#       cd "$git_directory/$git_address"
    fi

done
echo $separator | tee -a "$logfile"_this_run.log
echo "" | tee -a "$logfile"_this_run.log

echo -e "\E[32m"
echo "" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo "Po and pot files:" | tee -a "$logfile"_this_run.log
echo "Translate po files in working (WD) or git directories:" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo -e "\E[m"
echo $separator | tee -a "$logfile"_this_run.log

# echo about checking the syntax of po file if required
if [ $check_po_syntax -eq 1 ]; then
    echo "Syntax of $language_code.po in git will be tested."
fi

# echo about copying the *.pot file and $language_code.po for editing in apropriate directory if required
if [ $copying_po -eq 1 ]; then
    echo "Files *.pot and $language_code.po will be copied into apropriate directory."
fi

empty_list_of_po_file=""
i=1
for translate_project_name_po in "${!translate_projects_po[@]}"
do
    echo $separator | tee -a "$logfile"_this_run.log
    unexisted_po="no"
    translate_this="no"
    wip_po_filename=""
    statistics_git_po=""
    statistics_git_pot=""
    statistics_wd_po=""
    pot_filename="*.pot"
    echo "Working on $language_code.po file in working translations directory: $translate_project_name_po and local git directory: ${translate_projects_po[$translate_project_name_po]}." | tee -a "$logfile"_this_run.log
    if [ ! -d "$git_directory/${translate_projects_po[$translate_project_name_po]}/" ]; then
        echo "Directory $git_directory/${translate_projects_po[$translate_project_name_po]}/ doesn't exist."
        echo "It seems that something wen't wrong in git clone operation. Other operations in $translate_project_name_po will be aborted."
        echo "All operations in $translate_project_name_po was aborted! Check script output or logs." >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
        continue
    else
        cd "$git_directory/${translate_projects_po[$translate_project_name_po]}/" # $translate_project_name_po"
        pot_filename=`ls *.pot`
        wip_po_filename="$pot_filename"_$language_code.po
        if [ $? -ne 0 ]; then
            echo "Pot file not found in $git_directory/${translate_projects_po[$translate_project_name_po]}/. Please report that on our mailing list." | tee -a "$logfile"_this_run.log
        fi
    fi

# checking for fuzzy and untranslated strings in git $language_code.po
    if [ -f $language_code.po ]; then
        msgattrib $language_code.po --only-fuzzy --no-obsolete | grep . >> /dev/null
        if [ $? -eq 0 ]; then
            translate_this="yes"
        fi
        msgattrib $language_code.po --untranslated --no-obsolete | grep . >> /dev/null
        if [ $? -eq 0 ]; then
            translate_this="yes"
        fi
    else # $language_code.po not in git yet
        translate_this="yes"
    fi
#   creating statistics
    if [ -f $language_code.po ]; then
        statistics_git_po=`LC_ALL=C msgfmt --statistics --verbose $language_code.po -o /dev/null 2>&1  | tail -1`
    fi
    if [ -f $pot_filename ]; then
        statistics_git_pot=`LC_ALL=C msgfmt --statistics --verbose $pot_filename -o /dev/null 2>&1 | tail -1`
    fi

#   checking the syntax of po file from git if required
    if [ $check_po_syntax -eq 1 ]; then
        if [ -f $language_code.po ]; then
            msgfmt --statistics --verbose -c $language_code.po -o /dev/null 2>&1 | tee -a "$logfile"_this_run.log
        else # Automatic test is not possible.
            echo "File $language_code.po is not present yet in ${translate_projects_po[$translate_project_name_po]} for msgfmt test. Please translate it and commit & push it to git." | tee -a "$logfile"_this_run.log
            unexisted_po="yes"
        fi
#       checking the syntax of pot file from git if required
        if [ $check_pot_syntax -eq 1 ]; then
            if [ -f $pot_filename ]; then
                msgfmt -c $pot_filename -o /dev/null 2>&1 | tee -a "$logfile"_this_run.log
            else # Automatic test is not possible.
                echo "File *.pot is not present in ${translate_projects_po[$translate_project_name_po]}. Please report that on our mailing list." | tee -a "$logfile"_this_run.log
            fi
        fi
    fi

#   copying the *.pot file and $language_code.po for editing in working directory if required
    if [ $copying_po -eq 1 ]; then
        if [ ! -d "$working_translations_directory/$translate_project_name_po/" ]; then
            mkdir -vp "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log
        fi
        if [ "$unexisted_po" != "yes" ]; then
#           testing for differences of *.po file from git and working copy
            if [ -f "$working_translations_directory/$translate_project_name_po/$language_code.po" ]; then
                diff -q "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po "$working_translations_directory/$translate_project_name_po/$language_code.po" | tee -a "$logfile"_this_run.log
            fi
            cp $copy_options $language_code.po "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log
        else
#           echo "File $language_code.po is not present yet in ${translate_projects_po[$translate_project_name_po]}. Copying to working directory is not possible." | tee -a "$logfile"_this_run.log
            echo -n # nop
        fi
        if [ -f $pot_filename ]; then
#           testing for differences of *.pot file from git and working copy
            if [ -f "$working_translations_directory/$translate_project_name_po/$pot_filename" ]; then
                diff -q "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" "$working_translations_directory/$translate_project_name_po/$pot_filename" | tee -a "$logfile"_this_run.log
            fi
            cp $copy_options $pot_filename "$working_translations_directory/$translate_project_name_po/" | tee -a "$logfile"_this_run.log
            cd "$working_translations_directory/$translate_project_name_po/"
#           rm sl.po # debug
            if [ -f "$working_translations_directory/$translate_project_name_po/$wip_po_filename" ]; then
#               creating new_pot_lang.po from latest *.pot file
                msgmerge -q $wip_po_filename $pot_filename > new_pot_$language_code.po | tee -a "$logfile"_this_run.log # || rm new_pot_$language_code.po # msgmerge *.pot_lang.po *.pot > new_pot_lang.po
                if [ ${PIPESTATUS[0]} -ne 0 ]; then
                    msgfmt -c "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" -o /dev/null
                    if [ ${PIPESTATUS[0]} -ne 0 ]; then
                        echo Test with msgfmt -c discovered a problem with "$git_directory/${translate_projects_po[$translate_project_name_po]}/$pot_filename" file. | tee -a "$logfile"_this_run.log
                        echo Please report on our mailing list that msgfmt -c test has a problem with "$translate_project_name_po/$pot_filename" file. >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
                    fi
                    msgfmt -c "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po -o /dev/null
                    if [ ${PIPESTATUS[0]} -ne 0 ]; then
                        echo Test with msgfmt -c discovered a problem with "$git_directory/${translate_projects_po[$translate_project_name_po]}/"$language_code.po file. | tee -a "$logfile"_this_run.log
                        echo Test with msgfmt -c discovered a problem with $language_code.po file. Check script output or logs. >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
                    fi
                    rm new_pot_$language_code.po # remove it as it's no good anyway
                fi
#               comparing new_pot_lang.po from working copy
                if [ -f new_pot_$language_code.po ]; then
                    statistics_wd_po=`LC_ALL=C msgfmt --statistics --verbose new_pot_$language_code.po -o /dev/null 2>&1 | tail -1`
#                   checking for fuzzy and untranslated strings in fresh new_pot_$language_code.po
                    msgattrib new_pot_$language_code.po --only-fuzzy --no-obsolete 2>&1 | grep . >> /dev/null
                    if [ $? -eq 0 ]; then
                        translate_this="yes"
                    fi
                    msgattrib new_pot_$language_code.po --untranslated --no-obsolete 2>&1 | grep . >> /dev/null
                    if [ $? -eq 0 ]; then
                        translate_this="yes"
                    fi
                    diff -q $wip_po_filename new_pot_$language_code.po >> /dev/null #| tee -a "$logfile"_this_run.log
#                   diff -q $language_code.po new_pot_$language_code.po | tee -a "$logfile"_this_run.log
                    diff_exit_status_1=${PIPESTATUS[0]} # this reads and remembers exit status of first command in pipe (diff in this case)
#                   if [ $? -eq 0 ]; then
                    if [ $diff_exit_status_1 -eq 0 ]; then # no differences
                        rm new_pot_$language_code.po # remove resulting file
#                       echo There are no differences between $wip_po_filename and new_pot_$language_code.po. # debug
                    else
                        if [ $diff_exit_status_1 -eq 1 ]; then # there are differences
                            echo Replace existing file $wip_po_filename with new_pot_$language_code.po in working directory $translate_project_name_po since they differ. | tee -a "$logfile"_this_run.log
                        else
                            echo There was an error in diff between $wip_po_filename and new_pot_$language_code.po in working directory $translate_project_name_po.
                        fi
                    fi
                else
#                   echo There is no new_pot_$language_code.po. # debug
                    echo -n # nop
                fi
#               comparing git lang.po from working copy lang.po
                if [ -f $language_code.po ]; then
                    diff -q $wip_po_filename $language_code.po | tee -a "$logfile"_this_run.log
                    diff_exit_status_2=${PIPESTATUS[0]} # this reads and remembers exit status of first command in pipe (diff in this case)
#                   if [ $? -eq 0 ]; then
                    if [ $diff_exit_status_2 -eq 1 ]; then # there are differences
                        echo New commit will be needed when the file $wip_po_filename will be ready in working directory $translate_project_name_po. | tee -a "$logfile"_this_run.log
                    else
                        if [ $diff_exit_status_2 -eq 2 ]; then # there was an error
                            echo There was an error in diff between file $wip_po_filename and $language_code.po in working directory $translate_project_name_po.
                        fi
                    fi
                fi
            else
                if [ "$unexisted_po" != "yes" ]; then
                    echo "File $wip_po_filename is not present in working directory $translate_project_name_po. Comparing is not possible." | tee -a "$logfile"_this_run.log
                fi
                if [ -z "$create_a_working_copy_of_po_file" ]; then
                    if [ "$unexisted_po" != "yes" ]; then
                        cp $copy_options $language_code.po $wip_po_filename | tee -a "$logfile"_this_run.log
                        echo "File $language_code.po in working directory $translate_project_name_po copied to $wip_po_filename." | tee -a "$logfile"_this_run.log
                    else
                        cp $copy_options $pot_filename $wip_po_filename | tee -a "$logfile"_this_run.log
                        echo "Template file $pot_filename in working directory $translate_project_name_po copied to $wip_po_filename." | tee -a "$logfile"_this_run.log
                    fi
                fi
            fi
        else
            echo "File $pot_filename is not present in ${translate_projects_po[$translate_project_name_po]}. Copying is not possible." | tee -a "$logfile"_this_run.log
        fi
#       echo "Files *.pot and $language_code.po copied into $working_translations_directory/$translate_project_name_po/."
    fi
    if [ -n "$statistics_wd_po" ]; then
        statistics_po=$statistics_wd_po
    else
        statistics_po=$statistics_git_po
    fi
    if [ -n "$statistics_po" ]; then
        statistics=$statistics_po
    else
        statistics=$statistics_git_pot
    fi
    if [ "$translate_this" = "yes" ]; then
        echo " $i. $translate_project_name_po, $statistics" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
        echo "    git: $git_directory/${translate_projects_po[$translate_project_name_po]}/$language_code.po" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
        if [ $copying_po -eq 1 ]; then
            echo "    WD: $working_translations_directory/$translate_project_name_po/$language_code.po" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
        fi
        empty_list_of_po_file="no"
        let i++
    fi
#    cd "$git_directory/"
#    echo "" | tee -a "$logfile"_this_run.log
done
echo $separator | tee -a "$logfile"_this_run.log
if [ -z "$empty_list_of_po_file" ]; then
    echo Congratulations. All po files are translated in $language_code language. >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
fi
echo "" | tee -a "$logfile"_this_run.log

echo -e "\E[32m"
echo "" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo "*.desktop files:" | tee -a "$logfile"_this_run.log
echo "Translate *.desktop files in working (WD) or git directories:" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo -e "\E[m"
if [ -z "$work_on_desktop_files" ]; then
    empty_list_of_desktop_file=""
    i=1
    for translate_project_name_desktop in "${!translate_projects_desktop[@]}"
    do
        if [ ! -f "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" ]; then
            echo "File $git_directory/${translate_projects_desktop[$translate_project_name_desktop]} doesn't exist."
            echo "It seems that something wen't wrong in git clone operation. Other operations in $translate_project_name_desktop will be aborted."
            echo "All operations in $translate_project_name_desktop was aborted! Check script output or logs." >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            continue
        fi
        echo $separator | tee -a "$logfile"_this_run.log
        copy_this_desktop_file="no"
        untranslated_name="Name, "
        untranslated_comment="Comment,"
        untranslated_generic_name="GenericName, "
        names_and_comments=""
        echo "Working on *.desktop file in working translations directory: $translate_project_name_desktop and local git directory: ${translate_projects_desktop[$translate_project_name_desktop]}." | tee -a "$logfile"_this_run.log
#       cd "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}/" # $translate_project_name_desktop"
        names_and_comments=`cat "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" #| grep -E "^Name=|^Name\[$language_code\]=|^Comment=|^Comment\[$language_code\]="`
#       echo names_and_comments: "$names_and_comments" # debug
        eng_name=`echo "$names_and_comments" | grep -E "^Name=" | sed 's/^Name=//'`
        lang_name=`echo "$names_and_comments" | grep -E "^Name\[$language_code\]=" | sed 's/^Name\['$language_code'\]=//'`
        eng_comment=`echo "$names_and_comments" | grep -E "^Comment=" | sed 's/^Comment=//'`
        lang_comment=`echo "$names_and_comments" | grep -E "^Comment\[$language_code\]=" | sed 's/^Comment\['$language_code'\]=//'`
        eng_generic_name=`echo "$names_and_comments" | grep -E "^GenericName=" | sed 's/^GenericName=//'`
        lang_generic_name=`echo "$names_and_comments" | grep -E "^GenericName\[$language_code\]=" | sed 's/^GenericName\['$language_code'\]=//'`

        if [ -n "$eng_name" ]; then # Name string present in original desktop file
            if [ -n "$lang_name" ]; then # Name string present in your language
                if [ "$lang_name" != "$eng_name" ]; then # both strings differ
#                   echo Name string \"$eng_name\" present in $language_code language: \"$lang_name\" # debug
#                   echo -n # nop
                    untranslated_name=""
                else # both strings are equal
                    copy_this_desktop_file="yes"
                    echo Name string \"$eng_name\" in $language_code language present but untranslated | tee -a "$logfile"_this_run.log
                fi
            else # Name string not present in your language
                copy_this_desktop_file="yes"
                echo Name string \"$eng_name\" not present in $language_code language | tee -a "$logfile"_this_run.log
            fi
        else
            untranslated_name=""
        fi
        if [ -n "$eng_comment" ]; then # Comment string present in original desktop file
            if [ -n "$lang_comment" ]; then # Comment string present in your language
                if [ "$lang_comment" != "$eng_comment" ]; then # both strings differ
#                   echo Comment string \"$eng_comment\" in $language_code language present: \"$lang_comment\" # debug
#                   echo -n # nop
                    untranslated_comment=""
                else # both strings are equal
                    copy_this_desktop_file="yes"
                    echo Comment string \"$eng_comment\" in $language_code language present but untranslated | tee -a "$logfile"_this_run.log
                fi
            else # Comment string not present in your language
                copy_this_desktop_file="yes"
                echo Comment string \"$eng_comment\" not present in $language_code language | tee -a "$logfile"_this_run.log
            fi
        else
            untranslated_comment=""
        fi
        if [ -n "$eng_generic_name" ]; then # GenericName string present in original desktop file
            if [ -n "$lang_generic_name" ]; then # GenericName string present in your language
                if [ "$lang_generic_name" != "$eng_generic_name" ]; then # both strings differ
#                   echo GenericName string \"$eng_generic_name\" in $language_code language present: \"$lang_generic_name\" # debug
#                   echo -n # nop
                    untranslated_generic_name=""
                else # both strings are equal
                    copy_this_desktop_file="yes"
                    echo GenericName string \"$eng_generic_name\" in $language_code language present but untranslated | tee -a "$logfile"_this_run.log
                fi
            else # GenericName string not present in your language
                copy_this_desktop_file="yes"
                echo GenericName string \"$eng_generic_name\" not present in $language_code language | tee -a "$logfile"_this_run.log
            fi
        else
            untranslated_generic_name=""
        fi

#       copying the *.desktop file for editing in working directory if required
        if [ -z $copying_desktop_files ]; then
            if [ "$copy_this_desktop_file" = "yes" ]; then
                if [ ! -d "$working_translations_directory/desktop/$translate_project_name_desktop/" ]; then
                    mkdir -vp "$working_translations_directory/desktop/$translate_project_name_desktop/" | tee -a "$logfile"_this_run.log
                fi
                cp $copy_options "$git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" "$working_translations_directory/desktop/$translate_project_name_desktop/" | tee -a "$logfile"_this_run.log
            fi
        fi
        if [ "$copy_this_desktop_file" = "yes" ]; then
            echo " $i. $translate_project_name_desktop, untranslated line: $untranslated_name $untranslated_comment $untranslated_generic_name" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            echo "    git: $git_directory/${translate_projects_desktop[$translate_project_name_desktop]}" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            if [ -z $copying_desktop_files ]; then
                echo "     WD: $working_translations_directory/desktop/$translate_project_name_desktop/" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            fi
            empty_list_of_desktop_file="no"
            let i++
        fi
    done
    if [ -z "$empty_list_of_desktop_file" ]; then
        echo Congratulations. All desktop files are translated in $language_code language. >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
    fi
else
    echo Your configuration exclude work on desktop files >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
fi
echo $separator | tee -a "$logfile"_this_run.log
echo "" | tee -a "$logfile"_this_run.log

echo -e "\E[32m"
echo "" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo "html software files:" | tee -a "$logfile"_this_run.log
echo "Copy and translate html software files in working (WD) or git directories:" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo -e "\E[m"
if [ -z "$work_on_html_software_files" ]; then
    empty_list_of_html_software_file=""
    i=1
    for translate_project_name_help in "${!translate_projects_help[@]}"
    do
        echo $separator | tee -a "$logfile"_this_run.log
        echo "Working on html software files for $language_code language code in working translations directory: $translate_project_name_help and local git directory: ${translate_projects_help[$translate_project_name_help]}." | tee -a "$logfile"_this_run.log
        if [ ! -d "$git_directory/${translate_projects_help[$translate_project_name_help]}/" ]; then
            echo "File $git_directory/${translate_projects_help[$translate_project_name_help]} doesn't exist."
            echo "It seems that something wen't wrong in git clone operation. Other operations in $translate_project_name_help will be aborted."
            echo "All operations in $translate_project_name_help was aborted! Check script output or logs." >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            continue
        fi
        if [ ! -d "$git_directory/${translate_projects_help[$translate_project_name_help]}/$language_code/" ]; then
            number_of_files=("$git_directory/${translate_projects_help[$translate_project_name_help]}/en/"*)
            echo " $i. $translate_project_name_help, ${#number_of_files[@]} files" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            echo "    git: $git_directory/${translate_projects_po[$translate_project_name_help]}$translate_project_name_help/en/*.html" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
            if [ -z $copying_html_software_files ]; then
                echo "    WD: $working_translations_directory/$translate_project_name_help$translate_project_name_help/*.html" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
                if [ ! -d "$working_translations_directory/$translate_project_name_help/" ]; then
                    mkdir -vp "$working_translations_directory/$translate_project_name_help/" | tee -a "$logfile"_this_run.log
                    cp $copy_options "$git_directory/${translate_projects_help[$translate_project_name_help]}/en/" "$working_translations_directory/$translate_project_name_help/" | tee -a "$logfile"_this_run.log
                fi
            fi
            echo "Please copy directory ./en/ from $translate_project_name_help/ to ./$language_code/ there. After translation of all those ${#number_of_files[@]} html files copy ./$language_code/ directory to local git directory: ${translate_projects_help[$translate_project_name_help]}/$language_code/."
            empty_list_of_html_software_file="no"
            let i++
        fi
    done
    echo $separator | tee -a "$logfile"_this_run.log
    if [ -z "$empty_list_of_html_software_file" ]; then
        echo Congratulations. All html directories in $language_code language exists. >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
    fi
fi

if [ -z "$work_on_web_pages_translation" ]; then
#   Check out / update web_page files
    echo -e "\E[32m"
    echo "Check out / update web page files:" | tee -a "$logfile"_this_run.log
    echo "" >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
    echo "Please check http://www.mageia.org/langs/report.php for details about translation of web page files in $language_code language." >> "$log_directory"/list_of_resources_for_translation_$language_code.txt
    echo -e "\E[m"
    for web_page_name in "${!web_pages[@]}"
    do
        echo $separator | tee -a "$logfile"_this_run.log
        echo Working on: "$web_page_name" from "${web_pages[$web_page_name]}". | tee -a "$logfile"_this_run.log # \'
        if [ -d "$svn_directory/$web_page_name/" ]; then
            cd "$svn_directory/$web_page_name/"
            svn upgrade | tee -a "$logfile"_this_run.log # if needed after your local distribution upgrade
#           just echo $language_code.lang or *.php file line if they are updated
            svn up | grep -E "$language_code.lang|en.lang|.php" | tee -a "$logfile"_this_run.log
#           echo -n "" # debug
        else
            cd "$svn_directory/"
#           just echo $language_code.lang or *.php file line if they are updated
            svn co $svn_method${web_pages[$web_page_name]} $web_page_name | grep -E "$language_code.lang|en.lang|.php" | tee -a "$logfile"_this_run.log
            echo -n "" | tee -a "$logfile"_this_run.log
            cd "$svn_directory/$web_page_name/"
        fi
#       echo "" | tee -a "$logfile"_this_run.log
    done


#   copying the english files and $language_code.lang files for editing in working directory if required
    if [ $copying_wp -eq 1 ]; then
        echo $separator | tee -a "$logfile"_this_run.log
        echo -e "\E[32m"
        echo "Web files will be copied (updated) into working translations directory."
        echo -e "\E[m"
        cd "$svn_directory/"

        if [ ! -d "$working_translations_directory/web_pages_lang/en/" ]; then
            mkdir -vp "$working_translations_directory/web_pages_lang/en/" | tee -a "$logfile"_this_run.log
        fi
        cp $copy_options ./web_pages_lang/en/* "$working_translations_directory/web_pages_lang/en/" | tee -a "$logfile"_this_run.log
        if [ ! -d "$working_translations_directory/web_pages_lang/$language_code/" ]; then
            mkdir -vp "$working_translations_directory/web_pages_lang/$language_code/" | tee -a "$logfile"_this_run.log
        fi
        cp $copy_options ./web_pages_lang/$language_code/* "$working_translations_directory/web_pages_lang/$language_code/" | tee -a "$logfile"_this_run.log
        if [ ! -d "$working_translations_directory/web_page_navigation/" ]; then
            mkdir -vp "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
        fi
        cp $copy_options ./web_page_navigation/en.lang "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
        cp $copy_options ./web_page_navigation/$language_code.lang "$working_translations_directory/web_page_navigation/" | tee -a "$logfile"_this_run.log
    fi

    if [ -d "$svn_directory/web_page_navigation/" ]; then
        if [ -d "$svn_directory/web_page_navigation_2/" ]; then
            diff -rq "$svn_directory/web_page_navigation" "$svn_directory/web_page_navigation_2" | grep -E ".lang" | tee -a "$logfile"_this_run.log
        else
            echo "Both navigation directories ($svn_directory/web_page_navigation and $svn_directory/web_page_navigation_2) are not present. Comparing is not possible." | tee -a "$logfile"_this_run.log
        fi
    else
        echo "Both navigation directories ($svn_directory/web_page_navigation and $svn_directory/web_page_navigation_2) are not present. Comparing is not possible." | tee -a "$logfile"_this_run.log
    fi
    echo "" | tee -a "$logfile"_this_run.log
fi

cd "$git_directory/"
##################################### TODO START change searching for new *.pot files and other resources in git
if [ $searching_for_new_pot_files_in_svn -eq 1 ]; then
    if [ "when_this_works_on_git" = "true" ]; then
        echo $separator | tee -a "$logfile"_this_run.log
        echo -e "\E[32m"
        echo "Searching for new *.pot files in svn." | tee -a "$logfile"_this_run.log
        echo -e "\E[m"
        if [ -f "$log_directory"/new_svn_list_of_pot_files ]; then
            mv "$log_directory"/new_svn_list_of_pot_files "$log_directory"/old_svn_list_of_pot_files # -f
        fi
        svn list -R svn://svn.mageia.org/svn/soft/ > "$log_directory"/svn_list
        cat "$log_directory"/svn_list | grep [\.]pot > "$log_directory"/new_svn_list_of_pot_files
#       svn list -R svn://svn.mageia.org/svn/soft/ | grep [\.]pot > new_svn_list_of_pot_files
        if [ -f "$log_directory"/old_svn_list_of_pot_files ]; then
            diff new_svn_list_of_pot_files old_svn_list_of_pot_files | tee -a "$logfile"_this_run.log
            if [ ${PIPESTATUS[0]} -eq 0 ]; then # this reads exit status of first command in pipe
                echo "No new *.pot files found." | tee -a "$logfile"_this_run.log
            fi
        fi
        echo "" | tee -a "$logfile"_this_run.log
    fi
fi
##################################### TODO END

# append this_run_log to full_log
cat "$logfile"_this_run.log >> "$logfile"_full.log
echo "" | tee -a "$logfile".log
echo $separator | tee -a "$logfile".log

if [ -z "$stop_showing_differences_from_last_run" ]; then
    if [ -f "$logfile"_previous_run.log ]; then
#       show only differences and log them
        echo -e "\E[32m"
        echo "Differences from last run:" | tee -a "$logfile".log
        echo -e "\E[m"
        echo -e "\E["$color_for_differences"m"
        diff "$logfile"_this_run.log "$logfile"_previous_run.log | tee -a "$logfile".log
        echo -e "\E[m"
    fi
fi

echo $separator
echo -e "\E[33m"
# echo "List of resources for translation:"
cat "$log_directory"/list_of_resources_for_translation_$language_code.txt
echo -e "\E[m"

# if you use this script by click it in GUI uncomment the next line
#read -p "Press any key to continue... " -n1 -s

# restore saved_dir
cd "$saved_dir"
# pwd
# set -x # turn debug tracing on with set -x
# set +x # turn debug tracing off with set +x
exit 0