@@ -130,10 +130,12 @@ def extension_path_for(path, extension, apply_tmp = true)
130
130
131
131
# Detect whether this is a special file that needs to get merged not overwritten.
132
132
# This is important only when nesting extensions.
133
- if extension . present? && File . exist? ( path )
133
+ # Routes and #{gem_name}\.rb have an .erb extension as path points to the generator template
134
+ # We have to exclude it when checking if the file already exists and include it in the regexps
135
+ if extension . present? && File . exist? ( path . gsub ( /\. erb$/ , "" ) )
134
136
if %r{/locales/.*\. yml$} === path ||
135
- %r{/routes.rb$} === path ||
136
- %r{/#{ gem_name } .rb$} === path
137
+ %r{/routes\ . rb\. erb $} === path ||
138
+ %r{/#{ gem_name } \ . rb\. erb $} === path
137
139
# put new translations into a tmp directory
138
140
if apply_tmp
139
141
path = path . split ( File ::SEPARATOR ) . insert ( -2 , "tmp" ) .
@@ -210,13 +212,15 @@ def merge_locales!
210
212
if existing_extension?
211
213
# go through all of the temporary files and merge what we need into the current files.
212
214
tmp_directories = [ ]
213
- Dir . glob ( source_pathname . join ( "{config/locales/*.yml,config/routes.rb,lib/refinerycms-extension_plural_name.rb}" ) , File ::FNM_DOTMATCH ) . sort . each do |path |
215
+ Dir . glob ( source_pathname . join ( "{config/locales/*.yml,config/routes.rb.erb ,lib/refinerycms-extension_plural_name.rb.erb }" ) , File ::FNM_DOTMATCH ) . sort . each do |path |
214
216
# get the path to the current tmp file.
215
- new_file_path = extension_path_for ( path , extension_name )
217
+ # Both the new and current paths need to strip the .erb portion from the generator template
218
+ new_file_path = Pathname . new extension_path_for ( path , extension_name ) . to_s . gsub ( /\. erb$/ , "" )
216
219
tmp_directories << Pathname . new ( new_file_path . to_s . split ( File ::SEPARATOR ) [ 0 ..-2 ] . join ( File ::SEPARATOR ) ) # save for later
217
220
# get the path to the existing file and perform a deep hash merge.
218
- current_path = extension_path_for ( path , extension_name , false )
221
+ current_path = Pathname . new extension_path_for ( path , extension_name , false ) . to_s . gsub ( / \. erb$/ , "" )
219
222
new_contents = nil
223
+
220
224
if File . exist? ( new_file_path ) && %r{.yml$} === new_file_path . to_s
221
225
# merge translation files together.
222
226
new_contents = YAML ::load ( new_file_path . read ) . deep_merge (
0 commit comments