Guest User

Untitled

a guest
May 24th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. module Globalite4js
  2. require "yaml"
  3.  
  4. wtf = [true, false]
  5.  
  6. Dir.foreach("lang/ui") do |lang|
  7. if (lang.split('.').last == 'yml')
  8. yaml = YAML.load_file("lang/ui/"+lang)
  9.  
  10. file = File.open("public/javascripts/lang/ui/"+lang.split('.')[0] + ".js", 'w')
  11. file.write("var globalite = {")
  12.  
  13. i = 1
  14. yaml.each_pair do |key, value|
  15. key = key.to_s
  16. value = value.to_s
  17.  
  18. if wtf.include?(key)
  19. yaml.delete(key)
  20. yaml[key] = value
  21. end
  22. yaml[key] = value if wtf.include?(value)
  23.  
  24. yaml[key] = value.tr('{}', '%')
  25.  
  26. (i == yaml.size) ? file.write("\"#{key}\" : \"#{value}\" }" ) : file.write("\"#{key}\" : \"#{value}\", \n" )
  27. i += 1
  28. end
  29.  
  30. end
  31. end
  32.  
  33. end
Add Comment
Please, Sign In to add comment