Configuração da tradução contextual

Visão geral

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

Integrated pseudo-language contains special identifiers instead of the original texts. Thus when switching your app to that language, all labels are converted to special identifiers. Javascript searches for those identifiers and replaces them with editable labels. So, the In-context page of your web app will look the same as your application, with the only difference that translatable strings will be editable.

In-Context View

Translations are made directly in the app, with no need to open the Editor. A simplified version of Crowdin Editor will be displayed, with all the functionality (TM, machine translation, approve/vote option, comments, terms) provided. Thus, it’s easier to make and review translations since translators can preview them in a real context.

In-Context Editor

Integração

Existem duas abordagens comuns para integrar o Crowdin No contextoao seu aplicativo:

  • Staging or translation environment
    If you are not planning to invite your end-users to help with translations or not considering using a “translation mode” in your production application, integrating Crowdin In-Context to your staging or dedicated translation app environment would be a good solution.

  • Production environment
    Crowdin In-Context doesn’t require any code changes in your application so that you can use it even on production. You decide how to turn it on and which segment of users will use it. The most common use cases are the following:

    • You can create a mirror website that is a complete copy of your application but under a different URL (for example, instead of crowdin.com it can be translate.crowdin.com), where translators will make translations as if it was your actual application.
    • You can also add In-context as an additional language. So, when translators open your application, they will choose this additional language from the list, which will open In-context for them.

Follow the integration setup guide in your Crowdin project to set up In-context. The guide can be found in the left-hand panel in your project, under Tools > In-Context.

In-Context Tab

Note: If you use CSP, ensure to add the following rules to the policy: for loading the In-Context resource files, for CORS requests to <organization_domain>.crowdin.com

After the integration is successfully set up and you have refreshed your application, you should see the invitation dialog and Crowdin login box.

Login Window

Parâmetros opcionais

You can add these parameters to the _jipt array in the configuration snippet.

Pré-carregamento de textos

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

Acelera o conteúdo dinâmico exibido na ferramenta In Context, pré-carregando todas as strings de origem. Automatically disabled for large projects (5000+ strings). Valores aceitáveis: true, false.

Botão de tradução sempre visível

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

This option is enabled on touchscreens by default and makes the translation button next to each translatable string permanently visible instead of showing on hover. Valores aceitáveis: true, false.

Antes de confirmar o callback

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

Função para validar a sugestão antes de enviar.

Parâmetros
fonteTexto de origem
traduçãoTexto de tradução
contextoContexto da cadeia de origem
language_codeCódigo do idioma de destino (códigos de idioma)
Valores de retorno
status_obj Objeto. O status_obj.status pode ser "ok", "erro" ou "corrigido". Em caso de erro, status_obj.mensagem contém a descrição do erro. Quando o status está "corrigido", status_obj.correction contém a tradução corrigida

Antes de Inserir Callback DOM

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

Função para transformar a string antes que ela seja inserida no DOM.

Parâmetros
textoString para inserção
node
opcional
Elemento DOM no qual o texto deve ser inserido. It may be omitted if the text doesn't have a target element (text inside the browser's pop-ups)
atributo
opcional
The attribute of DOM element, if the text is part of an attribute
Valores de retorno
textoString para inserção
falsoSe a função retornar false, O DOM não será atualizado

Feche o Callback de sobreposição em contexto

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

If defined, users can close the In-Context overlay if they don’t want to translate. Implementar esse recurso no seu lado. Depending on the In-Context integration approach, it must change the app’s language or redirect from the translation environment to the production app.

Close Login Window

Este artigo foi útil?