2

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 1

5

Dates are rendered as culture-specific unless specified explicitly.

SXA provide date format from variant item to field renderer and later Sitecore handle everything. enter image description here

The only thing you can change is format: enter image description here

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

enter image description here

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.