diff --git a/libretranslate/app.py b/libretranslate/app.py index 73be457..52e818f 100644 --- a/libretranslate/app.py +++ b/libretranslate/app.py @@ -1022,6 +1022,9 @@ def create_app(args): # TODO: populate from available locales return request.accept_languages.best_match(['en', 'it']) + def gettext_escaped(*args, **kwargs): + return _(*args, **kwargs).replace("'", "\\'") + app.jinja_env.globals.update(_e=gettext_escaped) # Call factory function to create our blueprint swaggerui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL) diff --git a/libretranslate/templates/app.js.template b/libretranslate/templates/app.js.template index 1c61fa1..57dde04 100644 --- a/libretranslate/templates/app.js.template +++ b/libretranslate/templates/app.js.template @@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function(){ detectedLangText: "", - copyTextLabel: {{ _("Copy text") }}, + copyTextLabel: '{{ _e("Copy text") }}', suggestions: false, isSuggesting: false, @@ -69,7 +69,7 @@ document.addEventListener('DOMContentLoaded', function(){ } } } else { - self.error = "Cannot load /frontend/settings"; + self.error = '{{ _e("Cannot load %(url)s", url="/frontend/settings") }}'; self.loading = false; } }; diff --git a/libretranslate/translations/it/LC_MESSAGES/messages.po b/libretranslate/translations/it/LC_MESSAGES/messages.po new file mode 100644 index 0000000..9c65540 --- /dev/null +++ b/libretranslate/translations/it/LC_MESSAGES/messages.po @@ -0,0 +1,41 @@ +# Italian translations for PROJECT. +# Copyright (C) 2023 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2023. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2023-01-04 12:27-0500\n" +"PO-Revision-Date: 2023-01-04 12:27-0500\n" +"Last-Translator: FULL NAME \n" +"Language: it\n" +"Language-Team: it \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.11.0\n" + +#: libretranslate/app.py:57 +msgid "Invalid JSON format" +msgstr "" + +#: libretranslate/app.py:125 +msgid "Auto Detect" +msgstr "" + +#: libretranslate/templates/app.js.template:31 +msgid "Copy text" +msgstr "Copia testo" + +#: libretranslate/templates/app.js.template:72 +#, python-format +msgid "Cannot load %(url)s" +msgstr "Impossibile caricare' %(url)s" + +#: libretranslate/templates/index.html:6 +msgid "Free and Open Source Machine Translation API" +msgstr "API di traduzione automatica open source" +