Guest User

Untitled

a guest
Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. @translations_split = {}
  2. @translations.each do |key, default_translation|
  3. tran_parts = key.split('.')
  4. current_position = @translations_split
  5. while tran_parts.length > 1
  6. next_part = tran_parts.shift
  7. unless current_position[next_part]
  8. current_position[next_part] = {}
  9. end
  10. current_position = current_position[next_part]
  11. end
  12. current_position[tran_parts.first] = default_translation
  13. end
Add Comment
Please, Sign In to add comment