---
title: "dominantLanguage(for:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nslinguistictagger/dominantlanguage(for:)"
---

# dominantLanguage(for:)

Returns the dominant language for the specified string.

## Declaration

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

## Parameters

- `string`: The string for which the dominant language is determined.

## Return Value

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

Discussion The dominantLanguage(for:) method is a convenience method for creating a new linguistic tagger, setting the string property, and getting the 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: 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.

## See Also

### Determining the Dominant Language and Orthography

- [dominantLanguage](foundation/nslinguistictagger/dominantlanguage.md)
- [orthography(at:effectiveRange:)](foundation/nslinguistictagger/orthography(at:effectiverange:).md)
- [setOrthography(_:range:)](foundation/nslinguistictagger/setorthography(_:range:).md)
