Repository: 12rambau/sepal_ui

Issue:
_protected_keys are not raising error when used in translator
`protected_keys` are not raising errors when used in a json translation file. It is also happening with the "`FORBIDDEN_KEYS`" when are used in nested levels.

To reproduce...

```Python
# set up the appropriate keys for each language
keys = {
    "en": {
        "find_target": "A key", 
        "test_key": "Test key", 
        "nested" : {
            "items" : {
                "_target" : "value"
            },
        },
        "merge_dict" : "value"
    },
    "fr": {
        "a_key": "Une clef", 
        "test_key": "Clef de test"
    },
    "fr-FR": {
        "a_key": "Une clef", 
        "test_key": "Clef de test"
    },
    "es": {
        "a_key": "Una llave"
    },
}

# generate the tmp_dir in the test directory
tmp_dir = Path(".").parent / "data" / "messages"
tmp_dir.mkdir(exist_ok=True, parents=True)

# create the translation files
for lan, d in keys.items():
    folder = tmp_dir / lan
    folder.mkdir(exist_ok=True)
    (folder / "locale.json").write_text(json.dumps(d, indent=2))

```
When the object is being instantiated, there's not any error to alert that the nested key "`_target`" cannot be used, nor the "`find_target`" in the first level.

```Python
translator = Translator(tmp_dir, "en")
```

Discussion:

Patch:
diff --git a/sepal_ui/translator/translator.py b/sepal_ui/translator/translator.py
index 1ad14c98..ea647223 100644
--- a/sepal_ui/translator/translator.py
+++ b/sepal_ui/translator/translator.py
@@ -65,7 +65,7 @@ class Translator(Box):
 
         # check if forbidden keys are being used
         # this will raise an error if any
-        [self.search_key(ms_dict, k) for k in FORBIDDEN_KEYS]
+        [self.search_key(ms_dict, k) for k in FORBIDDEN_KEYS + self._protected_keys]
 
         # # unpack the json as a simple namespace
         ms_json = json.dumps(ms_dict)
@@ -130,8 +130,7 @@ class Translator(Box):
 
         return (target, lang)
 
-    @staticmethod
-    def search_key(d, key):
+    def search_key(self, d, key):
         """
         Search a specific key in the d dictionary and raise an error if found
 
@@ -144,7 +143,9 @@ class Translator(Box):
             msg = f"You cannot use the key {key} in your translation dictionary"
             raise Exception(msg)
 
-        return
+        for k, v in d.items():
+            if isinstance(v, dict):
+                return self.search_key(v, key)
 
     @classmethod
     def sanitize(cls, d):


Test patch:
diff --git a/tests/test_Translator.py b/tests/test_Translator.py
index 3c3704af..865bcd84 100644
--- a/tests/test_Translator.py
+++ b/tests/test_Translator.py
@@ -40,17 +40,30 @@ class TestTranslator:
         assert translator._target == "fr-FR"
         assert translator._match is True
 
+        # Check that is failing when using
+
         return
 
     def test_search_key(self):
 
+        # generate the tmp_dir in the test directory
+        tmp_dir = Path(__file__).parent / "data" / "messages"
+        tmp_dir.mkdir(exist_ok=True, parents=True)
+
         # assert that having a wrong key  at root level
         # in the json will raise an error
         key = "toto"
         d = {"toto": {"a": "b"}, "c": "d"}
 
         with pytest.raises(Exception):
-            Translator.search_key(d, key)
+            Translator(tmp_dir).search_key(d, key)
+
+        # Search when the key is in a deeper nested level
+        key = "nested_key"
+        d = {"en": {"level1": {"level2": {"nested_key": "value"}}}}
+
+        with pytest.raises(Exception):
+            Translator(tmp_dir).search_key(d, key)
 
         return