Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows setting language #120

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Gijsreyn
Copy link
Contributor

@Gijsreyn Gijsreyn commented Nov 7, 2024


Addresses issue #34 and #92. Only the module this time.

Microsoft Reviewers: Open in CodeFlow

@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Nov 7, 2024

@stephengillie Opened up this one. Hope you don't mind the docs for the module here.

@Gijsreyn Gijsreyn force-pushed the windows-setting-language branch 2 times, most recently from fdd3054 to b482a12 Compare November 14, 2024 10:45

| **Parameter** | **Attribute** | **DataType** | **Description** | **Allowed Values** |
| ------------- | ------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| `LocaleName` | Mandatory | String | The name of the language. This is the language tag that represents the language. For example, `en-US` represents English (United States). | Use the `Get-WinUserLanguageList` to see what language pack have been installed. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `LocaleName` | Mandatory | String | The name of the language. This is the language tag that represents the language. For example, `en-US` represents English (United States). | Use the `Get-WinUserLanguageList` to see what language pack have been installed. |
| `LocaleName` | Mandatory | String | The name of the language. This is the language tag that represents the language. For example, `en-US` represents English (United States). | Use the `Get-WinUserLanguageList` to see which language packs have been installed. |

# helpful for users to discover what packages can be installed
$allLangues = [System.Globalization.CultureInfo]::GetCultures('AllCultures')
foreach ($culture in $allLangues) {
if ($out.LocaleName -notcontains $culture.Name -and -not ([string]::IsNullOrEmpty($culture.Name))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does $out.LocaleName return a collection of localeNames? I feel that this will be an error. Also whether $culture.Name is null/empty should be checked first in this if statement.

Comment on lines +137 to +144
static [void] GetInstalledLocality() {
[Language]::InstalledLocality = @{}

foreach ($locality in [Language]::Export()) {
[Language]::InstalledLocality[$locality.LocaleName] = $locality
}
}
#endRegion Language helper functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper function is slightly confusing for me. Why not just use the function in export and create the installed map in the constructor?


# check if user profile contains display language
$userProfileLanguageDict = TryGetRegistryValue -Key (Join-Path $global:LocaleUserProfilePath $this.LocaleName) -Property 'CachedLanguageName'
if ((TryGetRegistryValue -Key $global:LocaleNameRegistryPath -Property $this.KeyName) -ne $this.LocaleName -and ($null -ne $userProfileLanguageDict)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assign TryGetRegistryValue to a variable and then use the variable in the if condition for better readability.

Also you should check if $userProfileLanguagesDict is null first in this condition. What is $this.KeyName? I am not seeing that anywhere.

Comment on lines +186 to +189
return @{
LocaleName = $this.LocaleName
Exist = $true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be removed?

Comment on lines +197 to +200
# TODO: How do we handle sign out and sign in?
Set-WinUserLanguageList -Language $this.LocaleName

# TODO: Exist does not make sense here, we always want a language to exist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Exist doesn't make sense here, then you don't need to use it as a parameter. Just use LocaleName as the only parameter.

Comment on lines +197 to +198
# TODO: How do we handle sign out and sign in?
Set-WinUserLanguageList -Language $this.LocaleName
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would indicate to the user with a message that a reboot is required.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback This needs a response from the author. and removed Changes-Requested Changes Requested Needs-Author-Feedback This needs a response from the author. labels Nov 15, 2024
@Gijsreyn
Copy link
Contributor Author

Gijsreyn commented Dec 2, 2024

@ryfu-msft You can put this on hold. I'm seeing some strange behaviours with the relevant modules used to set language, plus a bug found on Windows PowerShell: PowerShell/PowerShellModuleCoverage#18.

@denelon I might need your help, but I'll test thoroughly first and let you know.

@denelon denelon marked this pull request as draft December 2, 2024 15:49
@denelon
Copy link
Contributor

denelon commented Dec 2, 2024

@Gijsreyn I converted this to a draft PR until you're ready for review/merge.

@stephengillie
Copy link
Collaborator

Apologies for my absent repsonse - I've been too busy maintaining the winget-pkgs repo, to be able to review this and provide feedback with constructive value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants