I am using variant Date field to display format as "25 September 2017", when language changed to Arabic it displays Hijri Date, is there a way to control the format to show gregorian calendar with the month names translated to arabic?
1 Answer
Dates are rendered as culture-specific unless specified explicitly.
SXA provide date format from variant item to field renderer and later Sitecore handle everything.
The only thing you can change is format:
If you cannot fix it with different variant of language, then you will have to provide your culture
manually.
There is a class in Sitecore called DataRendered
used by FieldRendered to render a date. Notice that there is a way of providing culture
What does it mean? That you can provide an additional parameter culture
to a field rendered and explicitly say what your culture should be.
Unfortunately, SXA does not provide you an ability to inject custom parameters to field renderer (good idea to add this in the future).
Here is a processor to override:
Sitecore.XA.Foundation.RenderingVariants.Pipelines.RenderVariantField.RenderVariantField
Find following method
protected virtual Control CreateFieldRenderer(Sitecore.XA.Foundation.RenderingVariants.Fields.VariantField variantField, Item item, bool isControlEditable, bool isFromComposite)
and extend control.Parameters
string with your additional parameter. It depends on you where you get it (item, configuration).
Good luck.