Serge + Smartcat

Smartcat drives the language industry to its full technological potential while making both customers and vendors happy in the process.

By enjoying a continuous and streamlined multilingual delivery loop, Smartcat users are prepared for the new content economy. Below, we describe how to integrate and configure Serge and Smartcat to build an automated, continuous localization process.

Configuring Serge to work with Smartcat

Here are the steps you need to take to make Serge work with Smartcat:

  1. Create a Smartcat account.
  2. Create and set up a project in Smartcat.
  3. Install Serge.
  4. Set up the Smartcat plugin.

Setting up the Smartcat plugin

sudo cpanm Serge::Sync::Plugin::TranslationService::Smartcat

Adding the plugin

In Serge configuration files find myproject.serge.tmpl and add the Smartcat plugin to the sync > ts section.

sync {
ts
   {
       plugin                    Smartcat
       data
       {
           project_id           12345678-1234-1234-1234-1234567890123
           token_id            12345678-1234-1234-1234-1234567890123
           token             1_qwertyuiopasdfghjklzxcvbn
           push {
               disassemble_algorithm_name       Serge.io PO
           }
           pull {
               complete_projects               NO
               complete_documents              YES
           }
           log_file             ./log/smartcat.log
       }
   }

Parameters:

  • plugin — plugin name. Must be “Smartcat”.
  • project_id — unique Smartcat project ID.
  • token, token_idcredentials used by Serge to access the Smartcat API.
  • disassemble_algorithm_name — name of the algorithm to disassemble the Serge files. Must be “Serge.io PO”.
  • complete_projects — condition to pull new translations. Whether or not the plugin will pull translations from Smartcat only when all documents in the project are Completed. “No” by default.
  • complete_documents — condition to pull new translations. Whether or not the plugin will pull translations from each Completed document in the Smartcat project. “Yes” by default.

Configuring Serge jobs

Go to the jobs section in the myproject.serge.tmpl file and configure the ts_file_path parameter. It describes the location to generate .po files.

ts_file_path                ./po/%project_id%/%LANG%/%FILE%.po

Parameters:

Note that the %LOCALE% macro is used to generate locale-specific folders under the /po/project_id/ directory. The value for %LOCALE% is set up in the destination_languages parameter. It must correspond to the Smartcat project languages and language codes from the list.

destination_languages       ru zh-Hans ko de ja

Once you set up the jobs section in your configuration file, you can run the Serge localization pass once to see if the .po files are generated properly, and the folder and file structure matches the expectations.

serge localize myproject.local.serge

Example of myproject.serge.tmpl

A configured myproject.serge.tmpl is presented below. You can use it as a template for your integration.

sync {
ts
   {
       plugin                    Smartcat
       data
       {
           project_id            %project_id%
           token_id             %token_id%
           token             %token%
           push {
               disassemble_algorithm_name       Serge.io PO
           }
           pull {
               complete_projects                NO
               complete_documents               YES
           }
       }
   }

   vcs {
       plugin                    git
       data {
           local_path            ./branches
           add_unversioned       YES
           name             L10N Robot
           email             l10n-robot@example.com
           remote_path {
               master   git@gitlab.loc:common/myproject.git#master
/* FBCGEN_BRANCH_REMOTES
               $FBCGEN_DIR_PADDED  git@gitlab.loc:common/myproject.git#$FBCGEN_BRANCH
*/
           }
       }
   }
}

jobs {
   :develop {
       id                     job.master
       name                     myproject
       source_language             en
       destination_languages       ru zh-Hans ko de ja
       optimizations               NO
       source_dir                  ./branches/master/client/src/translations
       source_match                `en-US.js`
       debug                     NO
       parser {
           plugin            parse_js
       }
       leave_untranslated_blank    YES
       db_source                   DBI:SQLite:dbname=./myproject.db3
       db_namespace                myproject
       ts_file_path                ./po/%project_id%/%LANG%/%FILE%.po
       output_file_path            ./branches/master/client/src/translations/%CULTURE%.%EXT%
       output_bom                  NO
       output_lang_rewrite {
              zh-Hans zh
       }
       callback_plugins {
           :feature_branch {
               plugin     feature_branch
               data {
                   master_job job.base-translate
               }
           }
       }
   }

/* FBCGEN_BRANCH_JOBS
   :$FBCGEN_DIR {
       @inherit                    .#jobs/:develop
       id                     job.$FBCGEN_DIR
                                   $FBCGEN_EXTRA_INCLUDE
       source_path_prefix          $FBCGEN_BRANCH.
       source_dir                  ./branches/$FBCGEN_DIR/client/src/translations/
       output_file_path            ./branches/$FBCGEN_DIR/client/src/translations/%CULTURE%.%EXT%
   }
*/
}