Skip to content

Commit

Permalink
Restore updates to LocaleFreshness
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwheeler committed Mar 12, 2024
1 parent 226e838 commit 490c320
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 49 deletions.
8 changes: 4 additions & 4 deletions Projects/Modules/Documentarian.MicrosoftDocs/.DevX.jsonc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"ManifestData": {
"Guid": "a054ec31-cb69-4a4b-b66b-39d25e909615",
"ModuleVersion": "0.0.2",
"ModuleVersion": "0.0.3",
"RootModule": "Documentarian.MicrosoftDocs.psm1",
"ScriptsToProcess": "Init.ps1",
"ScriptsToProcess": "",
"VariablesToExport": "*",
"Author": "PowerShell Docs Team",
"CompanyName": "Microsoft",
Expand All @@ -29,8 +29,8 @@
"ModuleLicenseNotice": "Licensed under the MIT License.",
"ModuleLineEnding": "\n",
"ModuleName": "Documentarian.MicrosoftDocs",
"ModuleVersion": "0.0.1",
"ModuleVersion": "0.0.3",
"OutputFolderPath": "./[[ManifestData.ModuleVersion]]",
"SourceFolderPath": "./Source",
"SourceInitScriptPath": "./Source/Init.ps1"
// "SourceInitScriptPath": "./Source/Init.ps1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gets the `ms.date` metadata information of a Docs article for every locale.
## SYNTAX

```
Get-LocaleFreshness [-Uri] <uri> [[-Locales] <string[]>] [<CommonParameters>]
Get-LocaleFreshness [-Uri] <uri> [[-Locale] <string[]>] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -24,6 +24,8 @@ Gets the `ms.date` metadata information of a Docs article for every locale. The
locale information and the translation method. This is useful to see that the localization process
has picked up the latest changes made to the English version of the article.

For comparison, the output of the cmdlet always includes the English version of the article.

## EXAMPLES

### Example 1 - Get the freshness data for an article
Expand Down Expand Up @@ -80,8 +82,9 @@ Get-LocaleFreshness $url pt-br, pt-pt
```Output
locpath locale ms.contentlocale ms.translationtype ms.date loc_version updated_at
------- ------ ---------------- ------------------ ------- ----------- ----------
pt-br pt-br pt-br HT 05/31/2022 2022-07-18T20:00:40.4523397Z 2022-08-17 10:12 PM
pt-pt pt-pt pt-pt MT 05/31/2022 2022-07-18T20:00:40.4523397Z 2022-08-17 10:12 PM
en-us en-us 01/09/2023 2023-09-05 09:55 PM
pt-br pt-br pt-br HT 01/09/2023 2023-09-26T22:04:42.7240190Z 2023-10-13 11:23 PM
pt-pt pt-pt pt-pt MT 01/09/2023 2023-10-26T21:59:59.7444562Z 2023-10-26 11:59 PM
```

### Example 3 - Get the full freshness data for an article for select languages
Expand All @@ -94,48 +97,51 @@ Get-LocaleFreshness $url pt-br | Format-List -Property *
```

```Output
locpath : en-us
locale : en-us
ms.contentlocale :
ms.translationtype :
ms.date : 01/09/2023
loc_version :
updated_at : 2023-09-05 09:55 PM
loc_source_id :
loc_file_id :
original_content_git_url : https://github.com/MicrosoftDocs/PowerShell-Docs/blob/live/reference/docs-conceptual/install/In
stalling-PowerShell-on-Linux.md
locpath : pt-br
locale : pt-br
ms.contentlocale : pt-br
ms.translationtype : HT
ms.date : 05/31/2022
loc_version : 2022-07-18T20:00:40.4523397Z
updated_at : 2022-08-17 10:12 PM
ms.date : 01/09/2023
loc_version : 2023-09-26T22:04:42.7240190Z
updated_at : 2023-10-13 11:23 PM
loc_source_id : Github-44411511#live
loc_file_id : Github-44411511.live.PowerShell.PowerShell_PowerShell-docs_reference.docs-conceptual/install
/Installing-PowerShell-on-Linux.md
original_content_git_url : https://github.com/MicrosoftDocs/PowerShell-Docs/blob/live/reference/docs-conceptual/install
/Installing-PowerShell-on-Linux.md
loc_file_id : Github-44411511.live.PowerShell.PowerShell_PowerShell-docs_reference.docs-conceptual/install/In
stalling-PowerShell-on-Linux.md
original_content_git_url : https://github.com/MicrosoftDocs/PowerShell-Docs/blob/live/reference/docs-conceptual/install/In
stalling-PowerShell-on-Linux.md
```

## PARAMETERS

### -Locales
### -Locale

An array of one or more locale strings. The parameter default defaults to the following array of
values:

- `en-us`
- `cs-cz`
- `de-de`
- `es-es`
- `fr-fr`
- `hu-hu`
- `id-id`
- `it-it`
- `ja-jp`
- `ko-kr`
- `nl-nl`
- `pl-pl`
- `pt-br`
- `pt-pt`
- `ru-ru`
- `sv-se`
- `tr-tr`
- `zh-cn`
- `zh-tw`

The value can be any valid locale identifier string.
- `ar-sa`, `cs-cz`, `de-de`, `en-us`, `es-es`, `fr-fr`, `hu-hu`, `id-id`, `it-it`, `ja-jp`, `ko-kr`,
`nl-nl`, `pl-pl`, `pt-br`, `pt-pt`, `ru-ru`, `sv-se`, `tr-tr`, `zh-cn`, `zh-tw`

The value can be any of the locales supported by the docs platform:

- `ar-sa`, `bg-bg`, `bs-latn-ba`, `ca-es`, `cs-cz`, `da-dk`, `de-at`, `de-ch`, `de-de`, `el-gr`,
`en-au`, `en-ca`, `en-gb`, `en-ie`, `en-in`, `en-my`, `en-nz`, `en-sg`, `en-us`, `en-za`, `es-es`,
`es-mx`, `et-ee`, `eu-es`, `fi-fi`, `fil-ph`, `fr-be`, `fr-ca`, `fr-ch`, `fr-fr`, `ga-ie`,
`gl-es`, `he-il`, `hi-in`, `hr-hr`, `hu-hu`, `id-id`, `is-is`, `it-ch`, `it-it`, `ja-jp`, `ka-ge`,
`kk-kz`, `ko-kr`, `lb-lu`, `lt-lt`, `lv-lv`, `ms-my`, `mt-mt`, `nb-no`, `nl-be`, `nl-nl`, `pl-pl`,
`pt-br`, `pt-pt`, `ro-ro`, `ru-ru`, `sk-sk`, `sl-si`, `sr-cyrl-rs`, `sr-latn-rs`, `sv-se`,
`th-th`, `tr-tr`, `uk-ua`, `vi-vn`, `zh-cn`, `zh-hk`, `zh-tw`

```yaml
Type: System.String[]
Expand All @@ -144,14 +150,14 @@ Aliases:

Required: False
Position: 1
Default value: en-us, cs-cz, de-de, es-es, fr-fr, hu-hu, id-id, it-it, ja-jp, ko-kr, nl-nl, pl-pl, pt-br, pt-pt, ru-ru, sv-se, tr-tr, zh-cn, zh-tw
Default value: 'ar-sa', 'en-us', 'cs-cz', 'de-de', 'es-es', 'fr-fr', 'hu-hu', 'id-id', 'it-it', 'ja-jp', 'ko-kr', 'nl-nl', 'pl-pl', 'pt-br', 'pt-pt', 'ru-ru', 'sv-se', 'tr-tr', 'zh-cn', 'zh-tw'
Accept pipeline input: False
Accept wildcard characters: False
```
### -Uri
The URL to the article being inspected. The URL must contain a locale.
The URL to the article being inspected. The URL must contain a supported locale.
```yaml
Type: System.Uri
Expand Down Expand Up @@ -188,4 +194,6 @@ tags are set by the build system when the article is published.

## NOTES

This cmdlet depends on the `Get-HtmlMetaTags` cmdlet.

## RELATED LINKS
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
// "IgnoreForBuild": false,
// "IgnoreForTest": false
// }
{
"Name": "LearnLocales",
"IgnoreForBuild": false,
"IgnoreForTest": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class LearnLocales {

## This list of locales is based on the language selection page on the Learn platform.

static [string[]]$SupportedLocales = 'ar-sa', 'bg-bg', 'bs-latn-ba', 'ca-es', 'cs-cz', 'da-dk',
'de-at', 'de-ch', 'de-de', 'el-gr', 'en-au', 'en-ca', 'en-gb', 'en-ie', 'en-in', 'en-my',
'en-nz', 'en-sg', 'en-us', 'en-za', 'es-es', 'es-mx', 'et-ee', 'eu-es', 'fi-fi', 'fil-ph',
'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'ga-ie', 'gl-es', 'he-il', 'hi-in', 'hr-hr', 'hu-hu',
'id-id', 'is-is', 'it-ch', 'it-it', 'ja-jp', 'ka-ge', 'kk-kz', 'ko-kr', 'lb-lu', 'lt-lt',
'lv-lv', 'ms-my', 'mt-mt', 'nb-no', 'nl-be', 'nl-nl', 'pl-pl', 'pt-br', 'pt-pt', 'ro-ro',
'ru-ru', 'sk-sk', 'sl-si', 'sr-cyrl-rs', 'sr-latn-rs', 'sv-se', 'th-th', 'tr-tr', 'uk-ua',
'vi-vn', 'zh-cn', 'zh-hk', 'zh-tw'

## Most docs are trnaslated into a subset of 19 locales.

static [string[]]$CommonLocales = 'ar-sa', 'en-us', 'cs-cz', 'de-de', 'es-es', 'fr-fr', 'hu-hu',
'id-id', 'it-it', 'ja-jp', 'ko-kr', 'nl-nl', 'pl-pl', 'pt-br', 'pt-pt', 'ru-ru', 'sv-se',
'tr-tr', 'zh-cn', 'zh-tw'

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

using module ..\Classes\LearnLocales.psm1

function Get-LocaleFreshness {

[CmdletBinding()]
Expand All @@ -10,23 +12,21 @@ function Get-LocaleFreshness {
[uri]$Uri,

[Parameter(Position = 1)]
[ValidatePattern('[a-z]{2}-[a-z]{2}')]
[string[]]$Locales = (
'en-us', 'cs-cz', 'de-de', 'es-es', 'fr-fr', 'hu-hu', 'id-id', 'it-it',
'ja-jp', 'ko-kr', 'nl-nl', 'pl-pl', 'pt-br', 'pt-pt', 'ru-ru', 'sv-se',
'tr-tr', 'zh-cn', 'zh-tw'
)
[ValidateScript({$_ -in [LearnLocales]::SupportedLocales})]
[string[]]$Locale = [LearnLocales]::CommonLocales
)

$locale = $uri.Segments[1].Trim('/')
if ($locale -notmatch '[a-z]{2}-[a-z]{2}') {
Write-Error "URL does not contain a valid locale: $locale"
$localeInUrl = $uri.Segments[1].Trim('/')
if ($localeInUrl -notin [LearnLocales]::SupportedLocales) {
Write-Error "URL does not contain a supported locale: $localeInUrl"
return
} else {

$url = $uri.OriginalString
$Locales | ForEach-Object {
if ($Locale -notcontains 'en-us') { $Locale += 'en-us' }
$Locale | ForEach-Object {
$locPath = $_
$result = Get-HtmlMetaTags ($url -replace $locale, $locPath) |
$result = Get-HtmlMetaTags ($url -replace $localeInUrl, $locPath) |
Select-Object @{n = 'locpath'; e = { $locPath } }, locale, 'ms.contentlocale',
'ms.translationtype', 'ms.date', 'loc_version', 'updated_at', 'loc_source_id',
'loc_file_id', 'original_content_git_url'
Expand Down

0 comments on commit 490c320

Please sign in to comment.