Module: Localeapp
- Defined in:
- lib/localeapp/rails/mimic_rails_missing_translation_display.rb,
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/copy.rb,
lib/localeapp/cli/pull.rb,
lib/localeapp/cli/push.rb,
lib/localeapp/i18n_shim.rb,
lib/localeapp/sync_file.rb,
lib/localeapp/api_caller.rb,
lib/localeapp/cli/daemon.rb,
lib/localeapp/cli/remove.rb,
lib/localeapp/cli/rename.rb,
lib/localeapp/cli/update.rb,
lib/localeapp/cli/command.rb,
lib/localeapp/cli/install.rb,
lib/localeapp/key_checker.rb,
lib/localeapp/routes/base.rb,
lib/localeapp/routes/copy.rb,
lib/localeapp/configuration.rb,
lib/localeapp/routes/export.rb,
lib/localeapp/routes/import.rb,
lib/localeapp/routes/remove.rb,
lib/localeapp/routes/rename.rb,
lib/localeapp/routes/projects.rb,
lib/localeapp/rails/controller.rb,
lib/localeapp/exception_handler.rb,
lib/localeapp/routes/translations.rb,
lib/localeapp/missing_translations.rb,
lib/localeapp/routes/missing_translations.rb,
lib/localeapp/rails/force_exception_handler_in_translation_helper.rb
Overview
Rails 3.2.16 and 4.0.2 introduced a new way of displaying missing translation : they now wrap them in a <span> element with useful class and title
github.com/rails/rails/commit/78790e4bceedc632cb40f9597792d7e27234138a
Defined Under Namespace
Modules: ApiCall, CLI, ForceExceptionHandlerInTranslationHelper, MimicRailsMissingTranslationDisplay, Rails, Routes, TranslationHelperRails41MonkeyPatch Classes: APIResponseError, ApiCaller, Configuration, ExceptionHandler, KeyChecker, LocaleappError, MissingApiKey, MissingTranslationRecord, MissingTranslations, Poller, PotentiallyInsecureYaml, RuntimeError, Sender, SyncData, SyncFile, Updater
Constant Summary collapse
- API_VERSION =
"1"
- LOG_PREFIX =
"** [Localeapp] "
- ENV_FILE_PATH =
".env".freeze
- VERSION =
"3.1.0"
- I18nMissingTranslationException =
I18n::MissingTranslationData
Class Attribute Summary collapse
-
.configuration ⇒ Object
An Localeapp configuration object.
-
.missing_translations ⇒ Object
readonly
The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend.
-
.poller ⇒ Object
The poller object is responsible for retrieving data for the Localeapp server.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Localeapp server.
-
.updater ⇒ Object
The updater object is responsible for merging translations into the i18n backend.
Class Method Summary collapse
-
.configure {|configuration| ... } ⇒ Object
Localeapp.configure do |config| config.api_key = ‘1234567890abcdef’ end.
- .debug(message) ⇒ Object
- .default_config_file_paths ⇒ Object
- .env_file_path ⇒ Object
- .has_config_file? ⇒ Boolean
- .load_yaml(contents) ⇒ Object
- .load_yaml_file(filename) ⇒ Object
-
.log(message) ⇒ Object
Writes out the given message to the #logger.
- .log_with_time(message) ⇒ Object
-
.logger ⇒ Object
Look for the Rails logger currently defined.
- .yaml_data(content, locale_key = nil) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
An Localeapp configuration object.
43 44 45 |
# File 'lib/localeapp.rb', line 43 def configuration @configuration end |
.missing_translations ⇒ Object (readonly)
The missing_translations object is responsible for keeping track of missing translations that will be sent to the backend
56 57 58 |
# File 'lib/localeapp.rb', line 56 def missing_translations @missing_translations end |
.poller ⇒ Object
The poller object is responsible for retrieving data for the Localeapp server
49 50 51 |
# File 'lib/localeapp.rb', line 49 def poller @poller end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Localeapp server.
46 47 48 |
# File 'lib/localeapp.rb', line 46 def sender @sender end |
.updater ⇒ Object
The updater object is responsible for merging translations into the i18n backend
52 53 54 |
# File 'lib/localeapp.rb', line 52 def updater @updater end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
Localeapp.configure do |config|
config.api_key = '1234567890abcdef'
end
81 82 83 84 85 86 87 88 |
# File 'lib/localeapp.rb', line 81 def configure self.configuration ||= Configuration.new yield(configuration) if block_given? self.sender = Sender.new self.poller = Poller.new self.updater = Updater.new @missing_translations = MissingTranslations.new end |
.debug(message) ⇒ Object
68 69 70 |
# File 'lib/localeapp.rb', line 68 def debug() logger.debug(LOG_PREFIX + ) if logger end |
.default_config_file_paths ⇒ Object
94 95 96 97 98 99 |
# File 'lib/localeapp.rb', line 94 def default_config_file_paths [ File.join(Dir.pwd, '.localeapp', 'config.rb'), File.join(Dir.pwd, 'config', 'initializers', 'localeapp.rb') ] end |
.env_file_path ⇒ Object
122 123 124 |
# File 'lib/localeapp.rb', line 122 def env_file_path ENV_FILE_PATH end |
.has_config_file? ⇒ Boolean
90 91 92 |
# File 'lib/localeapp.rb', line 90 def has_config_file? default_config_file_paths.any? { |path| File.exist?(path) } end |
.load_yaml(contents) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/localeapp.rb', line 101 def load_yaml(contents) if Localeapp.configuration.raise_on_insecure_yaml raise Localeapp::PotentiallyInsecureYaml if contents =~ /!ruby\// end YAML.load(contents) end |
.load_yaml_file(filename) ⇒ Object
109 110 111 |
# File 'lib/localeapp.rb', line 109 def load_yaml_file(filename) load_yaml(File.read(filename)) end |
.log(message) ⇒ Object
Writes out the given message to the #logger
60 61 62 |
# File 'lib/localeapp.rb', line 60 def log() logger.info LOG_PREFIX + if logger end |
.log_with_time(message) ⇒ Object
64 65 66 |
# File 'lib/localeapp.rb', line 64 def log_with_time() log [Time.now.to_i, ].join(' - ') end |
.logger ⇒ Object
Look for the Rails logger currently defined
73 74 75 |
# File 'lib/localeapp.rb', line 73 def logger self.configuration && self.configuration.logger end |
.yaml_data(content, locale_key = nil) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/localeapp.rb', line 113 def yaml_data(content, locale_key = nil) yaml_data = Localeapp.load_yaml(content) if locale_key raise "Could not find given locale" unless yaml_data and yaml_data[locale_key] yaml_data = {locale_key => yaml_data[locale_key]} end yaml_data end |