Skip to content

Commit

Permalink
Update multilingual-apps.md
Browse files Browse the repository at this point in the history
  • Loading branch information
quinntracy authored Jan 27, 2025
1 parent b984a22 commit 553de96
Showing 1 changed file with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,82 +31,82 @@ Combine the languages in the two entities into a single view. To do this, join t
1. Open your domain model and add a new view entity named *AllProductTranslationVE*.
2. Add the following query for your entity:

```
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
coalesce(pt.Description, p.Description) as Description
FROM Shop.Product p
JOIN p/Shop.ProductTranslation_Product/Shop.ProductTranslation pt
UNION
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
cast('en_US' as STRING) as LanguageCode,
p.Description as Description
FROM Shop.Product p
```
```
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
coalesce(pt.Description, p.Description) as Description
FROM Shop.Product p
JOIN p/Shop.ProductTranslation_Product/Shop.ProductTranslation pt
UNION
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
cast('en_US' as STRING) as LanguageCode,
p.Description as Description
FROM Shop.Product p
```
{{< figure src="/attachments/refguide/modeling/domain-model/view-entities/multilingual-apps/all-product-translation-ve.png" width="200" >}}
3. Filter the translation that corresponds to the user’s current language by creating a new view entity. Name this new entity *TranslatedProductVE*.
4. Add the query below to your entity:
```
SELECT
pt.ProductId as ProductId,
pt.ProductName as ProductName,
pt.QuantityPerUnit as QuantityPerUnit,
pt.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
pt.Description as Description
FROM Shop.AllProductTranslationVE pt
LEFT JOIN System.User as u on (u.ID = '[%CurrentUser%]')
LEFT JOIN u/System.User_Language/System.Language as l
WHERE (l.Code = pt.LanguageCode)
```
```
SELECT
pt.ProductId as ProductId,
pt.ProductName as ProductName,
pt.QuantityPerUnit as QuantityPerUnit,
pt.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
pt.Description as Description
FROM Shop.AllProductTranslationVE pt
LEFT JOIN System.User as u on (u.ID = '[%CurrentUser%]')
LEFT JOIN u/System.User_Language/System.Language as l
WHERE (l.Code = pt.LanguageCode)
```
{{< figure src="/attachments/refguide/modeling/domain-model/view-entities/multilingual-apps/translated-product-ve.png" width="200" >}}
Alternatively, you can also combine the view entities into one with a nested query:
```
SELECT
cp.ProductId as ProductId,
cp.ProductName as ProductName,
cp.QuantityPerUnit as QuantityPerUnit,
cp.Discontinued as Discontinued,
cp.Description as Description,
cp.LanguageCode as LanguageCode
FROM
(
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
coalesce(pt.Description, p.Description) as Description
FROM Shop.Product p
JOIN p/Shop.ProductTranslation_Product/Shop.ProductTranslation pt
UNION
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
cast('en_US' as STRING) as LanguageCode,
p.Description as Description
FROM Shop.Product p
) as cp
LEFT JOIN System.User as u on (u.ID = '[%CurrentUser%]')
LEFT JOIN u/System.User_Language/System.Language as l
WHERE (l.Code = cp.LanguageCode)
```
```
SELECT
cp.ProductId as ProductId,
cp.ProductName as ProductName,
cp.QuantityPerUnit as QuantityPerUnit,
cp.Discontinued as Discontinued,
cp.Description as Description,
cp.LanguageCode as LanguageCode
FROM
(
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
pt.LanguageCode as LanguageCode,
coalesce(pt.Description, p.Description) as Description
FROM Shop.Product p
JOIN p/Shop.ProductTranslation_Product/Shop.ProductTranslation pt
UNION
SELECT
p.ProductId as ProductId,
p.ProductName as ProductName,
p.QuantityPerUnit as QuantityPerUnit,
p.Discontinued as Discontinued,
cast('en_US' as STRING) as LanguageCode,
p.Description as Description
FROM Shop.Product p
) as cp
LEFT JOIN System.User as u on (u.ID = '[%CurrentUser%]')
LEFT JOIN u/System.User_Language/System.Language as l
WHERE (l.Code = cp.LanguageCode)
```
5. Generate an overview page for the view entity by right-clicking **TranslatedProductVE** > **Generate overview pages**.
6. Open the new page and remove the columns you do not need from the data grid.
Expand Down

0 comments on commit 553de96

Please sign in to comment.