Контекстный перевод для веб-приложений

Crowdin In-Context tool allows to translate texts directly within the actual web application. In such a way, the best translation quality is maintained.

In-Context localization is tied up with the actual project created in Crowdin, under which translatable files are stored.

This tool makes all the texts in the web app editable. Moreover, the translation process is real-time visible. Even the dynamic part of the application and strings that contain placeholders can be translated this way.

See In Action

Technical overview

Crowdin In-Context works with the help of one line Javascript snippet and the pseudo-language package. It creates the pseudo-language package based on the localization files uploaded to your project, which later will be integrated to your application as an extra-localization language.

Integrated pseudo-language contains some special identifiers instead of the original texts, thus when switching your app to that language, all of the labels are converted to the special identifiers. Javascript searches for those identifiers and replaces them with the editable labels. In such a way, the translator does not see any difference between the live app and the app with the integrated Crowdin In-Context tool. However, the tool defines what part of the app is translatable and provides all means to let the translator localize in context.

The translation is made on the minimized regular Crowdin Editor with all the functionalities (TM, machine translation, approve/vote option, comments, terms) provided. Thus, it is easier to review the translations for the proofreaders and assure the quality.

Интеграция

There are two common approaches to integrate Crowdin In-Context with your application: - Staging or translation environment. Если вы не считаете нужным привлекать конечных пользователей сайта к переводу и не предпочитаете иметь “режим перевода” на продакшне, интеграция Crowdin In-Context в отдельную среду для перевода будет отличным решением. - Production environment. Crowdin In-Context does not require any code changes in your application, so it can be used even on production. You decide how to turn it on and for what segment of users it can be activated. The feature that enables the translation mode can be either hidden, There were cases when the translation mode was enabled as an extra language.

Follow step by step the integration setup, which you can find in the Project Settings, In-Context tab.

After the successful integration and your app refreshment, you should see the invitation dialog and Crowdin login box.

Необязательные Параметры

Вы можете добавить эти параметры в _jipt массив в фрагменте конфигурации.

Предварительная загрузка строк

_jipt.push(['preload_texts', true]);

Speeds up dynamic content displaying within the In-Context tool by preloading all source strings. Automatically disabled for the large projects (5000+ strings). The acceptable values: true, false.

Before Commit Callback

_jipt.push(['before_commit', function(source, translation, context, language_code) {
  return status_obj;
}]);

Функция для проверки предложения перед совершением.

Параметры
sourceИсходный текст
translationТекст перевода
contextИсточник строки контекста
language_codeTarget language code (language codes)
Возвращать значения
status_obj Object. The status_obj.status may be "ok", "error" or "corrected". In case of error, status_obj.message contains error description. When status is "corrected", status_obj.correction contains the corrected translation

Before DOM Insert Callback

_jipt.push(['before_dom_insert', function(text, node, attribute) {
  return 'text';
}]);

Функция для преобразования строки перед его подставления в DOM.

Параметры
текстСтрока для вставки
node
необязательный
Элемент DOM, в которой должен быть вставлен текст. Может быть опущен, если текст не содержит элемент target (текст внутри браузера всплывающего окна)
attribute
optional
Атрибут элемента DOM, если текст является частью атрибута
Возвращать значения
текстСтрока для вставки
falseЕсли функция возвращает false, то DOM не будет обновляться

Close the In-Context Overlay Callback

_jipt.push(['escape', function() {
  window.location.href = "http://app_domain.com";
}]);

If defined, users can close In-Context overlay if they don’t want to translate. Implement this feature on your side. It must change app’s language or redirect from translation environment to the production app, depending on the In-Context integration approach.