Project

General

Profile

Actions

Patch #39207

closed

Replace `YAML.load` with `YAML.load_file` in locales.rake and improve error reporting for invalid YAML files

Added by Go MAEDA 7 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The attached patch replaces YAML.load with YAML.load_file in lib/tasks/locales.rake and improves the error message when `rake locales` fail to parse a translation file.

Suppose config/locales/tr.yml is not a valid YAML file and rake locales raises an error. As shown in the example below, after the improvement, the name of the file containing the problem will be displayed instead of "<unknown>", making it easier to identify which file contains the problem.

Before:

Updating file ./config/locales/tr.yml
rake aborted!
Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 7 column 3

After:

Updating file ./config/locales/tr.yml
rake aborted!
Psych::SyntaxError: (./config/locales/tr.yml): did not find expected key while parsing a block mapping at line 7 column 3


Files

use_yaml_load_file.patch (1.13 KB) use_yaml_load_file.patch Go MAEDA, 2023-10-20 03:26
Actions

Also available in: Atom PDF