withPreferredLocale

Learn how to set the preferred locale for the content.

This method sets the preferred locale for the content.

When the content is not available in that locale, it is returned in your workspace’s default locale.

Signature

This method has the following signature:

public function withPreferredLocale(string $preferredLocale): self

This method returns a copy of the options with the change applied, leaving the original unchanged.

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\FetchOptions;
$options = FetchOptions::defaults()->withPreferredLocale('en-us');

Parameters

The following list describes the supported parameters:

preferredLocale
string

The preferred locale for the content, as a language tag such as en-us.