Avoid notices when loading locale file

Reference: #1220

Cherry picked @Ceeram's commit for the test case.