Class: Showoff::Compiler::I18n
- Inherits:
-
Object
- Object
- Showoff::Compiler::I18n
- Defined in:
- lib/showoff/compiler/i18n.rb
Overview
Adds slide language selection to the compiler
Class Method Summary collapse
Class Method Details
.selectLanguage!(content) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/showoff/compiler/i18n.rb', line 4 def self.selectLanguage!(content) translations = {} content.scan(/^((~~~LANG:([\w-]+)~~~\n)(.+?)(\n~~~ENDLANG~~~))/m).each do |match| markup, opentag, code, text, closetag = match translations[code] = {:markup => markup, :content => text} end lang = Showoff::Locale.resolve(translations.keys).to_s translations.each do |code, translation| if code == lang content.sub!(translation[:markup], translation[:content]) else content.sub!(translation[:markup], "\n") end end content end |