Repository: pypi/warehouse

Issue:
Handle Translation of the <title> tag
Currently we can't really translate the `<title>` tag because our block doesn't allow a template to add a l20n ID to it.



Discussion:
Gonna drop this out of the Become PyPI, since we're not going to have any translations for launch we can figure this out later.


Resolving patch:
diff --git a/warehouse/i18n/__init__.py b/warehouse/i18n/__init__.py
--- a/warehouse/i18n/__init__.py
+++ b/warehouse/i18n/__init__.py
@@ -35,7 +35,3 @@ def includeme(config):
         "format_rfc822_datetime",
         "warehouse.i18n.filters:format_rfc822_datetime",
     )
-
-    # Register our utility functions with Jinja2
-    jglobals = config.get_settings().setdefault("jinja2.globals", {})
-    jglobals.setdefault("l20n", "warehouse.i18n.l20n:l20n")
diff --git a/warehouse/i18n/l20n.py b/warehouse/i18n/l20n.py
deleted file mode 100644
--- a/warehouse/i18n/l20n.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import jinja2
-
-from markupsafe import Markup as M  # noqa
-
-from warehouse.filters import tojson
-
-
-_L20N_TEMPLATE = jinja2.Template(
-    'data-l10n-id="{{ tid }}"'
-    '{% if data %} data-l10n-args="{{ data }}"{% endif %}',
-    autoescape=True,
-)
-
-
-def l20n(tid, **kwargs):
-    data = tojson(kwargs) if kwargs else None
-    return M(_L20N_TEMPLATE.render(tid=tid, data=data))


Test patch:
diff --git a/tests/unit/i18n/test_init.py b/tests/unit/i18n/test_init.py
--- a/tests/unit/i18n/test_init.py
+++ b/tests/unit/i18n/test_init.py
@@ -46,7 +46,4 @@ def test_includeme():
             "format_rfc822_datetime":
                 "warehouse.i18n.filters:format_rfc822_datetime",
         },
-        "jinja2.globals": {
-            "l20n": "warehouse.i18n.l20n:l20n",
-        },
     }
diff --git a/tests/unit/i18n/test_l20n.py b/tests/unit/i18n/test_l20n.py
deleted file mode 100644
--- a/tests/unit/i18n/test_l20n.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import pytest
-
-from warehouse.i18n import l20n
-
-
-@pytest.mark.parametrize(
-    ("tid", "args", "expected"),
-    [
-        ("foo", {}, 'data-l10n-id="foo"'),
-        (
-            "bar",
-            {"thing": "other"},
-            'data-l10n-id="bar" '
-            'data-l10n-args="{&#34;thing&#34;:&#34;other&#34;}"',
-        ),
-    ],
-)
-def test_l20n(tid, args, expected):
-    assert l20n.l20n(tid, **args) == expected