Still the issue appears in generated code (Lang.cs) , not in user code:
KeyNotFoundException: The given key 'value' was not present in the dictionary.
ASPNETMaker2023.Models.EvOLT_2_0+Lang+<>c.<PhrasesToJson>b__36_1(KeyValuePair<string, object> kvp) in Lang.cs
+
.ToDictionary(kvp => kvp.Key, kvp => (string)kvp.Value["value"]);
System.Linq.Enumerable.ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
System.Linq.Enumerable.ToDictionary<TSource, TKey, TElement>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
OK, problem is in the translation file. Switching the default language to English, app works with no issue.
Any idea how to capture the exact phrase which is failing?
Ay some point I have identified a phrase which was missing the “value” attribute, but that was not an issue on an another project which renders ok my translated language.
You can always turn on Tools → Advanced Settings → Debug to find more info.
It was from the phrase with missing value attribute, in translation file.
An idea to update the PhrasesToJson method in Lang.js, to filter out pharses without “value”:
// Output phrases as JSON
public async Task PhrasesToJson(dynamic phrases)
{
Dictionary<string, string> dict = ((Dictionary<string, dynamic>)phrases)
.Where(kvp => kvp.Value["value"] != null)
.ToDictionary(kvp => kvp.Key, kvp => (string)kvp.Value["value"]);
foreach (var (key, value) in dict) {
await _writer.WritePropertyNameAsync(key);
await _writer.WriteValueAsync(value);
}
}
Thanks for your time!