GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Include localized diagnostics by mhegazy · Pull Request #18702 · microsoft/TypeScript

Conversation

@mhegazy

@mhegazy Mohamed Hegazy (mhegazy) commented Sep 22, 2017

Copy link
Copy Markdown
Contributor

Include localized error messages with the ts package. Localized error messages will be under lib\<locale id>\diagnosticMessages.generated.json. running tsc --locale rus for instance should load the diagnostic messages file from lib\rus\diagnosticMessages.generated.json.

for background, the diagnosticMessages.generated.json is a just a map from diagnostic message id => diagnostic message text. the compiler comes in with one already for English. When the --locale is passed, the compiler tries to load the .json map from a folder with matching locale name.

Messages are localized by the MS localization team. The communication with the loc team is all done in a specific XML formats, the .lcg files are used to specify the messages to be localized, the .lcl files have the result of the localization. The loc team will be monitoring the repo and should be periodically inserting new .lcl files with localized messages as we add/change messages.

The change adds:

  • Existing .lcl files we have used in previous version of the VS with localization for existing messages.
  • A script that converts src\compiler\diagnosticMessages.generated.json into the .lcg format and convert the existing .lcl files back into .json format.
  • Build files (jake/gulp) updates to allow for building the new localized messages.

Fixes #13703

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DanielRosenwasser, weswigham, and mishengqiang reacted with hooray emoji
All reactions
  • 🎉 3 reactions
Mohamed Hegazy (mhegazy) added 7 commits September 19, 2017 15:41
@mhegazy
Add lcl files
c5cb07e
@mhegazy
Add loclalization script
a622648
@mhegazy
Add localization build targets
96d748b
@mhegazy
use async exists, and add assert
9e3a30f
@mhegazy
Generate lcg file
74d5e80
@mhegazy
Add localize task to gulpFile
e7f730a
@mhegazy
Only run loclaize if the generated files neededs update. Also run loc…
a241854
…alize as part of local
@mhegazy
Mohamed Hegazy (mhegazy) requested review from Paul van Brenk (paulvanbrenk) and Wesley Wigham (weswigham) September 22, 2017 22:05
@msftclas Microsoft Contribution License Agreements (msftclas) added the cla-not-required label Sep 22, 2017
@mhegazy
Merge branch 'master' into includeLocalizedDiagnostics
538cbe0
weswigham
Wesley Wigham (weswigham) reviewed Sep 22, 2017
View reviewed changes

@weswigham Wesley Wigham (weswigham) left a comment

Copy link
Copy Markdown
Member

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 probably also add generateLocalizedDiagnosticMessages.ts to the list of linted files in the Gulpfile and Jakefile, before we forget about it and never lint it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread package.json
"@types/q": "latest",
"@types/run-sequence": "latest",
"@types/through2": "latest",
"@types/xml2js": "^0.4.0",

@weswigham Wesley Wigham (weswigham) Sep 22, 2017

Copy link
Copy Markdown
Member

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.

These should be latest, unless we have a strong reason to fix the version, yes?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Gulpfile.ts
const generateLocalizedDiagnosticMessagesJs = path.join(scriptsDirectory, "generateLocalizedDiagnosticMessages.js");
const generateLocalizedDiagnosticMessagesTs = path.join(scriptsDirectory, "generateLocalizedDiagnosticMessages.ts");

gulp.task(generateLocalizedDiagnosticMessagesJs, /*help*/ false, [], () => {

@weswigham Wesley Wigham (weswigham) Sep 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Rather than building the script in the gulpfile, can we just import the typescript directly, and call a function it exports (instead of shelling out)? We could do this with our other scripts in the Gulpfile to cut away some cruft, too.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mhegazy Mohamed Hegazy (mhegazy) Sep 22, 2017

Copy link
Copy Markdown
Contributor Author

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.

are we doing this anywhere else in gulpFile? i tried to stay close to the Jake file really. i am not a gulp user :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) Sep 22, 2017

Copy link
Copy Markdown
Member

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.

We were doing it for the old parallel runner, though I've removed it since it's in the harness now. It's no big deal; could just be a little cleaner-feeling, since then there'd be no (visible) compilation step for the script. Doesn't matter much, since we need to keep the compilation step in the Jakefile anyway.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Jakefile.js Outdated
// Local target to build the compiler and services
desc("Builds the full compiler and services");
task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, buildProtocolDts, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]);
task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, buildProtocolDts, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end", "localize"]);

@weswigham Wesley Wigham (weswigham) Sep 22, 2017

Copy link
Copy Markdown
Member

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.

"localize" should come before "build-fold-end", probably.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mhegazy
Fix lint errors
89b0d56
paulvanbrenk
Paul van Brenk (paulvanbrenk) approved these changes Sep 25, 2017
View reviewed changes

@paulvanbrenk Paul van Brenk (paulvanbrenk) left a comment

Copy link
Copy Markdown
Contributor

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.

As discussed we should consider building the NPM packages on the build server vs. this another machine. This way we can include signing in the future.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread scripts/generateLocalizedDiagnosticMessages.ts
}
}

function xmlObjectToString(o: any) {

@paulvanbrenk Paul van Brenk (paulvanbrenk) Sep 25, 2017

Copy link
Copy Markdown
Contributor

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.

Add a comment here what we expect the incoming XML to look like

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) requested changes Sep 25, 2017
View reviewed changes
Comment thread scripts/generateLocalizedDiagnosticMessages.ts Outdated

// generate other langs
fs.readdir(inputPath, (err, files) => {
handelError(err);

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Sep 25, 2017

Copy link
Copy Markdown
Member

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.

handle :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread scripts/generateLocalizedDiagnosticMessages.ts Outdated
});
}

function objectToList(o: Record<string, string>) {

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Sep 25, 2017

Copy link
Copy Markdown
Member

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 we're assuming an ES2015 runtime, you can use Object.entries instead, but this is probably fine.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) Sep 25, 2017

Copy link
Copy Markdown
Member

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.

We already use const in some of our build scripts, I believe, and haven't received any complaints. We only build on back to Node 4, so it seems reasonable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mhegazy Mohamed Hegazy (mhegazy) Oct 2, 2017

Copy link
Copy Markdown
Contributor Author

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.

Object.entries is ES2017. not sure if was on node v4 or not..

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) Oct 2, 2017

Copy link
Copy Markdown
Member

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.

According to http://node.green/, node 7.5 was the first with Object.entries... so probably not yet. However map.entries has been available since node 4. 🐱

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@msftgits Microsoft GitHub User (msftgits) removed the cla-not-required label Sep 26, 2017
Mohamed Hegazy (mhegazy) added 2 commits October 2, 2017 16:28
@mhegazy
Linter love
1bf2179
@mhegazy
Respond to code review comments
10f5acc
@mhegazy
Mohamed Hegazy (mhegazy) merged commit a8b7f7d into master Oct 3, 2017
@mhegazy
Mohamed Hegazy (mhegazy) deleted the includeLocalizedDiagnostics branch October 3, 2017 00:16
@mihailik

mihailik commented Oct 3, 2017

Copy link
Copy Markdown
Contributor

What would the error output look like?

error TS2318: BlaBlaInForeignLanguage
^^^^^ that's English, right?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Oct 3, 2017

Copy link
Copy Markdown
Contributor Author
c:\ts>tsc --v
Version 2.6.0-dev.20171003

c:\ts>tsc --locale rus --pretty c:\test\a.ts

../test/a.ts(1,5): error TS2322: Тип ""string"" не может быть назначен для типа "number".

1 var x: number = "string";
      ~
mihailik reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhegazy

Mohamed Hegazy (mhegazy) commented Oct 3, 2017

Copy link
Copy Markdown
Contributor Author

And help in JPN would look like:

PS C:\ts> tsc --v
Version 2.6.0-dev.20171003

PS C:\ts> tsc --locale jpn
バージョン 2.6.0-dev.20171003
構文: tsc [オプション] [ファイル ...]

例:  tsc hello.ts
    tsc --outFile file.js file.ts
    tsc @args.txt

オプション:
 -h, --help                                 このメッセージを表示します。
 --all                                      コンパイラ オプションをすべて表示します。
 -v, --version                              コンパイラのバージョンを表示します。
 --init                                     TypeScript プロジェクトを初期化して、tsconfig.json ファイルを作成します。
 -p ファイルまたはディレクトリ, --project ファイルまたはディレクトリ  構成ファイルか、'tsconfig.json' を含むフォルダーにパスが指定されたプロジェクトをコ
ンパイルします。
 --pretty                                   色とコンテキストを使用してエラーとメッセージにスタイルを適用します (試験的)。
 -w, --watch                                入力ファイルを監視します。
 -t バージョン, --target バージョン                   ECMAScript のターゲット バージョンを指定します: 'ES3' (既定)、'ES5'、'ES2015'、'ES2016'、'ES2017'、'ES
NEXT'。
 -m 種類, --module 種類                         モジュール コード生成を指定します: 'none'、'commonjs'、'amd'、'system'、'umd'、'es2015'、'ESNext'。
 --lib                                      コンパイルに含めるライブラリ ファイルを指定します:
                                              'es5' 'es6' 'es2015' 'es7' 'es2016' 'es2017' 'esnext' 'dom' 'dom.iterable' 'webworker' 'scripthost' 'es201
5.core' 'es2015.collection' 'es2015.generator' 'es2015.iterable' 'es2015.promise' 'es2015.proxy' 'es2015.reflect' 'es2015.symbol' 'es2015.symbol.wellkno
wn' 'es2016.array.include' 'es2017.object' 'es2017.sharedmemory' 'es2017.string' 'es2017.intl' 'esnext.asynciterable'
 --allowJs                                  javascript ファイルのコンパイルを許可します。
 --jsx 種類                                   JSX コード生成を指定します: 'preserve'、'react-native'、'react'。
 -d, --declaration                          対応する '.d.ts' ファイルを生成します。
 --sourceMap                                対応する '.map' ファイルを生成します。
 --outFile ファイル                             出力を連結して 1 つのファイルを生成します。
 --outDir ディレクトリ                            ディレクトリへ出力構造をリダイレクトします。
 --removeComments                           コメントを出力しないでください。
 --noEmit                                   出力しないでください。
 --strict                                   strict 型チェックのオプションをすべて有効にします。
 --noImplicitAny                            暗黙的な 'any' 型を含む式と宣言に関するエラーを発生させます。
 --strictNullChecks                         厳格な null チェックを有効にします。
 --strictFunctionTypes                      Enable strict checking of function types.
 --noImplicitThis                           暗黙的な 'any' 型を持つ 'this' 式でエラーが発生します。
 --alwaysStrict                             厳格モードで解析してソース ファイルごとに "use strict" を生成します。
 --noUnusedLocals                           使用されていないローカルに関するエラーを報告します。
 --noUnusedParameters                       使用されていないパラメーターに関するエラーを報告します。
 --noImplicitReturns                        関数の一部のコード パスが値を返さない場合にエラーを報告します。
 --noFallthroughCasesInSwitch               switch ステートメントに case のフォールスルーがある場合にエラーを報告します。
 --types                                    コンパイルに含む型宣言ファイル。
 @<ファイル>  
mihailik, weswigham, alex-kinokon, and hanakla reacted with heart emoji
All reactions
  • ❤️ 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 3, 2017
Fix gulp lint #18921
Merged
gulp local broken #18922
Closed
@mhegazy Mohamed Hegazy (mhegazy) mentioned this pull request Oct 18, 2017
Fix https://github.com/Microsoft/TypeScript/issues/19270: ensure output name is a valid locale name #19308
Merged
@Quramy Yosuke Kurami (Quramy) mentioned this pull request Nov 6, 2017
[feat] pass --locale option when tsserver boot Quramy/tsuquyomi#186
Closed
@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@weswigham Wesley Wigham (weswigham) weswigham left review comments
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) DanielRosenwasser requested changes
+1 more reviewer
@paulvanbrenk Paul van Brenk (paulvanbrenk) paulvanbrenk approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@mhegazy @mihailik @DanielRosenwasser @weswigham @paulvanbrenk @msftclas @msftgits
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.