From 41dad43a3cad9f1558a32b833b5d9c8d779ed76f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 19 Nov 2021 21:33:58 +0000 Subject: [PATCH] --- docs/8.0/ayanova/docs/ay-report-edit.md | 14 +++++++++++++- server/AyaNova/resource/rpt/ay-report.js | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/8.0/ayanova/docs/ay-report-edit.md b/docs/8.0/ayanova/docs/ay-report-edit.md index 4163e5e5..c3606206 100644 --- a/docs/8.0/ayanova/docs/ay-report-edit.md +++ b/docs/8.0/ayanova/docs/ay-report-edit.md @@ -395,10 +395,22 @@ Will render the small sized logo as an image tag set to the correct API Url. No ### ayT -Translates an AyaNova translation key into the language indicated by the current logged in user or the server default: +Translates a pre-specified (see below) AyaNova translation key into the language indicated by the current logged in user or the server default: ```{{ ayT 'Customer' }}``` +Note that you need to tell AyaNova which translation keys to pre-fetch before rendering the report by inserting a call to the function `ayGetTranslations` in the ayPrepareData function in the Prepare Data tab. All translation keys required need to be specified in this manner. + +For example, let's say you wanted to display the translation for Customer and WorkOrder, you would insert a call to get the translations as follows: + +```javascript +async function ayPrepareData(ayData){ + await ayGetTranslations(["Customer","WorkOrder"]); + return ayData; +} +``` +ayGetTranslations expects an array of all the translation keys that will be used on the report. If any are missing you will receive an error message about the missing keys. + You can view all the translations keys available in the [Translations](adm-translations.md) form. diff --git a/server/AyaNova/resource/rpt/ay-report.js b/server/AyaNova/resource/rpt/ay-report.js index c510a0a8..fa10cc45 100644 --- a/server/AyaNova/resource/rpt/ay-report.js +++ b/server/AyaNova/resource/rpt/ay-report.js @@ -96,7 +96,7 @@ function ayRegisterHelpers() { Handlebars.registerHelper("ayT", function (translationKey) { if (ayTranslationKeyCache[translationKey] == undefined) { - throw `ayT reporting helper error: the key "${translationKey}" is not present in the translation cache, did you forget to include it in your call to "await ayGetTranslations([KeyList]);" in ayPrepareData()\nTranslationKeyCache contains: ${JSON.stringify( + throw `ayT reporting helper error: the key "${translationKey}" is not present in the translation cache, did you forget to include it in your call to "await ayGetTranslations(['ExampleTranslationKey1','ExampleTranslationKey2','etc']);" in ayPrepareData()\nTranslationKeyCache contains: ${JSON.stringify( ayTranslationKeyCache, null, 3