module Tml

Decoration Token Forms:

link: click here

or

link

click here [/link]

Decoration Tokens Allow Nesting:

link: {count} {_messages}
link: {count||message}
link: {count||person, people}
link: {user.name}

Decoration Token Forms:

link: click here

or

link

click here [/link]

Decoration Tokens Allow Nesting:

link: {count} {_messages}
link: {count||message}
link: {count||person, people}
link: {user.name}
link

{user.name} [/link]

<link> {user.name} </link>

Decoration Token Forms:

link: click here

or

link

click here [/link]

Decoration Tokens Allow Nesting:

link: {count} {_messages}
link: {count||message}
link: {count||person, people}
link: {user.name}

Constants

CACHE_VERSION_KEY
VERSION

Attributes

config[RW]

Public Class Methods

cache() click to toggle source
# File lib/tml/cache.rb, line 41
def self.cache
  @cache ||= begin
    if Tml.config.cache_enabled?
      # .capitalize is not ideal, but .camelcase is not available in pure ruby.
      # This works for the current class names.
      klass = Tml::CacheAdapters.const_get(Tml.config.cache[:adapter].to_s.capitalize)
      klass.new
    else
      # blank implementation
      Tml::Cache.new
    end
  end
end
configure() { |config| ... } click to toggle source

Allows you to configure Tml

Tml.configure do |config|

config.application = {:key => "", :secret => ""}

end

# File lib/tml/config.rb, line 53
def self.configure
  yield(self.config)
end
current_language() click to toggle source
# File lib/tml.rb, line 48
def self.current_language
  Tml.session.current_language
end
default_language() click to toggle source
# File lib/tml.rb, line 44
def self.default_language
  Tml.config.default_language
end
full_version() click to toggle source
# File lib/tml/version.rb, line 36
def self.full_version
  "tml-ruby v#{Tml::VERSION} (Faraday v#{Faraday::VERSION})"
end
language(locale) click to toggle source
# File lib/tml.rb, line 52
def self.language(locale)
  Tml.session.application.language(locale)
end
logger() click to toggle source
# File lib/tml/logger.rb, line 37
def self.logger
  @logger ||= begin
    logfile_path = File.expand_path(Tml.config.logger[:path] || './log/tml.log')
    logfile_dir = logfile_path.split("/")[0..-2].join("/")
    FileUtils.mkdir_p(logfile_dir) unless File.exist?(logfile_dir)
    logfile = File.open(logfile_path, 'a')
    logfile.sync = true

    logger = Tml::Logger.new(logfile)
    if Tml.config.logger[:type].to_s == 'rails'
      logger.external_logger = Rails.logger
    end

    logger
  end
end
logger=(logger) click to toggle source
# File lib/tml/logger.rb, line 54
def self.logger=(logger)
  @logger = logger
end
session() click to toggle source
# File lib/tml/session.rb, line 35
def self.session
  Thread.current[:tml_context] ||= Tml::Session.new
end
translate(label, description = '', tokens = {}, options = {}) click to toggle source
# File lib/tml.rb, line 56
def self.translate(label, description = '', tokens = {}, options = {})
  Tml.session.translate(label, description, tokens, options)
end
with_config_settings() { |config| ... } click to toggle source

Allows you to create a block to perform something on adjusted config settings Once the block exists, the config will be reset back to what it was before:

Tml.with_config_settings do |config|
   config.format = :text

   Do something....

end
# File lib/tml/config.rb, line 68
def self.with_config_settings
  old_config = @config.dup
  yield(@config)
  @config = old_config
end
with_options(opts) { || ... } click to toggle source
# File lib/tml.rb, line 60
def self.with_options(opts)
  Tml.session.with_options(opts) do
    if block_given?
      yield
    end
  end
end