Module: Localeapp

Defined in:
lib/localeapp.rb,
lib/localeapp/rails.rb,
lib/localeapp/poller.rb,
lib/localeapp/routes.rb,
lib/localeapp/sender.rb,
lib/localeapp/cli/add.rb,
lib/localeapp/updater.rb,
lib/localeapp/version.rb,
lib/localeapp/api_call.rb,
lib/localeapp/cli/pull.rb,
lib/localeapp/cli/push.rb,
lib/localeapp/i18n_shim.rb,
lib/localeapp/api_caller.rb,
lib/localeapp/cli/update.rb,
lib/localeapp/cli/install.rb,
lib/localeapp/key_checker.rb,
lib/localeapp/configuration.rb,
lib/localeapp/rails/controller.rb,
lib/localeapp/exception_handler.rb,
lib/localeapp/missing_translations.rb

Defined Under Namespace

Modules: ApiCall, CLI, Rails, Routes, TranslationHelperMonkeyPatch Classes: ApiCaller, Configuration, ExceptionHandler, KeyChecker, MissingTranslationRecord, MissingTranslations, Poller, Sender, Updater

Constant Summary collapse

API_VERSION =
"1"
LOG_PREFIX =
"** [Localeapp] "
VERSION =
"0.3.1"
I18nMissingTranslationException =
I18n::MissingTranslationData

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

An Localeapp configuration object.



54
55
56
# File 'lib/localeapp.rb', line 54

def configuration
  @configuration
end

.missing_translationsObject (readonly)

The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend



67
68
69
# File 'lib/localeapp.rb', line 67

def missing_translations
  @missing_translations
end

.pollerObject

The poller object is responsible for retrieving data for the Localeapp server



60
61
62
# File 'lib/localeapp.rb', line 60

def poller
  @poller
end

.senderObject

The sender object is responsible for delivering formatted data to the Localeapp server.



57
58
59
# File 'lib/localeapp.rb', line 57

def sender
  @sender
end

.updaterObject

The updater object is responsible for merging translations into the i18n backend



63
64
65
# File 'lib/localeapp.rb', line 63

def updater
  @updater
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Localeapp.configure do |config|

config.api_key = '1234567890abcdef'

end

Examples:

Configuration


Yields:



88
89
90
91
92
93
94
95
# File 'lib/localeapp.rb', line 88

def configure
  self.configuration ||= Configuration.new
  yield(configuration)
  self.sender  = Sender.new
  self.poller  = Poller.new
  self.updater = Updater.new
  @missing_translations = MissingTranslations.new
end

.debug(message) ⇒ Object



75
76
77
# File 'lib/localeapp.rb', line 75

def debug(message)
  logger.debug(LOG_PREFIX + message) if logger
end

.include_config_file(file_path = nil) ⇒ Object

requires the Localeapp configuration



98
99
100
101
102
103
104
105
106
# File 'lib/localeapp.rb', line 98

def include_config_file(file_path=nil)
  file_path ||= File.join(Dir.pwd, 'config', 'initializers', 'localeapp')
  begin
    require file_path
    true
  rescue
    false
  end
end

.log(message) ⇒ Object

Writes out the given message to the #logger



71
72
73
# File 'lib/localeapp.rb', line 71

def log(message)
  logger.info LOG_PREFIX + message if logger
end

.loggerObject

Look for the Rails logger currently defined



80
81
82
# File 'lib/localeapp.rb', line 80

def logger
  self.configuration && self.configuration.logger
end