From 16c34c206da8acb119eaecd4c1c5a1524a1b83e6 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 27 Aug 2014 14:12:11 +1000 Subject: [PATCH] FEATURE: verbose localization option --- .../initializers/verbose-localization.js.es6 | 25 +++++++++++++++++++ config/locales/server.en.yml | 1 + config/site_settings.yml | 3 +++ 3 files changed, 29 insertions(+) create mode 100644 app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 diff --git a/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 b/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 new file mode 100644 index 00000000000..8f27beb4691 --- /dev/null +++ b/app/assets/javascripts/discourse/initializers/verbose-localization.js.es6 @@ -0,0 +1,25 @@ +export default { + name: 'verbose-localization', + initialize: function() { + + if(Discourse.SiteSettings.verbose_localization){ + var counter = 0; + var keys = {}; + var t = I18n.t; + + + I18n.t = I18n.translate = function(scope, value){ + var current = keys[scope]; + if(!current) { + current = keys[scope] = ++counter; + var message = "Translation #" + current + ": " + scope; + if (!_.isEmpty(value)) { + message += ", parameters: " + JSON.stringify(value); + } + window.console.log(message); + } + return t.apply(I18n, [scope, value]) + " (t" + current + ")"; + }; + } + } +}; diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 838f0784980..f5cd7067e56 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -799,6 +799,7 @@ en: s3_backup_bucket: "The remote bucket to hold backups. WARNING: Make sure it is a private bucket." active_user_rate_limit_secs: "How frequently we update the 'last_seen_at' field, in seconds" + verbose_localization: "Show extended localization tips in the UI" previous_visit_timeout_hours: "How long a visit lasts before we consider it the 'previous' visit, in hours" rate_limit_create_topic: "After creating a topic, users must wait (n) seconds before creating another topic." diff --git a/config/site_settings.yml b/config/site_settings.yml index 72a13e9c6fa..4d5425a4efd 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -594,6 +594,9 @@ developer: client: true default: 5 active_user_rate_limit_secs: 60 + verbose_localization: + default: false + client: true embedding: embeddable_host: ''