mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-03-16 21:30:24 +00:00
Replace the (no longer working) Microsoft translation API with the new Azure Translator API (Fixes #200 and #201, thank you @svdvonde)
This commit is contained in:
parent
3b3d63eecd
commit
e3dd1f9b91
6 changed files with 13 additions and 10 deletions
5
CHANGES
5
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)
|
||||
|
|
|
|||
|
|
@ -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 <http://api.yandex.com/translate/>`_. To use this service you must first `obtain an AppID key <http://api.yandex.com/key/form.xml?service=trnsl>`_, 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 <https://datamarket.azure.com/dataset/5BA839F1-12CE-4CCE-BF57-A49D98D29A44>`_, then specify the 'Customer ID' and 'Primary Account Key' respectively, which you can find on your `account information page on Azure Marketplace <https://datamarket.azure.com/account?lang=en>`_.
|
||||
* ``AZURE_CLIENT_SECRET``: Translation suggestions using the Microsoft Azure Translator API. To use this service, you must first `register for the service <https://docs.microsoft.com/en-us/azure/cognitive-services/Translator/translator-text-how-to-signup>`_, 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 ``()``.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
VERSION = (0, 8, 2)
|
||||
VERSION = (0, 8, 3)
|
||||
default_app_config = "rosetta.apps.RosettaAppConfig"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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(/<br\s?\/?>/g,'\n').replace(/<code>/,'').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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue