ItemsRepo#build_cache! is flawed when combined with I18n.with_locale
Closed this issue · 2 comments
ahoward commented
tl;dr; if you switch locales the cache is the wrong locale.
I18n.enforce_available_locales = false
dato.available_locales.each do |locale|
directory "data/dato/#{locale}" do
I18n.with_locale(locale) do
dato.send(:build_cache!) # without this the cache will contain data for the wrong locale ;-/
create_data_file "site.yml", :yaml, dato.site.to_hash
dato.item_types.each do |item_type|
create_data_file "#{item_type.api_key}.yml", :yaml,
dato.items_of_type(item_type).map(&:to_hash)
end
end
end
end
stefanoverna commented
stefanoverna commented
The same commit also fixes the situation where an Item Type has a field called slug
. In this case, the gem returns the directly the field value, and does not generate a slug on its own.