-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: main
Are you sure you want to change the base?
Conversation
@stephengillie Opened up this one. Hope you don't mind the docs for the module here. |
fdd3054
to
b482a12
Compare
|
||
| **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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `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. | |
resources/Microsoft.Windows.Setting.Language/Microsoft.Windows.Setting.Language.psm1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Language/Microsoft.Windows.Setting.Language.psm1
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Language/Microsoft.Windows.Setting.Language.psm1
Outdated
Show resolved
Hide resolved
# 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))) { |
There was a problem hiding this comment.
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.
static [void] GetInstalledLocality() { | ||
[Language]::InstalledLocality = @{} | ||
|
||
foreach ($locality in [Language]::Export()) { | ||
[Language]::InstalledLocality[$locality.LocaleName] = $locality | ||
} | ||
} | ||
#endRegion Language helper functions |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
return @{ | ||
LocaleName = $this.LocaleName | ||
Exist = $true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be removed?
# 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 |
There was a problem hiding this comment.
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.
# TODO: How do we handle sign out and sign in? | ||
Set-WinUserLanguageList -Language $this.LocaleName |
There was a problem hiding this comment.
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.
9d56ef3
to
41a4038
Compare
…n/winget-dsc into windows-setting-language
@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. |
@Gijsreyn I converted this to a draft PR until you're ready for review/merge. |
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. |
Addresses issue #34 and #92. Only the module this time.
Microsoft Reviewers: Open in CodeFlow