From 10001c5383dd56fdc535c16b1d8f91b7497e2fe3 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Fri, 26 Dec 2014 12:19:56 +0200 Subject: [PATCH 1/2] put translation javascript code in separate file --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/osem-translation.js | 6 ++++++ app/views/layouts/application.html.haml | 9 +-------- config/config.yml.example | 2 -- 4 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/osem-translation.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0370bfd9..3bf7d917 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -34,6 +34,7 @@ //= require osem-datepickers //= require osem-datatables //= require osem-tickets +//= require osem-translation $(document).ready(function() { $('a[disabled=disabled]').click(function(event){ diff --git a/app/assets/javascripts/osem-translation.js b/app/assets/javascripts/osem-translation.js new file mode 100644 index 00000000..2fd48cc7 --- /dev/null +++ b/app/assets/javascripts/osem-translation.js @@ -0,0 +1,6 @@ +window.liveSettings = { + api_key: '', + picker: "bottom-right", + detectlang: true, + autocollect: true +}; diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a2eb5b4c..92edf807 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -8,15 +8,8 @@ = stylesheet_link_tag "application", :media => "all" = javascript_include_tag "application" = csrf_meta_tags - :javascript - window.liveSettings = { - api_key: "<%= CONFIG['transifex_live_api_key'] %>", - picker: "bottom-right", - detectlang: true, - autocollect: true - }; = content_for(:script_head) - =# javascript_include_tag "//cdn.transifex.com/live.js" + = javascript_include_tag "//cdn.transifex.com/live.js" = yield(:head) %body diff --git a/config/config.yml.example b/config/config.yml.example index 412e109a..89a18daa 100644 --- a/config/config.yml.example +++ b/config/config.yml.example @@ -31,5 +31,3 @@ production: <<: *defaults # If you add more providers that do not require a key, you still have to create the 2 variables with sample data - - transifex_live_api_key: '' From 8686887695f263df778314c7c8b16bac874113e2 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 19 Jan 2015 18:37:07 +0200 Subject: [PATCH 2/2] read config var in js --- app/assets/javascripts/osem-translation.js | 2 +- config/config.yml.example | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/osem-translation.js b/app/assets/javascripts/osem-translation.js index 2fd48cc7..25fd36f5 100644 --- a/app/assets/javascripts/osem-translation.js +++ b/app/assets/javascripts/osem-translation.js @@ -1,5 +1,5 @@ window.liveSettings = { - api_key: '', + api_key: "CONFIG['transifex_live_api_key']", picker: "bottom-right", detectlang: true, autocollect: true diff --git a/config/config.yml.example b/config/config.yml.example index 89a18daa..903c455d 100644 --- a/config/config.yml.example +++ b/config/config.yml.example @@ -21,6 +21,9 @@ defaults: &defaults ichain: enabled: false + # Enter your key, provided by transifex live settings, in the quotes + transifex_live_api_key: '' + development: <<: *defaults