i18n Multisite folders

Hello, is there a way on build to copy the main css/js/whatever folder in each language folder?

I mean for example the DE folder should have this structure:

DE
– index.html
–[css folder]
–[js folder]
–[images/folder]

Not sure exactly what you want to do (and why), but after_build may be what you need. It will allow you to make copies of whatever into whereever.

1 Like

Hi, thanks. Basically I’ve to build a set of landing pages localised in several langs, each page will be uploaded on a different server, so I’d like to avoid the manual copy/paste of folders and assets from the root dir to each lang dir.

Sounds like a task for after_build

I managed to do it manually like

after_build do |builder|
 FileUtils.cp_r 'build/js/.', 'build/de/js'
 FileUtils.cp_r 'build/css/.', 'build/de/css'
 FileUtils.cp_r 'build/images/.', 'build/de/images'
end

but I’d like to know if there’s a way to iterate to all languages folders instead of writing /de/ or /fr/ etc.

after_build do |builder|
  ['de','fr','etc'].each do |language|
    FileUtils.cp_r 'build/js/.', "build/#{language}/js"

(Edited: Double-quotes needed for #{language} to resolve)

Or, if you prefer a more complex solution, you can make the script walk you dictionary (Dir.glob) and compile the list of language dictionaries.

1 Like