From 05dee1b5f68d720b2540b99bf79cefc251139ec7 Mon Sep 17 00:00:00 2001
From: Thomas JUND <tjund@entrouvert.com>
Date: Wed, 16 Jun 2021 16:14:11 +0200
Subject: [PATCH] card infos cell form: add i18n (#52073)

---
 .../wcs/manager/card-infos-cell-form.html     | 47 ++++++++++++-------
 combo/manager/static/js/combo.manager.js      |  6 +--
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/combo/apps/wcs/templates/combo/wcs/manager/card-infos-cell-form.html b/combo/apps/wcs/templates/combo/wcs/manager/card-infos-cell-form.html
index 98dac4f3..1913ed9b 100644
--- a/combo/apps/wcs/templates/combo/wcs/manager/card-infos-cell-form.html
+++ b/combo/apps/wcs/templates/combo/wcs/manager/card-infos-cell-form.html
@@ -1,4 +1,5 @@
 {% extends "combo/cell_form.html" %}
+{% load i18n %}
 
 {% block cell-form %}
 {{ block.super }}
@@ -8,15 +9,15 @@
 {# Grille de personalisation #}
 <div class="wcs-cards-cell--grid">
   <div class="wcs-cards-cell--grid-options">
-    <span class="wcs-cards-cell--grid-layout-label">auto</span>
+    <span class="wcs-cards-cell--grid-layout-label">{% trans "Automatic" %}</span>
     <a role="button" class="wcs-cards-cell--grid-layout-btn">
-      Modifier
+      {% trans "Edit" %}
     </a>
   </div>
   <div class="wcs-cards-cell--grid-cells">
   </div>
   <div class="wcs-cards-cell--grid-buttons">
-    <button type="button" class="wcs-cards-cell--add-grid-cell-btn">Ajouter</button>
+    <button type="button" class="wcs-cards-cell--add-grid-cell-btn">{% trans "Add" %}</button>
   </div>
 </div>
 
@@ -24,12 +25,12 @@
 <script type="text/template" class="wcs-cards-cell--grid-form-tpl">
   <form>
     <p>
-      Disposition
+      {% trans "Layout" %}
       <select name="grid-layout">
-        <option value="fx-grid--auto">auto</option>
-        <option value="fx-grid">1 colonne</option>
-        <option value="fx-grid--t2">2 colonnes</option>
-        <option value="fx-grid--t3">3 colonnes</option>
+        <option value="fx-grid--auto">{% trans "Automatic" %}</option>
+        <option value="fx-grid">{% trans "1 column" %}</option>
+        <option value="fx-grid--t2">{% trans "2 columns" %}</option>
+        <option value="fx-grid--t3">{% trans "3 columns" %}</option>
       </select>
     </p>
   </form>
@@ -38,26 +39,26 @@
   <form>
     <p>
       <label>
-        Champ
+        {% trans "Field" %}
         <select name="card_field_varname"></select>
       </label>
     </p>
     <p>
       <label>
-        Afficher
+        {% trans "Display" %}
         <select name="card_field_elements">
-          <option value="key,value">Label & valeur</option>
-          <option value="key">Label uniquement</option>
-          <option value="value">Valeur uniquement</option>
-          <option value="title">Titre</option>
+          <option value="key,value">{% trans "Label & Value" %}</option>
+          <option value="key">{% trans "Label only" %}</option>
+          <option value="value">{% trans "Value only" %}</option>
+          <option value="title">{% trans "Title" %}</option>
         </select>
       </label>
     </p>
     <p>
       <label>
-        Taille
+        {% trans "Size" %}
         <select name="cell_size">
-          <option value="">auto</option>
+          <option value="">{% trans "Automatic" %}</option>
           <option value="size--1-1">1/1</option>
           <option value="size--t1-2">1/2</option>
           <option value="size--t1-3">1/3</option>
@@ -71,10 +72,20 @@
   <div class="wcs-cards-cell--grid-cell">
     <div class="wcs-cards-cell--grid-cell-content"></div>
     <div class="wcs-cards-cell--grid-cell-buttons">
-      <a role="button" class="wcs-cards-cell--grid-cell-edit">Modifier</a>
-      <a role="button" class="wcs-cards-cell--grid-cell-delete">Supprimer</a>
+      <a role="button" class="wcs-cards-cell--grid-cell-edit">{% trans "Edit" %}</a>
+      <a role="button" class="wcs-cards-cell--grid-cell-delete">{% trans "Delete" %}</a>
     </div>
   </div>
 </script>
+
+<script>
+window.combo_i18n = {
+  automatic: "{% trans 'Automatic' %}",
+  cancel: "{% trans 'Cancel' %}",
+  edit: "{% trans 'Edit' %}",
+  add: "{% trans 'Add' %}"
+};
+</script>
+</script>
 {% endif %}
 {% endblock %}
\ No newline at end of file
diff --git a/combo/manager/static/js/combo.manager.js b/combo/manager/static/js/combo.manager.js
index d20ede5a..2cd1759e 100644
--- a/combo/manager/static/js/combo.manager.js
+++ b/combo/manager/static/js/combo.manager.js
@@ -405,7 +405,7 @@ const Card_cell_custom = function(cell) {
   this.cell = cell;
   this.gridShema_default = {
     "grid_class": "fx-grid--auto",
-    "grid_layout_label": "auto",
+    "grid_layout_label": window.combo_i18n.automatic,
     "cells": []
   }
   this.init();
@@ -564,7 +564,7 @@ Card_cell_custom.prototype = {
     this.grid_cell_form.display.value = grid_cell.dataset.display;
     const cell_id = $(grid_cell).index();
     const grid_cell_shema = this.gridShema.cells[cell_id];
-    this.grid_cell__form_dialog("Modifier", function(form_datas){
+    this.grid_cell__form_dialog(window.combo_i18n.edit, function(form_datas){
       const grid_cell_shema_mod = _self.grid_cell__set_shema(form_datas, grid_cell_shema);
       _self.grid_cell__set(grid_cell, grid_cell_shema_mod);
       $(_self.cell).trigger("custom_cell:change");
@@ -626,7 +626,7 @@ Card_cell_custom.prototype = {
     })
     // Add grid cell Btn click
     $(this.add_grid_cell_btn).on('click', function() {
-      _self.grid_cell__form_dialog("Ajouter", _self.grid_cell__add_shema.bind(_self));
+      _self.grid_cell__form_dialog(window.combo_i18n.add, _self.grid_cell__add_shema.bind(_self));
     });
     // Grid cells sortable
     $(_self.grid_wrapper).sortable({
-- 
2.20.1

