From e217f964549b92ddc9c594cf33f286f96db01530 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 31 Aug 2017 13:39:37 +0200 Subject: [PATCH 1/2] Use Rails lazy lookup for translation keys See "lazy" lookup in http://guides.rubyonrails.org/i18n.html#abstracting-localized-code --- app/views/admin/order_cycles/_exchange_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index 1275103a50..c8fbf28cc1 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -15,10 +15,10 @@ {{ exchange.tags.length }} %td.collection-details = text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', 'required' => 'required', 'placeholder' => t('.pickup_time_placeholder'), 'ng-model' => 'exchange.pickup_time', 'ng-disabled' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator', 'maxlength' => 35 - %span.icon-question-sign{'ofn-with-tip' => t('admin.order_cycles.edit.pickup_time_tip')} + %span.icon-question-sign{'ofn-with-tip' => t('.pickup_time_tip')} %br/ = text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', 'placeholder' => t('.pickup_instructions_placeholder'), 'ng-model' => 'exchange.pickup_instructions', 'ng-disabled' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator' - %span.icon-question-sign{'ofn-with-tip' => t('admin.order_cycles.edit.pickup_instructions_tip')} + %span.icon-question-sign{'ofn-with-tip' => t('.pickup_instructions_tip')} %td.fees %ol{ ng: { show: 'enterprises[exchange.enterprise_id].managed || order_cycle.viewing_as_coordinator' } } %li{'ng-repeat' => 'enterprise_fee in exchange.enterprise_fees'} From 96e31235da3b3fdf20e5e6d0f9fe909b6f664b5c Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Thu, 31 Aug 2017 13:40:53 +0200 Subject: [PATCH 2/2] Replace hardcoded strings with i18n keys --- .../admin/order_cycles/_add_exchange_form.html.haml | 2 +- app/views/admin/order_cycles/_exchange_form.html.haml | 4 ++-- app/views/admin/order_cycles/edit.html.haml | 4 ++-- config/locales/en.yml | 10 ++++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/views/admin/order_cycles/_add_exchange_form.html.haml b/app/views/admin/order_cycles/_add_exchange_form.html.haml index f9f64ab631..36c8e804af 100644 --- a/app/views/admin/order_cycles/_add_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_add_exchange_form.html.haml @@ -3,4 +3,4 @@ {{ enterprise.name }} = "{{ enterprise.issues_summary_#{type} ? '('+enterprise.issues_summary_#{type}+')' : '' }}" -= f.submit "Add #{type}", 'ng-click' => "add#{type.capitalize}($event)", 'ng-disabled' => "!new_#{type}_id || !OrderCycle.novel#{type.capitalize}(new_#{type}_id)" += f.submit t(".add_#{type}"), 'ng-click' => "add#{type.capitalize}($event)", 'ng-disabled' => "!new_#{type}_id || !OrderCycle.novel#{type.capitalize}(new_#{type}_id)" diff --git a/app/views/admin/order_cycles/_exchange_form.html.haml b/app/views/admin/order_cycles/_exchange_form.html.haml index c8fbf28cc1..9209c4cf77 100644 --- a/app/views/admin/order_cycles/_exchange_form.html.haml +++ b/app/views/admin/order_cycles/_exchange_form.html.haml @@ -6,7 +6,7 @@ {{ enterpriseTotalVariants(enterprises[exchange.enterprise_id]) }} - else {{ (incomingExchangeVariantsFor(exchange.enterprise_id)).length }} - selected + = t('.selected') - if type == 'supplier' %td.receival-details = text_field_tag 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', '', 'id' => 'order_cycle_incoming_exchange_{{ $index }}_receival_instructions', 'placeholder' => t('.receival_instructions_placeholder'), 'ng-model' => 'exchange.receival_instructions' @@ -28,7 +28,7 @@ = link_to 'Remove', '#', {'id' => 'order_cycle_{{ exchangeDirection(exchange) }}_exchange_{{ $parent.$index }}_enterprise_fees_{{ $index }}_remove', 'ng-click' => 'removeExchangeFee($event, exchange, $index)'} - = f.submit 'Add fee', 'ng-click' => 'addExchangeFee($event, exchange)', 'ng-hide' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator' + = f.submit t('.add_fee'), 'ng-click' => 'addExchangeFee($event, exchange)', 'ng-hide' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator' %td.actions %a{'ng-click' => 'removeExchange($event, exchange)', :class => "icon-trash no-text remove-exchange"} diff --git a/app/views/admin/order_cycles/edit.html.haml b/app/views/admin/order_cycles/edit.html.haml index ddfd10b38a..ed7b93571a 100644 --- a/app/views/admin/order_cycles/edit.html.haml +++ b/app/views/admin/order_cycles/edit.html.haml @@ -12,7 +12,7 @@ - if can? :notify_producers, @order_cycle %li - = button_to "Notify producers", main_app.notify_producers_admin_order_cycle_path, :id => 'admin_notify_producers', :confirm => t(:are_you_sure) + = button_to t(:notify_producers), main_app.notify_producers_admin_order_cycle_path, :id => 'admin_notify_producers', :confirm => t(:are_you_sure) %li %button#toggle_settings{ onClick: 'toggleSettings()' } = t('.advanced_settings') @@ -30,7 +30,7 @@ %save-bar{ dirty: "order_cycle_form.$dirty", persist: "true" } %input.red{ type: "button", value: t(:update), ng: { click: "submit($event, null)", disabled: "!order_cycle_form.$dirty || order_cycle_form.$invalid" } } %input.red{ type: "button", value: t('.update_and_close'), ng: { click: "submit($event, '#{main_app.admin_order_cycles_path}')", disabled: "!order_cycle_form.$dirty || order_cycle_form.$invalid" } } - %input{ type: "button", ng: { value: "order_cycle_form.$dirty ? 'Cancel' : 'Close'", click: "cancel('#{main_app.admin_order_cycles_path}')" } } + %input{ type: "button", ng: { value: "order_cycle_form.$dirty ? '#{t(:cancel)}' : '#{t(:close)}'", click: "cancel('#{main_app.admin_order_cycles_path}')" } } - if order_cycles_simple_form = render 'simple_form', f: f diff --git a/config/locales/en.yml b/config/locales/en.yml index 9c1d7e538a..18db5812dc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -602,12 +602,17 @@ en: advanced_settings: Advanced Settings update_and_close: Update and Close choose_products_from: 'Choose Products From:' - pickup_time_tip: When orders from this OC will be ready for the customer - pickup_instructions_tip: These instructions are shown to customers after they complete an order exchange_form: + pickup_time_tip: When orders from this OC will be ready for the customer pickup_instructions_placeholder: "Pick-up instructions" + pickup_instructions_tip: These instructions are shown to customers after they complete an order pickup_time_placeholder: "Ready for (ie. Date / Time)" receival_instructions_placeholder: "Receival instructions" + add_fee: 'Add fee' + selected: 'selected' + add_exchange_form: + add_supplier: 'Add supplier' + add_distributor: 'Add distributor' advanced_settings: title: Advanced Settings choose_product_tip: You can opt to restrict all available products (both incoming and outgoing), to only those in %{inventory}'s inventory. @@ -1507,6 +1512,7 @@ Please follow the instructions there to make your enterprise visible on the Open new_order_cycles: "New Order Cycles" new_order_cycle: "New Order Cycle" select_a_coordinator_for_your_order_cycle: "Select a coordinator for your order cycle" + notify_producers: 'Notify producers' edit_order_cycle: "Edit Order Cycle" roles: "Roles" update: "Update"