Skip to content

Commit

Permalink
CTC-1953 Explain localization requests in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jancerman committed Jun 7, 2024
1 parent 3fcb691 commit 1f25792
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Gets the Spanish variant of an article
query GetArticleInSpanish {
article(codename: "about_us", languageFilter: {languageCodename: "es-ES"}) {
title
# other elements
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Filters all articles to find the Spanish variant by its URL slug
query GetArticlesByLocalizedSlug {
article_All(where: {title: {eq: "acerda-de-nosotros"}}, languageFilter: {languageCodename: "es-ES"}) {
items {
title
# other elements
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Gets content items in Spanish without following language fallbacks
query GetArticlesInSpanishOnly {
article_All(
# Requests items in Spanish
languageFilter: {languageCodename: "es-ES"},
# Filters the items so that only Spanish is returned, ignoring language fallbacks
# Filters the items so that only Spanish is returned
where: {_system_: {language: {_system_: {codename: {eq: "es-ES"}}}}}) {
items {
title
# other elements
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// Registers the model class for articles
client.registerType(Article.class);

// Gets the Spanish variant of an article
// Gets a specific article in Spanish
CompletionStage<Article> item = client.getItem(
"about_us",
Article.class,
DeliveryParameterBuilder.params()
.language("es-ES")
.build()

);
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
// Registers the model class for articles
client.registerType(Article.class);

// Gets the Spanish variant of an "About us" content item that has "acerda-de-nosotros" in its "URL pattern" element
// Filters all articles to find the Spanish variant by its URL slug
CompletionStage<List<Article>> items = client.getItems(
Article.class,
DeliveryParameterBuilder.params()
.language("es-ES")
.filterEquals("system.type", "article")
.filterEquals("elements.url_pattern", "acerda-de-nosotros")
.build();
);
);
4 changes: 2 additions & 2 deletions java/get-localized-content/language_fallbacks_ignore.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// Initializes a DeliveryClient
DeliveryClient client = new DeliveryClient("<YOUR_ENVIRONMENT_ID>");

// Gets the Spanish variant of all content items (while ignoring language fallbacks)
// Gets content items in Spanish without following language fallbacks
CompletionsStage<ContentItemsListingResponse> listingResponse = client.getItems(
DeliveryParameterBuilder.params()
.language("es-ES")
.filterEquals("system.language", "es-ES")
.build()
);
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const deliveryClient = KontentDelivery.createDeliveryClient({
environmentId: '8d20758c-d74c-4f59-ae04-ee928c0816b7'
});

// Gets a specific article in Spanish
const response = await deliveryClient.item('about_us')
.languageParameter('es-ES')
.toPromise();
.toPromise();
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const deliveryClient = KontentDelivery.createDeliveryClient({
environmentId: '8d20758c-d74c-4f59-ae04-ee928c0816b7'
});

// Filters all articles to find the Spanish variant by its URL slug
const response = await deliveryClient.items('article')
.type('article')
.languageParameter('es-ES')
.depthParameter(0)
.equalsFilter('elements.url_pattern', 'acerda-de-nosotros')
.toPromise();
.toPromise();
3 changes: 2 additions & 1 deletion js/get-localized-content/language_fallbacks_ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const deliveryClient = KontentDelivery.createDeliveryClient({
environmentId: '975bf280-fd91-488c-994c-2f04416e5ee3',
});

// Gets content items in Spanish without following language fallbacks
const response = await deliveryClient.items()
.languageParameter('es-ES')
.equalsFilter('system.language', 'es-ES')
.toPromise();
.toPromise();
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;

// Creates an instance of the delivery client
// ProTip: Use DI for this in your apps https://kontent.ai/learn/net-register-client
// Tip: Use DI create Delivery client https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
.WithProjectId("8d20758c-d74c-4f59-ae04-ee928c0816b7")
.Build();

// Gets an article in Spanish
// Create strongly typed models according to https://kontent.ai/learn/net-strong-types
// Tip: Create strongly typed models according to https://kontent.ai/learn/net-strong-types
// Gets a specific article in Spanish
IDeliveryItemResponse<Article> response = await client.GetItemAsync<Article>("about_us",
new LanguageParameter("es-ES")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
.WithProjectId("8d20758c-d74c-4f59-ae04-ee928c0816b7")
.Build();

// Gets the 'About us' content item in Spanish based on the item's URL slug value
// Create strongly typed models according to https://kontent.ai/learn/net-strong-types
// Tip: Create strongly typed models according to https://kontent.ai/learn/net-strong-types
// Filters all articles to find the Spanish variant by its URL slug
IDeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>(
new LanguageParameter("es-ES"),
new EqualsFilter("system.type", "article"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

$client = new DeliveryClient('8d20758c-d74c-4f59-ae04-ee928c0816b7');

// Gets a specific article in Spanish
$items = $client->getItem('about_us', (new QueryParams())
->language('es-ES'));
?>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

$client = new DeliveryClient('8d20758c-d74c-4f59-ae04-ee928c0816b7');

// Filters all articles to find the Spanish variant by its URL slug
$items = $client->getItems((new QueryParams())
->language('es-ES')
->equals('system.type', 'article')
Expand Down
1 change: 1 addition & 0 deletions php/get-localized-content/language_fallbacks_ignore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

$client = new DeliveryClient('975bf280-fd91-488c-994c-2f04416e5ee3');

// Gets content items in Spanish without following language fallbacks
$items = $client->getItems((new QueryParams())
->language('es-ES')
->equals('system.language', 'es-ES'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Gets a specific article in Spanish
curl --request GET \
--url 'https://deliver.kontent.ai/8d20758c-d74c-4f59-ae04-ee928c0816b7/items/about_us?language=es-ES' \
--header 'content-type: application/json'
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Filters all articles to find the Spanish variant by its URL slug
curl --request GET \
--url 'https://deliver.kontent.ai/8d20758c-d74c-4f59-ae04-ee928c0816b7/items?language=es-ES&system.type=article&elements.url_pattern=acerda-de-nosotros' \
--header 'content-type: application/json'
1 change: 1 addition & 0 deletions rest/get-localized-content/language_fallbacks_ignore.curl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Gets content items in Spanish without following language fallbacks
curl --request GET \
--url 'https://deliver.kontent.ai/975bf280-fd91-488c-994c-2f04416e5ee3/items?language=es-ES&system.language=es-ES' \
--header 'content-type: application/json'
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
require 'delivery-sdk-ruby'

delivery_client = Kontent::Ai::Delivery::DeliveryClient.new project_id: '8d20758c-d74c-4f59-ae04-ee928c0816b7'

# Gets a specific article in Spanish
delivery_client.item('about_us')
.language('es-ES')
.execute do |response|
item = response.item
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
require 'delivery-sdk-ruby'

delivery_client = Kontent::Ai::Delivery::DeliveryClient.new project_id: '8d20758c-d74c-4f59-ae04-ee928c0816b7'

# Filters all articles to find the Spanish variant by its URL slug
delivery_client.items([
'system.type'.eq('article'),
'elements.url_pattern'.eq('acerda-de-nosotros')
])
.language('es-ES')
.execute do |response|
items = response.items
end
end
4 changes: 3 additions & 1 deletion ruby/get-localized-content/language_fallbacks_ignore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
require 'delivery-sdk-ruby'

delivery_client = Kontent::Ai::Delivery::DeliveryClient.new project_id: '975bf280-fd91-488c-994c-2f04416e5ee3'

# Gets content items in Spanish without following language fallbacks
delivery_client.items(['system.language'.eq('es-ES')])
.language('es-ES')
.execute do |response|
items = response.items
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const deliveryClient = createDeliveryClient({
environmentId: '8d20758c-d74c-4f59-ae04-ee928c0816b7',
});

// Gets a specific article in Spanish
const response = await deliveryClient.item<Article>('about_us')
.languageParameter('es-ES')
.toPromise();
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const deliveryClient = createDeliveryClient({
environmentId: '8d20758c-d74c-4f59-ae04-ee928c0816b7',
});

// Filters all articles to find the Spanish variant by its URL slug
const response = await deliveryClient.items<Article>()
.type('article')
.languageParameter('es-ES')
Expand Down
1 change: 1 addition & 0 deletions ts/get-localized-content/language_fallbacks_ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const deliveryClient = createDeliveryClient({
environmentId: '975bf280-fd91-488c-994c-2f04416e5ee3',
});

// Gets content items in Spanish without following language fallbacks
const response = await deliveryClient.items()
.languageParameter('es-ES')
.equalsFilter('system.language', 'es-ES')
Expand Down

0 comments on commit 1f25792

Please sign in to comment.