diff --git a/app/assets/javascripts/user/application.js.erb b/app/assets/javascripts/user/application.js.erb index c952fa90..9f38e5ff 100644 --- a/app/assets/javascripts/user/application.js.erb +++ b/app/assets/javascripts/user/application.js.erb @@ -1,6 +1,6 @@ // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. -// +// a // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // @@ -68,10 +68,13 @@ var $translations = { moved_to_another_table: 'The table is changed.', confirmation_title: 'Move to another table?', confirmation_body: 'Are you sure you want to move to another table?' - } + }, + models: <%= I18n.t('activemodel.models', locale: :en).to_json %>, + attributes: <%= I18n.t('activemodel.attributes', locale: :en).to_json %>, + <%= I18n.t('user', locale: :en).to_json[1..-2] %> }, nl: { - messages: <%= I18n.t('messages', locale: :en).to_json %>, + messages: <%= I18n.t('messages', locale: :nl).to_json %>, confirmations: { }, list_needs_help: { @@ -99,7 +102,10 @@ var $translations = { moved_to_another_table: 'De tafel is gewijzigd.', confirmation_title: 'Naar een andere tafel verhuizen?', confirmation_body: 'Ben je aan een andere tafel gaan zitten?' - } + }, + models: <%= I18n.t('activemodel.models', locale: :nl).to_json %>, + attributes: <%= I18n.t('activemodel.attributes', locale: :nl).to_json %>, + <%= I18n.t('user', locale: :nl).to_json[1..-2] %> } } function redirect_to(mapping, variables){ @@ -156,6 +162,7 @@ function getUrlVars() { return $url_vars; } $(function(){ + $locale = QMobile.locale(); if(getUrlVars().message){ var container = $('.alert-success'); // Prepend messages. if there is no path/period specified @@ -170,3 +177,8 @@ $(function(){ } $('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))}) }); +function setLocale(locale){ + QMobile.setLocale(locale); + $locale = locale; + $('[data-t]').each(function(){$(this).text(t($(this).attr('data-t')))}) +} diff --git a/app/views/layouts/phone.html.slim b/app/views/layouts/phone.html.slim index af8377ca..0a915209 100644 --- a/app/views/layouts/phone.html.slim +++ b/app/views/layouts/phone.html.slim @@ -20,7 +20,7 @@ html lang="en" var data_host = '#{Rails.env == 'development' ? 'http://localhost:3000' : 'http://data.qwaiter.com' }'; //var data_host = 'http://localhost:3000'; //data_host = 'http://192.168.1.148:3000'; - var $locale = '#{I18n.locale}'; + var $locale = 'en'; var $url_vars = null; // Dummy holder when Qmobile object is not supplied by the mobile phone var QMobile, Qwaiter, Quser; @@ -37,7 +37,9 @@ html lang="en" root_url: function(){return 'file:///Users/bterkuile/Documents/workspace/Qwaiter/assets'}, root_url: function(){return ''}, goHome: function(){ redirect_to('user_root')}, - connection_problem: function(){alert('There is a problem connecting to the server')} + connection_problem: function(){alert('There is a problem connecting to the server')}, + locale: function(){ return $locale || ($locale = 'en')}, + setLocale: function(locale){$locale = locale; return locale} }); //QMobile.setAuthToken('i5brDZ1HS1okoEq3pMyh'); diff --git a/app/views/user/active_list.html.slim b/app/views/user/active_list.html.slim index d546f347..9d3a98e3 100644 --- a/app/views/user/active_list.html.slim +++ b/app/views/user/active_list.html.slim @@ -1,7 +1,7 @@ .page-header .table-number .supplier-name - h4= t('user.active_list.title', list: List.model_name.human) + h4 data-t="active_list.title" = t('user.active_list.title', list: List.model_name.human) .form-actions = link_to t('helpers.links.place_order'), user_list_products_path, class: ['user-top-button'], id: 'place-order-on-list' span#list-needs-payment-button.user-top-button @@ -10,8 +10,8 @@ table#active-list-table.table thead tr - th= Order.model_name.human - th.currency= Product.human_attribute_name(:price) + th data-t="models.order" = Order.model_name.human + th.currency data-t="attributes.product.price" = Product.human_attribute_name(:price) tbody tr td colspan=2 = slider_image diff --git a/app/views/user/list_history.html.slim b/app/views/user/list_history.html.slim index 5c02408d..ab038fb2 100644 --- a/app/views/user/list_history.html.slim +++ b/app/views/user/list_history.html.slim @@ -1,4 +1,5 @@ -.page-header= title 'User list history' +.page-header + h2 data-t="list_history.title" = t('user.list_history.title') nav.pagination ul#list-history-container - content_for :footer do diff --git a/app/views/user/list_products.html.slim b/app/views/user/list_products.html.slim index 22f0c22b..9affe714 100644 --- a/app/views/user/list_products.html.slim +++ b/app/views/user/list_products.html.slim @@ -1,7 +1,7 @@ .page-header .table-number .supplier-name - h4= t('user.show_products.title', products: Product.model_name.human_plural) + h4 data-t="show_products.title" = t('user.show_products.title', products: Product.model_name.human_plural) .form-actions = link_to t('helpers.links.show_active_list', list: List.model_name.human), user_active_list_path, class: ['user-top-button'], id: 'show-active-list' span#list-needs-payment-button.user-top-button @@ -14,9 +14,9 @@ table#active-order-table.table.hide thead tr - th= Product.model_name.human + th data-t="models.product"= Product.model_name.human th # - th.currency Total + th.currency data-t="basket.total"= t('user.basket.total') th tbody tfoot diff --git a/config/locales/en.yml b/config/locales/en.yml index 273720a9..ab577690 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -108,10 +108,12 @@ en: user: active_list: - title: Active %{list} + title: Active list needs_payment: Check please! history_list: - title: Closed %{list} + title: Closed list + list_history: + title: Closed lists show_products: # The title gets products: Product.model_name.human_plural that can be used: e.g.: Showing %{products} title: Menu @@ -124,6 +126,8 @@ en: scan_qr: Scan qr code show_active_list: Show my orders show_active_list_products: Go to the menu + basket: + total: Total section: first_section_title: Room manage_tables: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 42653434..735dee53 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -121,10 +121,12 @@ nl: user: active_list: - title: Actieve %{list} + title: Actieve lijst needs_payment: Rekening vragen! history_list: - title: Afgesloten %{list} + title: Afgesloten lijst + list_history: + title: Afgesloten lijsten show_products: # The title gets products: Product.model_name.human_plural that can be used: e.g.: Showing %{products} title: Menu @@ -137,6 +139,8 @@ nl: scan_qr: Scan qr code show_active_list: Toon mijn bestellingen show_active_list_products: Ga naar het menu + basket: + total: Totaal section: first_section_title: Ruimte manage_tables: