> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # SetVisitorPrimaryLocale # Package: localeManagement # Namespace: LocalesService # Method link: https://dev.wix.com/docs/api-reference/business-management/multilingual/locale-management/locales/set-visitor-primary-locale.md ## Permission Scopes: Wix Multilingual: SCOPE.MULTILINGUAL.MANAGE_TRANSLATIONS ## Introduction Sets a locale as the visitor primary locale for the site. Only one locale can be set as the visitor primary locale at a time. When you update the visitor primary locale, site visitors see the new default language on their next page load.
Important: The specified locale's `visibility` must be set to `"VISIBLE"`.
--- ## REST API ### Schema ``` Method: setVisitorPrimaryLocale Description: Sets a locale as the visitor primary locale for the site. Only one locale can be set as the visitor primary locale at a time. When you update the visitor primary locale, site visitors see the new default language on their next page load.
Important: The specified locale's `visibility` must be set to `"VISIBLE"`.
URL: https://www.wixapis.com/v2/locale/set-visitor-primary Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: localeId Method parameters: param name: localeId | type: localeId | description: GUID of the locale to set as visitor primary. | required: true Return type: SetVisitorPrimaryLocaleResponse - name: locale | type: Locale | description: Updated locale that is now set as the visitor primary locale. - name: id | type: string | description: Locale GUID. The locale GUID is made up of the language and region codes supported by Wix. For example, `"en-US"` for U.S. English. - name: revision | type: string | description: Revision number, which increments by 1 each time the locale is updated. To prevent conflicting changes, the existing revision must be passed when updating the locale object. - name: createdDate | type: string | description: Date and time the locale was created. - name: updatedDate | type: string | description: Date and time the locale was last updated. - name: languageCode | type: string | description: Language code. For example, `"en"` for English. - name: regionCode | type: string | description: Region code. For example, `"UK"` for United Kingdom. - name: visibility | type: LocaleVisibility | description: Locale visibility status. - enum: - HIDDEN: Locale is hidden from site visitors. A site's locale should be hidden when a translation is not ready to be exposed to visitors. - VISIBLE: Locale is visible to site visitors. A site can only have up to 100 visible locales. - name: primaryLocale | type: boolean | description: Whether the locale is the site's primary locale. - name: visitorPrimaryLocale | type: boolean | description: Whether the locale is the site's visitor primary locale. - name: flag | type: string | description: Flag icon as a 3-letter language code based on Wix's supported locales. For example, `"USA"` for the United States flag icon. - name: regionalFormat | type: string | description: Regional format for determining how to display data types such as dates, times, numbers, and currencies. For example, `"en-US"` to format dates like this: `MM-DD-YYYY`. - name: effectiveUrlStructure | type: UrlStructure | description: Default URL structure for the locale's live site URL, based on the locale's settings, unless overridden. - enum: - SUBDIRECTORY: URL structure as a subdirectory. For example, `"www.mysite.com/fr"`. - SUBDOMAIN: URL structure as a subdomain. For example, `"fr.mysite.com"`. - QUERY_PARAM: URL structure as a query parameter. For example, `"www.mysite.com?lang=fr"`. - name: urlStructureOverride | type: UrlStructureOverride | description: Optional override for the locale's default URL structure. - name: urlStructure | type: UrlStructure | description: URL structure to use instead of the default. - name: machineTranslationCode | type: string | description: Language code based on Wix's supported locales, used to specify the target language when translatable content is sent for machine translation. For example, `"ES"` for Spanish or `"ZH_TW"` for Traditional Chinese. Default: The locale's `languageCode` value. - name: effectiveDisplayName | type: string | description: The locale's `displayName`, unless overridden. - name: displayName | type: string | description: Default display name for the locale, inferred from the locale GUID and region code. - name: overrideDisplayName | type: string | description: Optional override for the locale's display name. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCALE_NOT_FOUND | Description: Couldn't find the locale. ``` ### Examples ### Set Visitor Primary Locale ```curl curl -X POST \ 'https://www.wixapis.com/locales/v2/locale/set-visitor-primary' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-binary '{ "localeId": "fr" }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.localeManagement.LocalesService.setVisitorPrimaryLocale(localeId) Description: Sets a locale as the visitor primary locale for the site. Only one locale can be set as the visitor primary locale at a time. When you update the visitor primary locale, site visitors see the new default language on their next page load.
Important: The specified locale's `visibility` must be set to `"VISIBLE"`.
# Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: localeId Method parameters: param name: localeId | type: string | description: GUID of the locale to set as visitor primary. | required: true Return type: PROMISE - name: locale | type: Locale | description: Updated locale that is now set as the visitor primary locale. - name: _id | type: string | description: Locale GUID. The locale GUID is made up of the language and region codes supported by Wix. For example, `"en-US"` for U.S. English. - name: revision | type: string | description: Revision number, which increments by 1 each time the locale is updated. To prevent conflicting changes, the existing revision must be passed when updating the locale object. - name: _createdDate | type: Date | description: Date and time the locale was created. - name: _updatedDate | type: Date | description: Date and time the locale was last updated. - name: languageCode | type: string | description: Language code. For example, `"en"` for English. - name: regionCode | type: string | description: Region code. For example, `"UK"` for United Kingdom. - name: visibility | type: LocaleVisibility | description: Locale visibility status. - enum: - HIDDEN: Locale is hidden from site visitors. A site's locale should be hidden when a translation is not ready to be exposed to visitors. - VISIBLE: Locale is visible to site visitors. A site can only have up to 100 visible locales. - name: primaryLocale | type: boolean | description: Whether the locale is the site's primary locale. - name: visitorPrimaryLocale | type: boolean | description: Whether the locale is the site's visitor primary locale. - name: flag | type: string | description: Flag icon as a 3-letter language code based on Wix's supported locales. For example, `"USA"` for the United States flag icon. - name: regionalFormat | type: string | description: Regional format for determining how to display data types such as dates, times, numbers, and currencies. For example, `"en-US"` to format dates like this: `MM-DD-YYYY`. - name: effectiveUrlStructure | type: UrlStructure | description: Default URL structure for the locale's live site URL, based on the locale's settings, unless overridden. - enum: - SUBDIRECTORY: URL structure as a subdirectory. For example, `"www.mysite.com/fr"`. - SUBDOMAIN: URL structure as a subdomain. For example, `"fr.mysite.com"`. - QUERY_PARAM: URL structure as a query parameter. For example, `"www.mysite.com?lang=fr"`. - name: urlStructureOverride | type: UrlStructureOverride | description: Optional override for the locale's default URL structure. - name: urlStructure | type: UrlStructure | description: URL structure to use instead of the default. - name: machineTranslationCode | type: string | description: Language code based on Wix's supported locales, used to specify the target language when translatable content is sent for machine translation. For example, `"ES"` for Spanish or `"ZH_TW"` for Traditional Chinese. Default: The locale's `languageCode` value. - name: effectiveDisplayName | type: string | description: The locale's `displayName`, unless overridden. - name: displayName | type: string | description: Default display name for the locale, inferred from the locale GUID and region code. - name: overrideDisplayName | type: string | description: Optional override for the locale's display name. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: LOCALE_NOT_FOUND | Description: Couldn't find the locale. ``` ### Examples ### setVisitorPrimaryLocale ```javascript import { locales } from '@wix/multilingual'; async function setVisitorPrimaryLocale(localeId) { const response = await locales.setVisitorPrimaryLocale(localeId); }; ``` ### setVisitorPrimaryLocale (with elevated permissions) ```javascript import { locales } from '@wix/multilingual'; import { auth } from '@wix/essentials'; async function mySetVisitorPrimaryLocaleMethod(localeId) { const elevatedSetVisitorPrimaryLocale = auth.elevate(locales.setVisitorPrimaryLocale); const response = await elevatedSetVisitorPrimaryLocale(localeId); } ``` ### setVisitorPrimaryLocale (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { locales } from '@wix/multilingual'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { locales }, // Include the auth strategy and host as relevant }); async function setVisitorPrimaryLocale(localeId) { const response = await myWixClient.locales.setVisitorPrimaryLocale(localeId); }; ``` ---