Skip to content

Format date strings with the right locale#150133

Merged
sandy081 merged 2 commits intomicrosoft:mainfrom
aifreedom:date-string-locale
May 23, 2022
Merged

Format date strings with the right locale#150133
sandy081 merged 2 commits intomicrosoft:mainfrom
aifreedom:date-string-locale

Conversation

@aifreedom
Copy link
Copy Markdown
Contributor

@aifreedom aifreedom commented May 22, 2022

This PR fixes #140434

It's also a retake of @icepaq 's PR #141353, which has the discussion history.

This PR fixes the issue that the dates in the Extension details page are not formatted with the locale used in VS Code. The fix is fairly straightforward - get the locale string from vs/base/common/platform and pass it to Date.prototype.toLocaleString().

How to Test

  1. Add the following member to product.json to enable extension marketplace in the OSS dev build
"extensionsGallery": {
  "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
  "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
  "itemUrl": "https://marketplace.visualstudio.com/items"
},
  1. Use "Configure Display Language" to change the locale used in VS Code. I've tested with en, es, and zh-cn, covering date formats MM/DD/YYYY, DD/MM/YYYY, and YYYY/MM/DD.
  2. Go to the Extensions tab
  3. Search for an extension (eg, "Prettier")
  4. Ensure that the "Released on" and "Last updated" fields are rendered in the format specified by the locale.
en es zh-cn
Format MM/DD/YYYY DD/MM/YYYY YYYY/MM/DD
image image image

@sandy081 sandy081 enabled auto-merge May 23, 2022 10:51
@sandy081 sandy081 merged commit 2807672 into microsoft:main May 23, 2022
@aifreedom aifreedom deleted the date-string-locale branch May 23, 2022 15:13
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dates on extension page use American format regardless of display language

4 participants