Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.44 KB

languagecode_criterion.md

File metadata and controls

56 lines (40 loc) · 1.44 KB

LanguageCode Criterion

The LanguageCode Search Criterion searches for content based on whether it is translated into the selected language.

Arguments

  • value - string(s) representing the language codes to search for
  • (optional) matchAlwaysAvailable - bool representing whether content with the alwaysAvailable flag should be returned even if it does not contain the selected language (default true)

Example

PHP

$query->query = new Criterion\LanguageCode('ger-DE', false);

REST API

=== "XML"

```xml
<Query>
    <Filter>
        <LanguageCodeCriterion>eng-GB</LanguageCodeCriterion>
    </Filter>
</Query>
```

=== "JSON"

```json
"Query": {
    "Filter": {
        "LanguageCodeCriterion": "eng-GB"
    }
}
```

Use cases

You can use the LanguageCode Criterion to search for articles that are lacking a translation into a specific language:

[[= include_file('code_samples/search/language/src/Controller/ArticlesToTranslateController.php', 24, 41) =]]

You can use the LanguageCode Criterion to search in several languages while ensuring results have a translation in one specific language:

[[= include_file('code_samples/search/language/src/Command/SearchTestCommand.php', 35, 47) =]]