This commit is contained in:
2021-11-19 21:33:58 +00:00
parent 48a067bb5e
commit 41dad43a3c
2 changed files with 14 additions and 2 deletions

View File

@@ -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.

View File

@@ -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