From 1db1efbcb30888107111455e04d8c8d8bf00818a Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Tue, 16 Aug 2022 12:44:33 +0200 Subject: [PATCH 1/2] Add method to list orphaned pluralizations Add method to thor locales to list locales that have a pluralization file but no locale file See #1011 --- locales.thor | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/locales.thor b/locales.thor index 4009d6c2e..a4d8ceb9d 100644 --- a/locales.thor +++ b/locales.thor @@ -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' @@ -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 = [] From a53c1cfea9965bf4f2fcaf120e446172f02db201 Mon Sep 17 00:00:00 2001 From: digitalfrost Date: Tue, 16 Aug 2022 12:48:43 +0200 Subject: [PATCH 2/2] Rewind after Dir.chdir Prevents problems when chaining method calls --- locales.thor | 1 + 1 file changed, 1 insertion(+) diff --git a/locales.thor b/locales.thor index a4d8ceb9d..90caabcee 100644 --- a/locales.thor +++ b/locales.thor @@ -117,6 +117,7 @@ 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