Closed harshdamaniahd closed 2 years ago
Hi @harshdamaniahd, it should work. I have updated my sample to support localization, once the PR is merged, do check out after cloning it.
yep it works normally for static content. but in quick view i have dynamic binding, how can i use strings.localizedfield ?
In your quickview.ts file you should see something like
import * as strings from 'MYACEAdaptiveCardExtensionStrings';
and in that file you can reference values like strings.MyLocalString
Add a reference to the strings object to the IQuickViewData like strings: IMYACEAdaptiveCardExtensionStrings;
and then in your data() method add it as a property like so strings: strings
In your template.json file you can reference any value like this ${strings.MyLocalString}
If you are inside of a loop of data then you might need to reference the root like this ${$root.strings.MyLocalString}
There will be more sample coming up with this methodology soon.
Hope that helps.
Hey thanks. I tired something similar. I created a constant file and used it import * as strings from "JobListingAdaptiveCardExtensionStrings";
export const FormTemplateLabels = {
daystoapply:strings.DaysToApply
};
export interface IQuickViewData {
jobPostings: IListPostings[];
//created a constant file
labels: any;
day:string;
}
public get data(): IQuickViewData {
return {
jobPostings: this.state.jobpostings,
labels:FormTemplateLabels,
day:strings.DaysToApply
};
}
tried both inside and outside loop
{
"type": "TextBlock",
"text": "${$root.days.daystoapply}",
"wrap": true
}
# # {
"type": "TextBlock",
"text": "${$root.labels.daystoapply}",
"wrap": true
}
but it doesnt work :-( dont know what is wrong
So what isn't working? Is it outputting no string or the wrong language.
Ahh now it works. Same code. :-) Thanks for help 👍 Let me test it and then i can go ahead and close it. 💯
resolved
Hi,
Like we can do localization for strings in SPFX, can we do the same thing in adaptive card templates ?
Also the text on the card for eg primary text, if we set it from localization file dynamically it doesnt work