I am looking for a feature to translate variables in templates a la i18n Jinja style but could not find anything in the documentation.
According to the web I can do this by using a mapping of source terms like so:
Why not simply use external snippets? You can store all translations in there, and they will automatically switch to the required language when you invoke it with @#snippet
and why not in data-expressions - I know, actually they are more for calculations - but isn’t it clearer/better for overview?
I had this idea bc of another reason, too: it’s not about translation in the strict sense - it’s not about translating/having translated the input of a data point into another language, but more about giving it a specific, but different expression…hence my idea of putting this into the data expressions.
For example, the input visible in the frontend is “Äußerung ausstehend,” but the output is not “Äußerung ausstehend,” but rather “virtualcourthearingstatusdefendanttype_statement_pending” and we cannot use it in this form. What the data point expresses should therefore not only be translated in the narrow/simple sense, but also be given a different expression. Hence the idea of data expressions…
Both are possible of course — the way of organising is a bit different (one translation per file ↔ multiple data expressions per concept), and external snippets can also have the advantage of allowing for ?parameters.
In this example there are 4 different translations shared by 3 different clauses.
Do I understand correctly that you need 1 snippet per translation? What if you need 5 languages? I was hoping to have one file/snippet/… that contains all tranlations for one language and that I can “inject” into the clauses to be used there.
Can you please give an example of a snippets that contains all 4 tranlations from the example and how to invoke it in the clause by somehow passing the variable to get the correct snippet?
When using external-snippets, bear in mind that the translations will always be limited to the languages of the server you’re working on. E.g., if you’re on the German server, it will be limited to German + English.
We can add languages to the server, but that has some performance implications (as all language-related tasks may take a bit more time, particularly when also using ClauseBuddy on that server) and will also have an impact on users, because suddenly more languages are shown on the screen (except when you start to selectively disable languages for certain users / profiles).
Your example would be structured as follows:
A clause called apple, which simply contains “apple” in its English body and “Apfel” in its German body
A clause called pear, which contains “pear” in its English body and “Birne” in its German body
A clause called orange, which contains “orange” in its English body and “Orange” in its German body
A clause called plum, which contains “plum” in its English body and “Pflaume” in its German body
You would then invoke (insert) each translation simply by doing @#apple or @#pear. Clause9 will then automatically the English or German body, depending on whether you’re inserting that snippet in an English or a German body.
A completely different approach that you may want to have a look at, is to store the translations in Excel, and then use one of Excel’s lookup formulas. The advantages are that, once set up,
it’s faster to do the data entries, as it’s simply filling another row with columns
you’re not limited to the languages currently on the server
For both the external snippets and the Excel approach, take into account that there’s a practical limit of a few hundred translations per document.
Each individual Excel lookup takes a roundtrip to the server when you’re working in the browser. The value retrieved is cached, but even so it’s a roundtrip initially.
If you would be doing external snippets, then bear in mind that each snippet requires several internal database records to be assembled together. You don’t feel this with a few hundred files, but beyond that you’ll notice that it will take several seconds for the server to fetch the entire document. Until it’s changed all that data is cached, but the initial assembly make take several seconds.
If we were to do it with external snippets, we would have to do something like this because we dont know the value of the variable that determines which translation we need exactly (= that is determined by the value of that variable).
if my_var= 'fruit_apple' then @#apple else if my_var='fruit_pear' then @#pear else if ..else if.. else if ... [for all possible values of my_var]
That seems not very efficient.
I like the Excel idea a lot.
How do you dynamically get the correct row assuming different rows have different terms/words and their translations?
In the tutorial there is an example where you get the value from a cell if the neighboring cell has value '#product^name.
What if you dont know whether '#product^name is in row D1 or F1 or G1. You just know it is somewhere in column D.Is there a way to say: Give me the value from column C in the same row where column D has value ''#product^name?