In datamapping an xml invoice file I have to add strings to an extracted field to prepare it for use in the table wizard. Since I cannot change the generated tables later in the Designer (and instead would have to create them from scratch) I have to add relevant additional information to files in the datamapper that I then can later use in Designer in the table.
However, the templated are multilangual and I need to access the translation functions in Datamapper Javascript to provide language based string translations.
translate()
does not seem to work because it only is available in Designer context, not in Datamapper.
How can i translate Strings in Datamapper, using the same po/mo/pot files I use in designer?
You can’t. The DataMapper was specifically designed to be independent from the Designer since the same DM configuration can be used for multiple templates.
You’ll have to use generic values inside the DM for which you can then provide translations in the Designer. For instance, for a Due date, you could extract the string “INVOICE_DUE_DATE” in the record. That makes the value self-explanatory in the Designer’s Design mode and allows you to quickly identify which strings need translating.
I do not understand that explanation. If I want to use a datafield in a table I have to select it from the Data Model. After selecting it in a table using the dynamic table Wizard it does not show up in the Script tab to the lower left, so I cannot dynamically change the content of the table datafield depending on other fields.
The concrete problem is that if an article is not in stock and a replacement article is shipped from an attribute further down in the xml data i have to add additional information about this to the already existing article description. I can add the replacement article just fine in datamapper, but I cannot add the text “delivered instead” (and translations) as information for the customer.
In Designer after adding the description field in the Table Wizard I cannot change the description field using Javascript, since it does not show up to the left, as written above. So from what I understand so far I cannot add translations for that in Datamapper, but I can also not change Table Wizard Table fields after the table is created.
What you could do is when you are doing your product switch when the first one isn’t available, set a boolean value field stating that it was a switch. Then in your Template, you can add any text like “delivered instead” conditional of the true / false value of the boolean field and appply translation to that added text.
It does not work that way. The replacement article is not another article, but a sub-attribute of the replaced article.
In addition: As I wrote above: The changes are in the table created by the Table Wizard and I cannot change those fields using Javascript, since they do not show up in the Scripts pane. In a table I cannot simply “add any text” if I’m not missing something basic, because Designer says that is not possible and i have to use Table Wizard.
And in the table Wizard I can only select existing fields:
The table Wizard is only that…a Wizard. A mechanism helping you building your dynamic table. Once it is done, you can always modified the resulting code by using scripts.
I added a Field @BezeichnungPlusText2@ (adding the needed additional text) left in the Script tab and replaced the field @BezeichnungPlusText@ with it in the Designer Pane with it. The new field is completely ignored and in the table still the content of @BezeichnungPlusText@ is shown, it’s as if Designer ignored my new Javascript-based field and still uses the old one that was assigned in the Wizard. Why does that happen? And why do fields assigned by the table Wizard not show up to the left in the Javascript Pane?
I now know why: If I change the placeholder in the designer pane, the corresponding “data-field” in the source is not automatically also changed. This is not very intuitive or user-friendly. But it works now.