By this point you should have already created your repo-connector.conf
file, governing how the Repository Connector connects to Smartling and your code repository. Now you need to tell the connector where your resource files are, which locales you want to translate and how you want translated files to be returned to your repository.
Create Translation Configuration File
Remember that / is an escape character both for JSON and RegEx, so you need to double-escape special characters for your Regular Expressions to work.
Create a JSON file and commit it to the path defined in the repo-connector.conf
file. Default filename is smartling-config.json
. This file defines resource file that should be uploaded and how to save translated files that are downloaded from Smartling. The file must be valid JSON.
The Repository Connector Package contains an annotated example file called
. You can use this file to build your config but make sure you rename the file to remove the smartling-config-example.json
-example
from the filename.
Parameters
- locales: Locales has two functions. If automatically authorizing content that is uploaded to Smartling (default behavior), it determines which locales content will be authorized for. It also serves as a mapping of locale codes from the Smartling API codes to the codes that are used in the repository. Smartling locale code must be unique per configuration file. The file must list at least one locale. Note that if you add extra languages to your project, you will need to update this file for the new languages to be handled by the Repository Connector.
- smartling - Smartling locale code. Codes for locales in your project can be copied from Project Settings > Languages in the Smartling Dashboard.
- application - locale code that will be used when downloading translated files back to the repository. This can be any format
- resourceSets: Defines an array of resource sets. Each set identifies a group of repository files that will be uploaded to Smartling with the same settings.
- type: The Smartling API “fileType”. Possible values: “javaProperties”, “ios”, “android”, “gettext”, and so on. See Smartling’s Supported File Types documentation for the full list.
- pathRegex: Java 7 Regular expression defines which repository files to upload to Smartling. All files matching the expression will be uploaded. Read the additional notes about escaping in smartling-config-example.json. As well, you can test your Regex using online tools, such as this.
- authorizeContent (optional): Defines whether uploaded content will automatically be authorized for translation. Possible values: ‘true’ (default), ‘false’. If 'true', any updates committed in the repo will be automatically authorized for translation in a DailyUploads job. If 'false', any updates committed in the repo will sit outside of a job, in the Awaiting Authorization queue until a user manually authorizes the translation and creates a new job or adds the content to an existing job.
- translationPathExpression (optional): Groovy expression used to create a file path and name for translated files. If this value is not defined, translated files in the Smartling dashboard will not be downloaded to the repository. Predefined variables for the expression are:
- ${locale}: Project locale code value (as defined at locales.application)
- originalFile: Object with string properties, which returns parts of the original path. See below for property descriptions and example values for an original file path
localization/messages/user.properties
- ${originalFile.fullName}: Full path and name of original file. E.g.
localization/messages/user.properties
- ${originalFile.path}: Original file path only. E.g.localization/messages/
- ${originalFile.name}: Original file name with extension. E.g.
user.properties
- ${originalFile.baseName}: Original file name without extension. E.g.
user
- ${originalFile.extension}: Original file extension. E.g.
properties
- ${originalFile.fullName}: Full path and name of original file. E.g.
- Groups defined in your pathRegex expression can also be used as variables.
- translationCommitMessage (optional): Groovy expression defining a translation commit message. If not defined, a default value “
Translation $originalFile.fullName to $locale
” will be used. Predefined variables are the same as those fortranslationPathExpression
, plustranslatedFile
, which contains the translated file path and name, with the same attributes as theoriginalFile
. - smartlingDirectives: Array of strings which have the format
<directive name>=<value>
. File directives can be used to alter the way Smartling handles your files. See our Supported File Types documentation for information on which directives are available for each file type.