In xyzDialog.cs; using new LocalText("<myKey>") not finding key, works with e.g. "Dialogs.YesButton"
See original GitHub issueHi JaiQ,
John Ranger here again 😃
I am currently transferring my developed app (which was based on Serene V1.8.20 or so into the newest serene V1.9.9 - because I had some issues with the language switching and also User auth via AD didn’t work. Both are now working fine with V1.9.9) and while doing this, I am also transferring every statically programmed text Output into the localisation Framework.
For this I have put a new json file called ClientAndAssetManagement.invariant.json into xyz.Web/Scripts/site/texts and filled it with key-value pairs.
For most Things this works fine (e.g. I can define DB.xxxx keys (which I first look up within the Translation serenity GUI) and use them in xyzRow.cs) but when I want to use such a DB.xxxx key (which works in xyzRow.cs) or a completely new key (e.g. “Dlg.Stammdaten.CSVDelimiter.Warning.SetDefault”) within xyzDialog.cs to be used within a Q.Confirm popup, the LocalText method does not recognize my custom keys and just Shows the key instead of the desired value.
But… If - within xyzDialog.cs - I Exchange my custom key with a Serenity Default key like “Dialogs.YesButton” then localtext can translate the key into the related value and Outputs “yes”.
I have looked through your Dev-Guide but didn’t find anything special mentioned that custom keys have to be handled differently than Serenity keys.
The Definition within the json Looks like this:
"Dlg.Stammdaten.CSVDelimiter.Warning.SetDefault": "Warning! Checking this checkbox and clicking on 'update' will set this CSV delimiter as the 'default'.\n\nDo you really intend to do that?",
The code within xyzDialog.cs Looks like this:
var warning = new LocalText("Dlg.Stammdaten.CSVDelimiter.Warning.SetDefault");
Q.Confirm(warning.ToString(), () =>
{
isChecked = true;
form.IsDefault.Value = isChecked;
}
, new ConfirmOptions { DialogClass = "s-MessageDialog s-WarningDialog" });
–> This Outputs: “Dlg.Stammdaten.CSVDelimiter.Warning.SetDefault” instead of the text defined within the json.
Question: How can I use LocalText within xyzDialog.cs to fetch some Txt out of the localization json?
Hint: I have put the whole Content of the Jason file into a json validator (jsoneditoronline.org) and everything seems to be ok with the Content.
Thanks for your help and
with Kind regards,
John
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (4 by maintainers)

Top Related StackOverflow Question
Hi JaiQ,
that was it! I have now changed my Dlg. keys to Dialogs. and it immediately worked!
Thanks again for your fast and precise help.
Thanks also to Victor. --> I will have still to find out why my Db. key didn’t work when I tested it on script side (most probably a typing error on my side). But I anyway wanted Dialogs… so that works fine for me now.
Also: I somehow don’t like to use Q… when there is an explicit command so I will stick with the code below. 😃
For reference to other Readers:
In the web.config the relevant block Looks like this (look at the LocalTextPackages entry):
Here you can see that Dialogs. is one of the key prefixes which are supported by Default by serenity. If you want to have your own key prefixes also transported to the script side, add them here.
On the script side (e.g. within xyzDialog.cs), you can use These texts like this:
With Kind regards,
John
LocalText doesnt send all texts to script side. There is a LocalTextPackages configuration in web.config that contains which texts are sent. This is to limit size as not all texts are used in script. Either start your texts with ones in wen.config Dialogs Forms etc or add your prefix there. Should add a topic about this.