Created
December 28, 2010 18:55
-
-
Save knewter/757546 to your computer and use it in GitHub Desktop.
dastardly code that I'm simultaneously proud of and scarred by
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@translations_split = {} | |
@translations.each do |key, default_translation| | |
tran_parts = key.split('.') | |
current_position = @translations_split | |
while tran_parts.length > 1 | |
next_part = tran_parts.shift | |
unless current_position[next_part] | |
current_position[next_part] = {} | |
end | |
current_position = current_position[next_part] | |
end | |
current_position[tran_parts.first] = default_translation | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment