Localization Operator Real-world Scenarios

In this section, we will look at a few real-world scenarios to understand how the localization operator helps perform more accurate searches in Contentstack.

Consider a scenario where you have the following languages available within your stack: English (United States), French (France), Chinese (China), and Spanish (Spain). English (United States) is set as the master language of the stack.

  • English (United States) is a fallback language of French (France);
  • French (France) is a fallback language of Chinese (China);
  • English (United States) is a fallback language for Spanish (Spain)

You have created 6 entries within a content type, and these entries have been localized in different languages. The following table shows the localized entries’ fallback relationships between each of the languages in which these entries have been localized:

Entry No.Master LanguageLocalized in
Entry 1English (United States)
  • French (France)
    Chinese (China)
Entry 2English (United States)
  • French (France)
Entry 3English (United States)
  • None
Entry 4English (United States)
  • French (France)
Entry 5English (United States)
  • French (France)
    Chinese (China)
Entry 6English (United States)
  • Spanish (Spain)

Now, let’s see some scenarios to understand how the localization operator will work in your search queries.

Case 1: Search for entries of “Chinese (China)” language.

To do this, select “Chinese (China)” as value for the Language field in the condition. Then use the Localized in operator and then select Any Locales as value:

image.png

The search result will include the following entry versions:

  • Entry 1 (localized in Chinese (China))
  • Entry 2 (localized in French (France), since French (France) is the fallback language for Chinese (China))
  • Entry 3 (master language [English (United States)])
  • Entry 4 (localized in French (France), since French (France) is the fallback language for Chinese (China))
  • Entry 5 (localized in Chinese (China))
  • Entry 6 (master language [English (United States)])

Notice that it brings the list of entries that are either localized in Chinese or can be localized in Chinese (but are not yet localized in Chinese). In the case of entries that are not yet localized in Chinese, it brings the immediate predecessor in the fallback lineage, if available.

So, in the above example, it returned Entry 2 (localized in French), but did not bring Entry 2 (English).

Case 2: Search for entries that are localized only in “Chinese (China)”

To do this, select “Chinese (China)” as value for the Language field in the condition. Then use the Localized in operator and select Chinese (China) as value:

image.png

The search result will include the following entry versions:

  • Entry 1 (localized in Chinese (China))
  • Entry 5 (localized in Chinese (China))

Here, only the entries localized in Chinese (China) show up in the search results.

Case 3: Search for entries yet to be localized in Chinese (China)

To do this, select “Chinese (China)” as value for the Language field in the condition. Then use the Not localized in operator and select Chinese (China) as value:

image.png

The search result will include the following entry versions:

  • Entry 2 localized in French (France)
  • Entry 3 master language [English (United States)]
  • Entry 4 localized in French (France)
  • Entry 6 master language [English (United States)]

Here, all entries except the ones localized in Chinese (China) show up in the search results. It fetches the entries that can be localized in Chinese (but are not yet localized in Chinese).

Case 4: Search for entries localized only in French (France) within the Chinese (China) language entries.

To do this, select “Chinese (China)” as value for the Language field in the condition. Then use the Localized in operator and select French (France) as value:

image.png

The search result will include the following entry versions:

  • Entry 2 localized in French (France)
  • Entry 4 localized in French (France)

Here, only the entries present in Chinese (China) language that have been localized in French (France) show up in the search results.

Was this article helpful?

Thanks for your feedbackSmile-icon

More articles in "Localization Operator for Language Field in Advanced Search"

On This Page

^