Skip to content

Commit

Permalink
Add method to list orphaned pluralizations
Browse files Browse the repository at this point in the history
Add method to thor locales to list locales that
have a pluralization file but no locale file
See svenfuchs#1011
  • Loading branch information
digitalfrost committed Aug 16, 2022
1 parent 7c14ed9 commit 1db1efb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions locales.thor
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ class Locales < Thor
puts self.incomplete_locales.count
end

desc 'orphaned_pluralizations', 'Returns pluralizations that do nothave a locale file'
def orphaned_pluralizations
orphans = self.list_pluralizations.difference(self.list_locales)
puts orphans.join(', ')
end

private

desc 'list_locales', 'List all locales'
Expand All @@ -114,6 +120,16 @@ class Locales < Thor
return locales.sort
end

desc 'list_pluralizations', 'List all pluralizations'
def list_pluralizations
path_to_pluralizations = 'rails/pluralization'
Dir.chdir(path_to_pluralizations)
pluralization_files = Dir.glob('*.rb')
pluralizations = pluralization_files.map{ |f| File.basename(f, '.rb') }
Dir.chdir('../..') # rewind
return pluralizations.sort
end

desc 'complete_locales', 'List complete locales'
def complete_locales
locales = []
Expand Down

0 comments on commit 1db1efb

Please sign in to comment.