Skip to content

Commit e601e53

Browse files
committed
Merge pull request #9 from daften/feature/force_english_drushrc
Force english through drushrc.php file
2 parents 1576691 + 23715cd commit e601e53

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Version 0.5 (unreleased)
22
-----------
33

4+
- [Fea] Set language for drush commands to English through forced config file
45

56
Version 0.4
67
-----------

bin/check_drupal

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ is_drupal_root() {
207207
return 0
208208
}
209209

210+
# Writes a drushrc.php file to /tmp
211+
write_drushrc() {
212+
echo "<?php" > '/tmp/drushrc.php'
213+
echo "// Drush commands should always be run in en." >> '/tmp/drushrc.php'
214+
echo "\$options['variables']['language_default'] = (object) array(" >> '/tmp/drushrc.php'
215+
echo " 'language' => 'en'," >> '/tmp/drushrc.php'
216+
echo " 'name' => 'English'," >> '/tmp/drushrc.php'
217+
echo " 'native' => 'English'," >> '/tmp/drushrc.php'
218+
echo " 'direction' => '0'," >> '/tmp/drushrc.php'
219+
echo " 'enabled' => 1," >> '/tmp/drushrc.php'
220+
echo " 'plurals' => '0'," >> '/tmp/drushrc.php'
221+
echo " 'formula' => ''," >> '/tmp/drushrc.php'
222+
echo " 'domain' => ''," >> '/tmp/drushrc.php'
223+
echo " 'prefix' => 'en'," >> '/tmp/drushrc.php'
224+
echo " 'weight' => '0'," >> '/tmp/drushrc.php'
225+
echo " 'javascript' => ''," >> '/tmp/drushrc.php'
226+
echo ");" >> '/tmp/drushrc.php'
227+
}
228+
229+
# Removes the drushrc.php file from /tmp if it exists
230+
remove_drushrc() {
231+
if [ -f '/tmp/drushrc.php' ]; then
232+
rm -f '/tmp/drushrc.php'
233+
fi
234+
}
235+
210236

211237
############################################################
212238
# Drush check functions
@@ -363,9 +389,8 @@ check_core_warnings() {
363389
return $EXIT_UNKNOWN
364390
fi
365391

366-
# Only keep "Warnung", "Warning", ... TODO: Other languages or make it outut always in english
367-
# But how???
368-
_core_warnings="$(echo "${_core_warnings}" | grep -E 'Warning|Warnung')"
392+
# Only keep "Warning"
393+
_core_warnings="$(echo "${_core_warnings}" | grep -E 'Warning')"
369394

370395
# Trim the string
371396
_core_warnings="$(trim_lines "${_core_warnings}")"
@@ -696,6 +721,10 @@ while test -n "$1"; do
696721
shift
697722
done
698723

724+
# Use a drushrc.php file to set the language to english
725+
write_drushrc
726+
DRUSH="${DRUSH} --config=/tmp/drushrc.php"
727+
699728

700729
############################################################
701730
# Validate arguments
@@ -1005,5 +1034,7 @@ else
10051034
exit "$NAGIOS_EXIT"
10061035
fi
10071036

1037+
remove_drushrc
1038+
10081039
# " vim: set ts=4:
10091040

0 commit comments

Comments
 (0)