Before building a script, you must understand the basics of Codex profiles. You can find all the information about Codex and the profiles here.


Basics


For CSV files a cell is referenced using an RC pattern: Row, Column. This means that to access the value of the first cell, you will tell Codex that it can find it at these coordinates: [0,0].

Warning: the indexes for CSV files starts at 0, not 1.


ID;SOURCE;DESC;EAN
154895;RING;A super ring;1828301928
159847;SHOES;Super shoes;4828298371
987372;SHORT;A super short;283923184
628481;PANT;Super pants;123098322
328479;SWEAT;A super sweat;123894893


Here we have our CSV Sample file. As we can see, the first and fourth columns do not need to be translated. Also, the first line contains column names we don't want to send to be translated. Find below the Codex Script that will allow you to separate correctly:

selectionPathList = [Pair("[0,*]", False), Pair("[*,0]", False), Pair("[*,3]", False), Pair("[*,*]", True)]
contextsPath = []
groupingPaths = []
contentNames = []
groupingPathNames = []
targetInjections = []
targetInjectionsRange = []

Exclude all columns of the first line, Exclude all lines of the first column, Exclude all lines of the third column, Include other content.


Improve your scripts


Manage multiple target languages files with targetInjections parameter


ID;SOURCE;de-DE;it-IT
154895;RING;RING;RING
159847;SHOES;SHOES;SHOES
987372;SHORT;SHORT;SHORT
628481;PANT;PANT;PANT
328479;SWEAT;SWEAT;SWEAT

Here we have as sample a CSV File that has to be translated directly inside target language columns instead of replacing the source values one.

Find below the Codex Script that will allow you to separate properly:

selectionPathList = [Pair("[0,*]", False), Pair("[*,0]", False), Pair("[*,1]", True), Pair("[*,*]", False)]
contextsPath = []
groupingPaths = []
contentNames = []
groupingPathNames = []
targetInjections = [Triplet("[*,1]", "[?,2]",Language.de_DE), Triplet("[*,1]", "[?,3]",Language.it_IT)]
targetInjectionsRange = []

targetInjections dispatcher parameter has been set up to: GET the extracted content of the second column, apply it to the third one, for the language de-DE, and GET the extracted content of the second column, apply it to the fourth one, for the language it-IT


Warning: this parameter overrides any target languages that you could have set during uploading or manual launching. If you want to add another language for translation, update the script then apply a manual translation with any target languages.


Split your large files with the groupingPaths parameter


Without using this parameter, the whole extracted content of your file will be located into a single task in your translation project.


Let's say your sheet contains in the first column some values that can be used to group your content. You can then just use this column as a grouping path:

groupingPaths = [Pair("[*,*]", "[?,0]")]

Here Codex will create groups that have the same content in the first column, so the two first rows will be grouped together, and the other ones will remain alone.


Give context to your localizable content with the contextPaths parameter


The localization process can be improved if a context is given.

If any element that can be used as a context and is present in your file, their values will then be displayed on the Details panel of the Translation Studio.

Here is a sample script to extract some content as context:

contextsPath = [Pair("[*,3]", True), Pair("[*,4], True)]

Here we've added the lines of the fourth and fifth columns as context.


URLs & Images

To have clickable URLs in the Translation Studio Details panel, make sure they are provided between "[url=" and "]" tags in the file.

ex: [url=https://helpdesk.wezen.com]


To have images displayed in the Translation Studio Details panel, make sure they are provided between "[img=" and "]" tags in the file.

ex: [img=https://wezen.com/yourimage.jpg]