This package facilitates working with translations in Contentful
-
exportTranslations --space-id=<spaceId> --environment-id=<environment-id> --management-token=<management-token> --url-filter=<url pattern> --locale=<locale> --mode=<mode> --exact-url
The exportTranslations script is used for generating JSON from pages in Contentful (starting with a URL slug, and most commonly used on DotCom) -
exportOneType --space-id=<spaceId> --environment-id=<environment-id> --management-token=management-token --type-id=<typeId> --team-id=<teamId> --locale=<locale> --mode=<mode>
The exportOneType script is used for generating JSON from entries of a specific type. Ifteam-id
is specified, then only the entries with this team ID will be exported. -
exportOneEntry --space-id=<spaceId> --environment-id=<environmentId> --management-token=management-token --entry-id=<entryId> --locale=<locale> --mode=<mode>
The exportOneEntry script is used for generating JSON from ONE Contentful entry (and everything below it). This is typically used for special cases and exceptions.
Export script arguments:
Parameter | Description | ||
---|---|---|---|
url-filter | The URL under which we want the content exported (required in the exportTranslations script only) |
||
exact-url (optional) | if specified, only content for this exact URL gets exported, otherwise ALL pages matching the pattern will be exported (exportTranslations script only) |
||
type-id | The id of the content type in Contentful whose entries we want exported (required for the exportOneType script) |
||
team-id (optional) | The ID of the TeamName entry in the ShortStrings space. If specified, only the entries with that teamID will be exported (exportOneType script) |
||
entry-id | The Contentful id of the entry to export (required for the exportOneEntry script) |
||
locale | locale to export for. For example da-DK , tr-TR (case doesn't matter). Additional supported locale aliases are listed below: |
||
all : all supported locales at DFDS |
|||
all-b2b : locales used in Freight & Logistics |
|||
all-pax : locales used in PAX |
|||
all-app : locales used by the App team |
|||
mode (optional) | determines how the export gets generated, see options below | Expected format coming back from the translation vendor | |
"all English" is the default mode, generating English content for everything under the URL. | translations for the English strings that were sent out | ||
missing : export only the strings that have no translations for that language. The result is English strings to be translated |
translations for the English strings that were sent out | ||
existing : re-sends the strings that already have translations for them. This generates 2 files per language. The source English (for reference) and the existing translation for target language |
corrections to existing translations | ||
space-id | The ID of the space in Contentful, usually pre-specified | ||
environment-id | The environment for that contentful space, usually export goes from master | ||
management-token | The access token for that Contentful space, usually pre-specified |
The importTranslations
script is used for importing translated JSON files into Contentful
The syntax for this script is as follows:
importTranslations --space-id=<spaceId> --environment-id=<environment-id> --management-token=management-token --filename=<filename_locale.json> [--overwrite] [--all-locales] [--all-folders]
Import script arguments:
Parameter | Description |
---|---|
filename | The filename containing translations. Specify the filename relative to package/translation/translationImport . The suffix of the file indicates which locale the translations are for, for example myfile_da-DK.json will be imported into the Danish locale, and myfile_tr-TR.json will be imported into the Turkish locale |
all-locales | import from files of all available locales. With this option, you should remove the <locale>.json postfix, leaving the name as --filename=myfile
|
all-folders | import from files of subfolders, in all available locales. Note that the specified argument at --filename will be ignored, and all files in all subfolders of package/translation/translationImport will be imported |
overwrite (optional) | If false (default), any existing content in the locale being imported will be KEPT. If true, the content in the JSON file will supercede what's in Contentful |
space-id | The ID of the space in Contentful, usually pre-specified |
environment-id | The environment for the Contentful space into which we are importing, usually the import is into staging or sandbox for testing and verification, and master for going live |
management-token | The access token for that Contentful space, usually pre-specified |
Note: while you can export in different modes (all English / existing / missing), the importer doesn't have modes, everything we import is going to be either new translations or existing translations fixed up