diff --git a/CHANGES b/CHANGES index 1ae510f..1a24437 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ Version History =============== +Version 0.8.3 (Not yet released) +-------------------------------- +* Replace the (no longer working) Microsoft translation API with the new Azure Translator API (Fixes #200 and #201, thank you @svdvonde) + + Version 0.8.2 ------------- * Avoid UnicodeEncodeError when quering strings (#197, thanks @YAtOff) diff --git a/docs/settings.rst b/docs/settings.rst index 70aaf85..19cb4ec 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -6,7 +6,7 @@ Rosetta can be configured via the following parameters, to be defined in your pr * ``ROSETTA_MESSAGES_PER_PAGE``: Number of messages to display per page. Defaults to ``10``. * ``ROSETTA_ENABLE_TRANSLATION_SUGGESTIONS``: Enable AJAX translation suggestions. Defaults to ``False``. * ``YANDEX_TRANSLATE_KEY``: Translation suggestions from Yandex `Yandex.Translate API `_. To use this service you must first `obtain an AppID key `_, then specify the key here. Defaults to ``None``. -* ``AZURE_CLIENT_SECRET``: Translation suggestions using the Microsoft Azure API. To use this service, you must first `register for the service `_, then specify the 'Customer ID' and 'Primary Account Key' respectively, which you can find on your `account information page on Azure Marketplace `_. +* ``AZURE_CLIENT_SECRET``: Translation suggestions using the Microsoft Azure Translator API. To use this service, you must first `register for the service `_, and set ``AZURE_CLIENT_SECRET`` to either of the keys listed for your subscription. Defaults to ``None``. * ``ROSETTA_MESSAGES_SOURCE_LANGUAGE_CODE`` and ``ROSETTA_MESSAGES_SOURCE_LANGUAGE_NAME``: Change these if the source language in your PO files isn't English. Default to ``'en'`` and ``'English'`` respectively. * ``ROSETTA_WSGI_AUTO_RELOAD`` and ``ROSETTA_UWSGI_AUTO_RELOAD``: When running WSGI daemon mode, using ``mod_wsgi`` 2.0c5 or later, this setting controls whether the contents of the gettext catalog files should be automatically reloaded by the WSGI processes each time they are modified. For performance reasons, this setting should be disabled in production environments. Default to ``False``. * ``ROSETTA_EXCLUDED_APPLICATIONS``: Exclude applications defined in this list from being translated. Defaults to ``()``. diff --git a/rosetta/__init__.py b/rosetta/__init__.py index 2bef6f9..ba99082 100644 --- a/rosetta/__init__.py +++ b/rosetta/__init__.py @@ -1,4 +1,4 @@ -VERSION = (0, 8, 2) +VERSION = (0, 8, 3) default_app_config = "rosetta.apps.RosettaAppConfig" diff --git a/rosetta/conf/settings.py b/rosetta/conf/settings.py index d351de5..1d1adf7 100644 --- a/rosetta/conf/settings.py +++ b/rosetta/conf/settings.py @@ -11,11 +11,10 @@ ENABLE_TRANSLATION_SUGGESTIONS = getattr(settings, 'ROSETTA_ENABLE_TRANSLATION_S # Can be obtained for free here: https://translate.yandex.com/apikeys YANDEX_TRANSLATE_KEY = getattr(settings, 'YANDEX_TRANSLATE_KEY', None) -# Can be obtained for free here: https://ssl.bing.com/webmaster/Developers/AppIds/ -AZURE_CLIENT_ID = getattr(settings, 'AZURE_CLIENT_ID', None) +# See here to obtain a free Azure key and enable the Translator Text service: +# https://docs.microsoft.com/en-us/azure/cognitive-services/Translator/translator-text-how-to-signup AZURE_CLIENT_SECRET = getattr(settings, 'AZURE_CLIENT_SECRET', None) - # Displays this language beside the original MSGID in the admin MAIN_LANGUAGE = getattr(settings, 'ROSETTA_MAIN_LANGUAGE', None) diff --git a/rosetta/templates/rosetta/js/rosetta.js b/rosetta/templates/rosetta/js/rosetta.js index 22080ca..b6f00a6 100644 --- a/rosetta/templates/rosetta/js/rosetta.js +++ b/rosetta/templates/rosetta/js/rosetta.js @@ -8,7 +8,7 @@ google.setOnLoadCallback(function() { }); {% if rosetta_settings.ENABLE_TRANSLATION_SUGGESTIONS %} - {% if rosetta_settings.AZURE_CLIENT_ID and rosetta_settings.AZURE_CLIENT_SECRET or rosetta_settings.GOOGLE_TRANSLATE %} + {% if rosetta_settings.AZURE_CLIENT_SECRET %} $('a.suggest').click(function(e){ e.preventDefault(); var a = $(this); @@ -16,7 +16,7 @@ google.setOnLoadCallback(function() { var orig = $('.original .message', a.parents('tr')).html(); var trans=$('textarea',a.parent()); var sourceLang = '{{ rosetta_settings.MESSAGES_SOURCE_LANGUAGE_CODE }}'; - var destLang = '{{ rosetta_i18n_lang_code }}'; + var destLang = '{{ rosetta_i18n_lang_code_normalized }}'; orig = unescape(orig).replace(//g,'\n').replace(//,'').replace(/<\/code>/g,'').replace(/>/g,'>').replace(/</g,'<'); a.attr('class','suggesting').html('...'); @@ -36,9 +36,7 @@ google.setOnLoadCallback(function() { } ); }); - {% endif %} - - {% if rosetta_settings.YANDEX_TRANSLATE_KEY %} + {% elif rosetta_settings.YANDEX_TRANSLATE_KEY %} $('a.suggest').click(function(e){ e.preventDefault(); var a = $(this); diff --git a/rosetta/views.py b/rosetta/views.py index 25183d2..d4da0a5 100644 --- a/rosetta/views.py +++ b/rosetta/views.py @@ -533,6 +533,7 @@ class TranslationFormView(RosettaFileLevelMixin, TemplateView): 'rosetta_settings': rosetta_settings, 'rosetta_i18n_lang_name': rosetta_i18n_lang_name, 'rosetta_i18n_lang_code': self.language_id, + 'rosetta_i18n_lang_code_normalized': self.language_id.replace('_', '-'), 'rosetta_i18n_lang_bidi': rosetta_i18n_lang_bidi, 'rosetta_i18n_filter': self.msg_filter, 'rosetta_i18n_write': self.po_file_is_writable,