Skip to content

Commit e31ed95

Browse files
justin808claude
andcommitted
Improve locale generation edge case handling
1. Add partial file check in obsolete? method: - Detect when only some output files exist (incomplete generation) - Triggers regeneration to ensure all files are present 2. Add warning for empty locale files: - Shows clear message when no source YAML files are found - Helps users debug configuration issues - Exits early to avoid confusing error messages 3. Simplify files_are_outdated logic: - Removed redundant empty check (now handled in initialize) - Cleaner separation of concerns All tests pass with these improvements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 22e9d96 commit e31ed95

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/react_on_rails/locales/base.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Base
3939
def initialize(force: false)
4040
return if i18n_dir.nil?
4141

42+
if locale_files.empty?
43+
puts "Warning: No locale files found in #{i18n_yml_dir || 'Rails i18n load path'}"
44+
return
45+
end
46+
4247
if !force && !obsolete?
4348
puts "Locale files are up to date, skipping generation. " \
4449
"Use 'rake react_on_rails:locale force=true' to force regeneration."
@@ -55,6 +60,7 @@ def initialize(force: false)
5560
def file_format; end
5661

5762
def obsolete?
63+
return true if exist_files.length != files.length # Some files missing
5864
return true if exist_files.empty?
5965

6066
files_are_outdated
@@ -65,8 +71,6 @@ def exist_files
6571
end
6672

6773
def files_are_outdated
68-
return false if locale_files.empty? # No source files = nothing to generate
69-
7074
latest_yml = locale_files.map { |file| File.mtime(file) }.max
7175
earliest = exist_files.map { |file| File.mtime(file) }.min
7276
latest_yml > earliest

0 commit comments

Comments
 (0)