Merge lp:~gunchleoc/widelands/translation_validation_folder_structure into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 8856
Proposed branch: lp:~gunchleoc/widelands/translation_validation_folder_structure
Merge into: lp:widelands
Diff against target: 139 lines (+47/-23)
2 files modified
utils/glossary_checks.py (+3/-3)
utils/validate_translations.sh (+44/-20)
To merge this branch: bzr merge lp:~gunchleoc/widelands/translation_validation_folder_structure
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+355599@code.launchpad.net

Commit message

Copy translation validation results into maintainers' and translators' views to make them easier for translators to navigate.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

This doesn't affect Widelands itself, so it can go straight in

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4046. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/433324366.
Appveyor build 3842. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_gunchleoc_widelands_translation_validation_folder_structure-3842.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils/glossary_checks.py'
2--- utils/glossary_checks.py 2017-08-17 14:06:54 +0000
3+++ utils/glossary_checks.py 2018-09-26 05:55:25 +0000
4@@ -512,8 +512,8 @@
5 hit.term, hit.translation, hit.source, hit.target, hit.po_file, hit.location)
6 locale_result = locale_result + row
7 counter = counter + 1
8- dest_filepath = output_path + '/glossary_check_' + locale + '.csv'
9- with open(dest_filepath, 'wt') as dest_file:
10+ dest_filepath = make_path(output_path, locale)
11+ with open(dest_filepath + '/glossary_check.csv', 'wt') as dest_file:
12 dest_file.write(locale_result)
13 # Uncomment this line to print a statistic of the number of hits for each locale
14 # print("%s\t%d"%(locale, counter))
15@@ -547,7 +547,7 @@
16
17 input_path = os.path.abspath(os.path.join(
18 os.path.dirname(__file__), '../po'))
19- output_path = make_path(os.path.dirname(__file__), '../po_validation')
20+ output_path = make_path(os.path.dirname(__file__), '../po_validation/translators')
21 result = check_translations_with_glossary(
22 input_path, output_path, glossary_file, locale)
23 print('Current time: %s' % time.ctime())
24
25=== modified file 'utils/validate_translations.sh'
26--- utils/validate_translations.sh 2018-09-10 07:00:08 +0000
27+++ utils/validate_translations.sh 2018-09-26 05:55:25 +0000
28@@ -18,36 +18,46 @@
29 exit 1;
30 fi
31
32-# Make sure that the output directory is there
33+# Make sure that the output directories are there and empty
34+echo "Creating directories in 'po_validation'"
35 if [ ! -d "po_validation" ]; then
36- echo "Creating directory 'po_validation'"
37 mkdir po_validation
38 fi
39+if [ ! -d "po_validation/maintainers" ]; then
40+ mkdir po_validation/maintainers
41+else
42+ rm -rf po_validation/maintainers/*
43+fi
44+if [ ! -d "po_validation/translators" ]; then
45+ mkdir po_validation/translators
46+else
47+ rm -rf po_validation/translators/*
48+fi
49
50 echo "Running i18nspector. This can take a while."
51
52 # We want a log of all errors.
53 i18nspector po/*/*.po \
54 | grep "E:" \
55- > po_validation/i18nspector-errors.log
56+ > po_validation/maintainers/i18nspector-errors.log
57
58 # We don't care about all warnings, so we filter some out.
59 i18nspector po/*/*.po \
60 | grep "W:" \
61 | grep -v "invalid-last-translator" \
62 | grep -v boilerplate \
63- > po_validation/i18nspector-warnings.log
64+ > po_validation/maintainers/i18nspector-warnings.log
65
66
67 # Takes type of check as an argument.
68 # Makes a subdirectory for the argument if necessary,
69 # then runs pofilter with the check.
70 function run_pofilter() {
71- if [ ! -d "po_validation/$1/" ]; then
72- mkdir po_validation/$1/
73+ if [ ! -d "po_validation/maintainers/$1/" ]; then
74+ mkdir po_validation/maintainers/$1/
75 fi
76 echo "Running pofilter for '$1'"
77- pofilter -t $1 -i po/ -o po_validation/$1/
78+ pofilter -t $1 -i po/ -o po_validation/maintainers/$1/
79 }
80
81 # These checks are critical
82@@ -72,30 +82,44 @@
83 run_pofilter "numbers"
84
85 # We only run the options check on the command line help
86-if [ ! -d "po_validation/options/" ]; then
87+if [ ! -d "po_validation/maintainers/options/" ]; then
88 echo "Creating directory 'options'"
89- mkdir po_validation/options/
90+ mkdir po_validation/maintainers/options/
91 fi
92 echo "Running pofilter for 'options'"
93-pofilter -t options -i po/widelands_console/ -o po_validation/options/
94+pofilter -t options -i po/widelands_console/ -o po_validation/maintainers/options/
95
96-echo "Cleaning up empty directories"
97-for dir in po_validation/*/
98+echo "Processing directories"
99+for dir in po_validation/maintainers/*/
100 do
101 dir=${dir%*/}
102- echo "- Cleaning up ${dir##*/}"
103- if [ ! "$(find po_validation/${dir##*/}/ -mindepth 1 -maxdepth 1 -type d -printf . | wc -c)" -eq 0 ]; then
104- for subdir in po_validation/${dir##*/}/*/
105+ echo "- ${dir##*/}"
106+ if [ ! "$(find po_validation/maintainers/${dir##*/}/ -mindepth 1 -maxdepth 1 -type d -printf . | wc -c)" -eq 0 ]; then
107+ for subdir in po_validation/maintainers/${dir##*/}/*/
108 do
109 subdir=${subdir%*/}
110- if [ ! "$(ls -A po_validation/${dir##*/}/${subdir##*/})" ]; then
111- rmdir po_validation/${dir##*/}/${subdir##*/}
112+ if [ ! "$(ls -A po_validation/maintainers/${dir##*/}/${subdir##*/})" ]; then
113+ # Delete empty directories
114+ rmdir po_validation/maintainers/${dir##*/}/${subdir##*/}
115+ else
116+ # Copy files to translators' view
117+ category=$(basename "$dir")
118+ textdomain=$(basename "$subdir")
119+ for localepath in $(find $subdir -maxdepth 2 -type f)
120+ do
121+ locale=$(basename "${localepath%.*}")
122+ targetpath="po_validation/translators/$locale/$textdomain/$category.po"
123+ if [ ! -d "po_validation/translators/$locale/" ]; then
124+ mkdir po_validation/translators/$locale/
125+ fi
126+ if [ ! -d "po_validation/translators/$locale/$textdomain/" ]; then
127+ mkdir po_validation/translators/$locale/$textdomain/
128+ fi
129+ cp $localepath $targetpath
130+ done
131 fi
132 done
133 fi
134- if [ ! "$(ls -A po_validation/${dir##*/})" ]; then
135- rmdir po_validation/${dir##*/}
136- fi
137 done
138
139 echo "Done"

Subscribers

People subscribed via source and target branches

to status/vote changes: