Skip to content

Commit

Permalink
Review edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant-Archibald-MS committed Dec 12, 2024
1 parent f20f181 commit e21288d
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 15 deletions.
7 changes: 7 additions & 0 deletions learning/07-updating-control-value-using-setproperty.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ To demonstrate a failing test, modify the assert statement to check for an incor
Assert(Label1.Text = "Incorrect Value", "Label1 should display 'Incorrect Value'")
```
6. Run the test
```pwsh
cd samples\buttonclicker
pwsh -File RunTests.ps1
```
## Summary
In this section, you learned how to use the `SetProperty` function in Power Fx to update control values in your Power Apps application. By including SetProperty statements in your test plans, you can modify control properties and verify the behavior of your application. This process involves adding SetProperty and assert statements to your test plan, running the test script, and reviewing the results to confirm that the control values are updated as expected.
Expand Down
42 changes: 39 additions & 3 deletions learning/10-using-simulations.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,52 @@ This section builds on concepts introduced in [Simulating Connector](./08-simula

## Let's Get Started

### Key Steps
### Getting Setup

To follow the steps in this module carry out the following actions.

1. Import the `WeatherSample_*.zip` solution file from the cloned repository using [Import solutions](https://learn.microsoft.com/power-apps/maker/data-platform/import-update-export-solutions).
2. Publish app customizations of the imported solution
3. Start the **Weather Snapshots** model driven application
4. Select **Allow** to consent to MSN Weather connection
5. Create config using instructions in [README](https://github.com/microsoft/PowerApps-TestEngine/blob/grant-archibald-ms/enhanced-sample-495/samples/weather/README.md) and steps in [Getting Started](../context/get-started-now#getting-started).
6. Run the test:

## Run Tests

1. Verify that the config file in the samples\weather has been configured for your environment, tennant and user1Email

```json
{
"tenantId": "a222222-1111-2222-3333-444455556666",
"environmentId": "12345678-1111-2222-3333-444455556666",
"customPage": "te_snapshots_24d69",
"appDescription": "Weather Sample",
"user1Email": "[email protected]",
"runInstall": true,
"installPlaywright": true,
"languages": [
{"id":1031, "name": "de-de", "file":"testPlan.eu.fx.yaml"},
{"id":1033, "name": "en-us", "file":"testPlan.fx.yaml"},
{"id":1036, "name": "fr-fr", "file":"testPlan.eu.fx.yaml"}
]
}
```

2. You have authenticated with the Power Platform CLI

```pwsh
pac auth create -name Dev --environment 12345678-1111-2222-3333-444455556666
```

3. You have logged into the Azure CLI with account that has access to the environment that you have deployed

```pwsh
az login --allow-no-subscriptions
```

4. Run the test

```pwsh
cd samples\weather
pwsh -File RunTests.ps1
```

Expand Down
133 changes: 121 additions & 12 deletions learning/11-localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ To complete this module you will need to follow instructions for setting up in [
This section assumes that French (LCID 1039) and German language (LCID 1031) have been enabled.
{: .notice--success}

> The sample application for this section is currently in a feature branch. This will require `git checkout grant-archibald-ms/enhanced-sample-495`
{: .notice--success}

## The Need for Localization

Localization is essential for several reasons:
Expand Down Expand Up @@ -81,28 +84,61 @@ cd examples\weather
.\Record.ps1
```


### Step 5: Expand to Another Language

Expanding the Model Driven application that contains a custom page and navigation to add a new language includes the applying these sets of changes for the WeatherSample application:
- Updating the translations to the Model Driven application. This will update the Display names of the Dataverse tables.
- Updating the locale settings for thr navigation mention to include new translation
- Updating the Power Fx of the Power Fx Language Component to include the new language

Lets step through each of these changes.

#### Model Driven Application Changes

To expand the example to another language, such as German (LCID 1031), follow these steps:
The general process to expand the example to another language, such as German (LCID 1031), follow these steps:
1. Export the translations and add a new column for German (1031). The [Translate customized table, form, and column text into other languages](https://learn.microsoft.com/power-apps/maker/data-platform/export-customized-entity-field-text-translation)
2. Update the translation file with the German translations.
3. Rezip the file and import the translations.
2. Update the translation file with the German translations. For this sample we have included the necessary German translations in the sample folder
3. In your file explorer zip the two files named **\[Content_Types\].xml** and **CrmTranslations.xml** into a zip file. For example **CrmTranslations.zip**
4. Open your WeatherSample solution in the maker portal.
5. Select the ... icon
6. Select **Switch to Classic**
7. From the menu select **Translations**
8. Select **Import Translations**
9. Select **Choose File**
10. Select the zip file you created above
11. Select **Import**

#### Model Driven Application Navigation Changes
1. Edit the `Weather Snapshots` Model Driven Application
2. Change the advanced settings of the navigation group to include German. For example [Add Localized Titles for Navigation Groups](https://learn.microsoft.com/power-apps/maker/model-driven-apps/app-navigation#create-a-group)
3. Publish the changes to the Model Driven Application to apply group name changes.

Next we will update the localized version of the custom page using the following steps:

1. Open your WeatherSample solution in the maker portal.
2. Select **Apps**
3. Edit the `Weather Snapshots` Model-Driven Application
4. Select the **Snapshots** custom page navigation item
5. Expand the **Advanced Settings**
6. Expand the **Locale** section
7. Select **Add localized title**
8. Select the Locale (LCID) German _Germany (1031)
9. Add the Localized title **Schnappschüsse**
10. Select **Apply**
11. Select the **Publish** from the top menu to save the changes to the Model Driven Application to apply group name changes.

#### Component Library Changes

1. Select `Localization` from solution Component libraries
Finally we will update the Component library to include translations used by the custom page.

1. Open your WeatherSample solution in the maker portal.

2. Select **Component libraries**

3. Select **Localization**`** from solution Component libraries

2. Edit the `Localization` item
4. Edit the **Localization** item

3. Update the component Power Fx to add "de-de" for the localization code library `Labels` of the "Translation Component" to include Table with Language "de-de". For example the original Labels could look like
5. Edit the **Translation Component** to update the components

6. Select the **Labels** property and update the Power Fx to add "de-de" translation. For example the original Labels could look like

```powerfx
LookUp(Table(
Expand Down Expand Up @@ -139,7 +175,7 @@ To expand the example to another language, such as German (LCID 1031), follow th
)).Labels
```
After applying changes new translations could look like
7. After applying changes new translations could look like
```powerfx
LookUp(
Expand Down Expand Up @@ -200,6 +236,79 @@ To expand the example to another language, such as German (LCID 1031), follow th
Once you have completed these changes you should be able to use English, French and German translations of the Weather Application.
## Testing you Changes
1. Verify that the config file in the samples\weather has been configured for your environment, tennant and user1Email
```json
{
"tenantId": "a222222-1111-2222-3333-444455556666",
"environmentId": "12345678-1111-2222-3333-444455556666",
"customPage": "te_snapshots_24d69",
"appDescription": "Weather Sample",
"user1Email": "[email protected]",
"runInstall": true,
"installPlaywright": true,
"languages": [
{"id":1031, "name": "de-de", "file":"testPlan.eu.fx.yaml"},
{"id":1033, "name": "en-us", "file":"testPlan.fx.yaml"},
{"id":1036, "name": "fr-fr", "file":"testPlan.eu.fx.yaml"}
]
}
```
2. You have authenticated with the Power Platform CLI
```pwsh
pac auth create -name Dev --environment 12345678-1111-2222-3333-444455556666
```
3. You have logged into the Azure CLI with account that has access to the environment that you have deployed
```pwsh
az login --allow-no-subscriptions
```
4. Run the test
```pwsh
cd samples\weather
pwsh -File RunTests.ps1
```
## Investigating Key Concepts
Lets investigate some key concepts that are important in this localizaed test.
### Power Fx to Set User Settings
Power Fx is a powerful formula language used in Power Apps to manipulate data and control app behavior. When setting user settings, especially for localization, Power Fx can be used to dynamically adjust the user interface based on the user's language preferences.
### Argument Delimiters in Non-English European Languages
In non-English European languages, the semicolon (`;`) is used instead of the comma (`,`) to delimit arguments in Power Fx functions. This means that when chaining multiple Power Fx functions, you should use `;;` as the separator.
### Language() Function
The `Language()` function in Power Fx returns the language tag of the current user's language. This function is essential for creating conditional logic based on the user's language. For example, you can use the `Language()` function to display different text based on the user's language setting.
### Example: Conditional Language Testing
To make the expected test conditional on the language being tested, you can use the `Assert` function along with `Switch` and `Language()` functions. Here is an example:
```powerfx
Assert(Summary.Text=
Switch(
Lower(Language());
"en-us"; "Match: Test Location, Temp: 30^F, Feels: 20^F, Sunny";
"fr-fr"; "Correspondance: Test Location, Température: 30^F, Ressenti: 20^F, Sunny";
"de-de"; "Übereinstimmung: Test Location, Temperatur: 30^F, Gefühlt: 20^F, Sunny"
)
)
```

In this example, the Switch function checks the user's language and validated the appropriate text for English (US), French (France), and German (Germany). The Assert function ensures that the Summary.Text matches the expected value based on the user's language.

## Summary

In this section, you learned about the importance of localization and how to test a localized Weather sample. Localization can be crucial for enhancing user experience, expanding market reach, and complying with regional requirements. The Power Platform provides robust support for localization in both Canvas and Model-Driven Applications.
Expand All @@ -208,4 +317,4 @@ You explored how to start the Weather application, change personal settings to s

To expand the example to another language, such as German, you followed steps to export translations, update the translation file, and import the translations. You also learned how to update the navigation group settings and component library to include the new language.

By following these steps, you can ensure that your Power Apps application supports multiple languages, making it more accessible and user-friendly for a global audience.
By following these steps, you can ensure and validate that your Power Apps application supports multiple languages, making it more accessible and user-friendly for a global audience.

0 comments on commit e21288d

Please sign in to comment.