This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
LanguageCode Criterion¶
The LanguageCode Search Criterion searches for content based on whether it's translated into the selected language.
Arguments¶
value- string(s) representing the language codes to search for- (optional)
matchAlwaysAvailable- bool representing whether content with thealwaysAvailableflag should be returned even if it doesn't contain the selected language (defaulttrue)
Example¶
PHP¶
1 | |
REST API¶
1 2 3 4 5 | |
1 2 3 4 5 | |
Use case¶
You can use the LanguageCode Criterion to search for articles that are lacking a translation
into a specific language:
``` php {skip-validation} hl_lines="5" $query = new LocationQuery; $query->query = new Criterion\LogicalAnd([ new Criterion\ContentTypeIdentifier('article'), new Criterion\LogicalNot( new Criterion\LanguageCode('ger-DE', false) ) ] );
$results = this->searchService->findContent(query); articles = []; foreach (results->searchHits as $searchHit) { $articles[] = $searchHit; }
return $this->render('list/articles_to_translate.html.twig', [ 'articles' => $articles, ]); ```