File tree 1 file changed +21
-5
lines changed
1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -89,18 +89,34 @@ summarize_progress: $(VENV_FOR_SCRIPT)/bin/activate
89
89
90
90
.PHONY : google_translate
91
91
google_translate : $(VENV_FOR_SCRIPT ) /bin/activate
92
- if [ -z $( filter-out $@ ,$( MAKECMDGOALS) ) ]; then \
92
+
93
+ @$(eval _target=$(filter-out $@, $(MAKECMDGOALS)))
94
+ @if [ -z $(_target) ]; then \
93
95
echo "Please provide a file argument."; \
94
96
exit 1; \
95
97
fi
96
98
97
- @$(eval __target=$(filter-out $@,$(MAKECMDGOALS)))
98
- @$(eval __filepath=$(addprefix ../,$(__target)))
99
- @$(eval __temp_po_file=tmp.po)
99
+
100
+ @if [ "$(suffix $(_target))" != ".po" ]; then \
101
+ echo "Incorrect file extension. Only '.po' files are allowed."; \
102
+ exit 1; \
103
+ else \
104
+ _target=$(addsuffix ,po,$(_target)); \
105
+ fi
106
+
107
+ @if [ ! -f "$(_target)" ]; then \
108
+ echo "File '$(filter-out $@, $(_target))' does not exist."; \
109
+ exit 1; \
110
+ fi
111
+
112
+ @$(eval _tmp_po_file=tmp.po)
113
+ @$(eval _file_path=$(addprefix ../, $(_target)))
100
114
101
115
cd .scripts && \
102
116
. $(VENV_FOR_SCRIPT)/bin/activate; \
103
- python3 google_translate/main.py $(__filepath) > $(__temp_po_file) ; pomerge -t $(__filepath) -i $(__temp_po_file) -o $(__filepath); rm "$(__temp_po_file)"
117
+ python3 google_translate/main.py $(_file_path) > $(_tmp_po_file) ; \
118
+ pomerge -t $(_file_path) -i $(_tmp_po_file) -o $(_file_path) ; \
119
+ # rm $(_tmp_po_file)
104
120
exit 0
105
121
106
122
You can’t perform that action at this time.
0 commit comments