---
title: "detectWebpageLocale(for:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensiontab/detectwebpagelocale(for:completionhandler:)"
---

# detectWebpageLocale(for:completionHandler:)

Called to detect the locale of the webpage currently loaded in the tab.

## Declaration

```swift
optional func detectWebpageLocale(for context: WKWebExtensionContext, completionHandler: @escaping (Locale?, (any Error)?) -> Void)
```

```swift
optional func detectWebpageLocale(for context: WKWebExtensionContext) async throws -> Locale?
```

## Parameters

- `context`: The context in which the web extension is running.
- `completionHandler`: A block that must be called upon completion. The block takes two arguments: the detected locale (or nil if the locale is unknown) and an error, which should be provided if any errors occurred.

## Discussion

Discussion No action is performed if not implemented.
