<!--
{
  "availability" : [
    "iOS: 11.0.0 - 27.0.0",
    "iPadOS: 11.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.13.0 - 27.0.0",
    "tvOS: 11.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 4.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSLinguisticTagger/dominantLanguage(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLinguisticTagger(cm)dominantLanguageForString:"
  },
  "title" : "dominantLanguage(for:)"
}
-->

# dominantLanguage(for:)

Returns the dominant language for the specified string.

```
class func dominantLanguage(for string: String) -> String?
```

## Parameters

`string`

The string for which the dominant language is determined.

## Return Value

The BCP-47 tag identifying the dominant language of the string, or the tag “und” if a specific language cannot be determined.

## Discussion

The [`dominantLanguage(for:)`](/documentation/Foundation/NSLinguisticTagger/dominantLanguage(for:)) method is a convenience method for creating a new linguistic tagger, setting the [`string`](/documentation/Foundation/NSLinguisticTagger/string) property, and getting the [`dominantLanguage`](/documentation/Foundation/NSLinguisticTagger/dominantLanguage) property. If you analyze the same string more than once, create a linguistic tagger object instead of calling the method, as shown in this example:

```swift
let text = "Die Kleinen haben friedlich zusammen gespielt."
NSLinguisticTagger.dominantLanguage(for: text) // "de"
```

In the example, the BCP-47 language tag “de” is returned as the dominant language, indicating that the text is in German.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)