Skip to content

Commit 050e739

Browse files
committed
Use a drushrc.php file to set language to english for drush commands
1 parent 1576691 commit 050e739

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

bin/check_drupal

Lines changed: 32 additions & 0 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
@@ -696,6 +722,10 @@ while test -n "$1"; do
696722
shift
697723
done
698724

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

700730
############################################################
701731
# Validate arguments
@@ -1005,5 +1035,7 @@ else
10051035
exit "$NAGIOS_EXIT"
10061036
fi
10071037

1038+
remove_drushrc
1039+
10081040
# " vim: set ts=4:
10091041

0 commit comments

Comments
 (0)