Use Phrase to translate dynamic segments, e.g. blog posts or product information typically stored in a database.
Setup
Projects
Keep translations of dynamic content in a separate project, next to the project already in use for handling static translations. Depending on quantity of dynamic content, create separate projects for different content types, e.g. My Project - Blog Posts and My Project - Products.
Key structure
Since all content is organized as keys and values, decide on a key structure for the dynamic content. Include the unique identifier from a database in the key name:
-
products.10.name
-
products.10.description
-
products.10.summary
-
products.11.name
-
products.11.description
-
products.11.summary
-
etc.
Depending on quantity and nature of the dynamic content, use tagging to further improve the key structure.
Sync process
If sync dynamic content translations frequently, write a script that handles uploading and downloading the content and can be run when necessary, e.g. once per day or triggered by a webhook event.
Uploading content
For a quick initial upload it is sufficient to render keys and source content in a simple .CSV or .JSON file and upload them directly using the push command or using the upload endpoint.
To provide more context data such as screenshots and descriptions, create key entries directly using the keys endpoint and attaching translation entries afterwards.
Updating content
Work solely in Phrase on the translated versions of original content and only modify source content directly in the database. This removes versioning conflicts that can occur if modifying content directly in a database.
Retrieving translations
For simple use cases, download the translations for dynamic content using the pull command or directly with the download endpoint. Specify whatever format works best, but use an easy to parse format such as .CSV or .JSON.
For more advanced setups, access all translation entries directly using the API.
After retrieving translations for each locale, store the content for each key and locale in the database.