in order to have Google Spreadsheets reevaluate a formula, the input arguments to the formula must get new values.
In your case, the only input parameter is argument is the name of a sheet, so the formula won't be evaluated as long as the sheet name stays the same (unless you specify a refresh interval in the spreadsheet's settings).
But you want to ...
@tedinoz guided me to a different approach: instead of the custom function, I ended up using NETWORKDAYS.INTL the following way:
Mondays: =NETWORKDAYS.INTL("8/1/2019",eomonth("8/1/2019", 0), "0111111")
Tuesdays: =NETWORKDAYS.INTL("8/1/2019",eomonth("8/1/2019", 0), "1011111")
Wednesdays: =NETWORKDAYS.INTL("8/1/2019",eomonth("8/1/2019", 0), "1101111")
The main problem is that sheetnames function returns a string while the QUERY's first argument should be a range reference or an array of values.
Another problem, is that Google Sheets errors aren't very clear, but regarding this we can only give feedback to Google. For this use Google Feedback.
The solution is to replace your sheetnames custom function ...
Hmm, based on the documentation for Detectlanguage, it doesn't look like you can feed it a range.
The best it seems you can do is define it as an array formula and check each line you wish to check, but that won't really work for an arbitrarily large array.
An idea I had was to use the app's service to translate everything to English and then compare ...