In the first installment of our Selligent Pro Tips series, Andy Somers at Selligent Partner company Foreach shares expert insights on keeping translations synchronized between different environments.
Most clients implement one Selligent system, usually a SAAS. When it comes to handling translations into different languages, this means the following namespace scheme: Application A has three namespaces: "Application A Dev", "Application A STG" and "Application A PRD". Application B has three namespaces, and so on.
Says Andy Somers at Foreach: “Since our clients have access to the Selligent tools and can change these translations through the standard Selligent translation tool, we end up with discrepancies pretty fast.”
Working with the standard Selligent translation tool offers the following view:
Andy Somers comments: “As you can see, this tool offers little in the way of comparing namespaces, or mapping the label keys to their place on the screen.”
The old method
As a workaround, Foreach tried the following makeshift solution: “Originally, with each deploy, we'd compare namespaces manually (and only copy those translations that had changed or were added). As our understanding of the translation system grew, we had written some SQL statements to aid us, but the bulk of the work was still manual. And as we all know, manual equals tedious and prone to errors.”
Engaging in some deep error analysis, Andy Somers and colleagues found: “Turns out the underlying cause was human. We just made too many mistakes during the manual comparison.”
As a result, the manual method proved frustrating for both clients and the pros at Foreach. Time for a better solution…
Drawing on some of the previous programming, the team went to work: “We set out to create a solution that allowed us to automatically copy changes between namespaces. The SQL statements we had before were poured into a couple of stored procedures.”
Combined with a Selligent campaign and a page, the SQL statements yielded the following results:
By default, the tool can copy values from a source to a target namespace, overwriting old values while ignoring values with a newer change date. This way, it ensures the most current translation data prevails. The tool also adds new translations in the target namespace that did not exist there yet.
The method also makes two more "advanced" options available:
- Drop and replace the values of the target namespace (effectively overwriting the entire target namespace).
- Force overwrite changes, which ignores the change date of the target namespace values.
But in daily practice, “we don't use these very often, but they come in handy from time to time,” said Foreach.
The new way
The new and improved deployment from staging to production follows this procedure:
- Select the production namespace as source and the staging namespace as target
- Copy the values
- Select the staging namespace as source and the production namespace as target
- Copy the values
As Andy Somers explains: “This causes both namespaces to contain the same values. Ideally, production is copied to development as well.”
WORKING WITH THE NEW METHOD
Here’s how you can optimize your translation process with this Pro Tips synchronization method.
The code of the stored procedures and the HTML page can be found here on Foreach’s server as a Git snippet.
Since system tables are not represented as lists, the first task is to create these lists to use in your campaign and pages. These lists are based on existing tables: 'labels' and 'namespaces'.
Create a data list for the labels table and an article list for namespaces, since we want to use the latter in the page. In our example, these are called 'templabels' and 'temparticlenamespaces' respectively.
2. Stored procedures
Take the code in the SQL files from the Git snippet and create two stored procedures: SP_COPY_LABELS and SP_DROP_LABELS.
Create two new pages with the code provided. The first page contains the functionality to display two dropdowns containing the namespaces. Add an article container named NAMESPACES pointing to the ‘temparticlenamespaces’ article list, unchecking all checkboxes.
Next, add a new filter called ALL to that article container and add a sort on ID(ASC).
Note: The second page is one that only contains the word 'OK'.
4. The campaign
In the final step, we'll string everything together in a campaign.
Create a new single shot campaign and use the ‘templabels’ list as a base list.
Add a new Weblink as entry point and the labels page as the first step. The next item in the flow is a decision component to check whether or not the target namespace needs to drop all values.
The 'no' branch leads to the 'SP_COPY_LABELS' stored procedure, the 'yes' branch to the 'SP_DROP_LABELS' stored procedure. The exit flow from the SP_DROP_LABELS leads to the SP_COPY_LABELS. The last item in the flow is the 'ok' page.
The flow should look something like this:
Both stored procedures need to have input parameters, configured as follows:
Ready to Roll
Open the Web link and go to the generated URL, you can now use the tool.
Caveats and disclaimers
Note that this tool makes changes in the labels table of Selligent. This is a system table, which means the structure and/or content of this table might change in the future without warning. Be careful when writing stored procedures on this kind of table, because you might break the system!
Also keep in mind that there is no way to retrieve previous translations once your overwritten them.
Once you have successfully implemented this solution, you'll see that keeping translations synchronized between namespaces is a breeze.