Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to list orphaned pluralizations #1016

Merged
merged 2 commits into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 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 @@ -111,9 +117,20 @@ class Locales < Thor
Dir.chdir(path_to_locales)
locale_files = Dir.glob('**/*.yml')
locales = locale_files.map{ |f| File.basename(f, '.yml') }
Dir.chdir('../..') # rewind
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