Task: localization for the extension (#675)

* i18n examples and gulp file mods

* cleaning up changes and adding localize calls

* removing unneeded files

* adding new lines to constants i18n files

* fixing failing tests

* cleaned up gulp file

* added applyLocalization property wtih false default

* setup constants folder and changed all imports

* automation scripts started

* adding xlf format and conversion to json logic

* added locale cli to send to sqltoolsservice

* adding option config

* adding newlines to xliff files

* adding more formatting related newlines

* adding full xlif enu file

* gulp script update

* uncommenting localize calls

* xlf format update

* adding tests and test constant

* spelling correction

* build automation scripts

* escaping qoute characters

* depending on fork and ignoring problem logs

* linking localized sqltoolsservice build
This commit is contained in:
Raymond Martin 2017-02-09 16:52:31 -08:00 коммит произвёл GitHub
Родитель 50ad0a6b6b
Коммит bab31c23f9
62 изменённых файлов: 1294 добавлений и 471 удалений

Просмотреть файл

@ -3,6 +3,7 @@ var gulp = require('gulp');
var rename = require('gulp-rename');
var install = require('gulp-install');
var tslint = require('gulp-tslint');
var filter = require('gulp-filter');
var ts = require('gulp-typescript');
var tsProject = ts.createProject('tsconfig.json');
var del = require('del');
@ -16,6 +17,8 @@ var cproc = require('child_process');
var os = require('os');
var jeditor = require("gulp-json-editor");
var path = require('path');
var nls = require('vscode-nls-dev');
var localization = require('./tasks/localizationtasks');
require('./tasks/htmltasks')
require('./tasks/packagetasks')
@ -46,6 +49,8 @@ gulp.task('ext:compile-src', (done) => {
process.exit(1);
}
})
.pipe(nls.rewriteLocalizeCalls())
.pipe(nls.createAdditionalLanguageFiles(nls.coreLanguages, config.paths.project.root + '/localization/i18n', undefined, false))
.pipe(srcmap.write('.', {
sourceRoot: function(file){ return file.cwd + '/src'; }
}))
@ -115,7 +120,9 @@ gulp.task('ext:copy-appinsights', () => {
gulp.task('ext:copy', gulp.series('ext:copy-tests', 'ext:copy-js', 'ext:copy-config'));
gulp.task('ext:build', gulp.series('ext:lint', 'ext:compile', 'ext:copy'));
gulp.task('ext:localization', gulp.series('ext:localization:xliff-to-ts', 'ext:localization:xliff-to-json'));
gulp.task('ext:build', gulp.series('ext:localization', 'ext:lint', 'ext:compile', 'ext:copy'));
gulp.task('ext:test', (done) => {
let workspace = process.env['WORKSPACE'];

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "从下面的列表中选择一个连接配置文件"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "从下面的列表中选择一个连接配置文件"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "Wählen Sie aus der folgenden Liste ein Verbindungsprofil aus"
}

Просмотреть файл

@ -0,0 +1,4 @@
{
"testLocalizationConstant": "test_es",
"recentConnectionsPlaceholder": "Elija un perfil de conexión de la lista siguiente"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "Choisissez un profil de connexion dans la liste ci-dessous"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "Scegliere un profilo di connessione dalla lista qui sotto"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "下のリストから接続プロファイルを選択してください"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "아래 목록에서 연결 프로필 선택"
}

Просмотреть файл

@ -0,0 +1,3 @@
{
"recentConnectionsPlaceholder": "Выберите профиль подключения из списка ниже"
}

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="chs">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>从下面的列表中选择一个连接配置文件</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="cht">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>从下面的列表中选择一个连接配置文件</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="deu">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>Wählen Sie aus der folgenden Liste ein Verbindungsprofil aus</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,391 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en">
<body>
<trans-unit id="configMyConnectionsNoServerName">
<source xml:lang="en">Missing server name in user preferences connection: </source>
</trans-unit>
<trans-unit id="msgLocalWebserviceStaticContent">
<source xml:lang="en">LocalWebService: added static html content path: </source>
</trans-unit>
<trans-unit id="msgLocalWebserviceStarted">
<source xml:lang="en">LocalWebService listening on port </source>
</trans-unit>
<trans-unit id="msgRunQueryAllBatchesExecuted">
<source xml:lang="en">runQuery: all batches executed</source>
</trans-unit>
<trans-unit id="msgStartedExecute">
<source xml:lang="en">Started query execution for document "{0}"</source>
</trans-unit>
<trans-unit id="msgFinishedExecute">
<source xml:lang="en">Finished query execution for document "{0}"</source>
</trans-unit>
<trans-unit id="msgRunQueryError">
<source xml:lang="en">runQuery: error: </source>
</trans-unit>
<trans-unit id="msgRunQueryExecutingBatch">
<source xml:lang="en">runQuery: executeBatch called with SQL: </source>
</trans-unit>
<trans-unit id="msgRunQueryAddBatchResultsets">
<source xml:lang="en">runQuery: adding resultsets for batch: </source>
</trans-unit>
<trans-unit id="msgRunQueryAddBatchError">
<source xml:lang="en">runQuery: adding error message for batch: </source>
</trans-unit>
<trans-unit id="msgRunQueryConnectionActive">
<source xml:lang="en">runQuery: active connection is connected, using it to run query</source>
</trans-unit>
<trans-unit id="msgRunQueryConnectionDisconnected">
<source xml:lang="en">runQuery: active connection is disconnected, reconnecting</source>
</trans-unit>
<trans-unit id="msgRunQueryNoConnection">
<source xml:lang="en">runQuery: no active connection - prompting for user</source>
</trans-unit>
<trans-unit id="msgRunQueryInProgress">
<source xml:lang="en">A query is already running for this editor session. Please cancel this query or wait for its completion.</source>
</trans-unit>
<trans-unit id="runQueryBatchStartMessage">
<source xml:lang="en">Started executing query at </source>
</trans-unit>
<trans-unit id="runQueryBatchStartLine">
<source xml:lang="en">Line {0}</source>
</trans-unit>
<trans-unit id="msgCancelQueryFailed">
<source xml:lang="en">Canceling the query failed: {0}</source>
</trans-unit>
<trans-unit id="msgCancelQueryNotRunning">
<source xml:lang="en">Cannot cancel query as no query is running.</source>
</trans-unit>
<trans-unit id="msgCancelQuerySuccess">
<source xml:lang="en">Successfully canceled the query.</source>
</trans-unit>
<trans-unit id="msgContentProviderOnContentUpdated">
<source xml:lang="en">Content provider: onContentUpdated called</source>
</trans-unit>
<trans-unit id="msgContentProviderAssociationFailure">
<source xml:lang="en">Content provider: Unable to associate status view for current file</source>
</trans-unit>
<trans-unit id="msgContentProviderOnRootEndpoint">
<source xml:lang="en">LocalWebService: Root end-point called</source>
</trans-unit>
<trans-unit id="msgContentProviderOnResultsEndpoint">
<source xml:lang="en">LocalWebService: ResultsetsMeta endpoint called</source>
</trans-unit>
<trans-unit id="msgContentProviderOnMessagesEndpoint">
<source xml:lang="en">LocalWebService: Messages end-point called</source>
</trans-unit>
<trans-unit id="msgContentProviderOnColumnsEndpoint">
<source xml:lang="en">LocalWebService: Columns end-point called for index = </source>
</trans-unit>
<trans-unit id="msgContentProviderOnRowsEndpoint">
<source xml:lang="en">LocalWebService: Rows end-point called for index = </source>
</trans-unit>
<trans-unit id="msgContentProviderOnClear">
<source xml:lang="en">Content provider: clear called</source>
</trans-unit>
<trans-unit id="msgContentProviderOnUpdateContent">
<source xml:lang="en">Content provider: updateContent called</source>
</trans-unit>
<trans-unit id="msgContentProviderProvideContent">
<source xml:lang="en">Content provider: provideTextDocumentContent called: </source>
</trans-unit>
<trans-unit id="msgChooseDatabaseNotConnected">
<source xml:lang="en">No connection was found. Please connect to a server first.</source>
</trans-unit>
<trans-unit id="msgChooseDatabasePlaceholder">
<source xml:lang="en">Choose a database from the list below</source>
</trans-unit>
<trans-unit id="msgConnectionError">
<source xml:lang="en">Error {0}: {1}</source>
</trans-unit>
<trans-unit id="msgConnectionError2">
<source xml:lang="en">Failed to connect: {0}</source>
</trans-unit>
<trans-unit id="msgConnectionErrorPasswordExpired">
<source xml:lang="en">Error {0}: {1} Please login as a different user and change the password using ALTER LOGIN.</source>
</trans-unit>
<trans-unit id="connectionErrorChannelName">
<source xml:lang="en">Connection Errors</source>
</trans-unit>
<trans-unit id="msgPromptCancelConnect">
<source xml:lang="en">Server connection in progress. Do you want to cancel?</source>
</trans-unit>
<trans-unit id="msgPromptClearRecentConnections">
<source xml:lang="en">Confirm to clear recent connections list</source>
</trans-unit>
<trans-unit id="extensionActivated">
<source xml:lang="en">activated.</source>
</trans-unit>
<trans-unit id="extensionDeactivated">
<source xml:lang="en">de-activated.</source>
</trans-unit>
<trans-unit id="msgOpenSqlFile">
<source xml:lang="en">To use this command, Open a .sql file -or- Change editor language to "SQL" -or- Select T-SQL text in the active SQL editor.</source>
</trans-unit>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en">Choose a connection profile from the list below</source>
</trans-unit>
<trans-unit id="msgNoConnectionsInSettings">
<source xml:lang="en">To use this command, add connection profile to User Settings.</source>
</trans-unit>
<trans-unit id="labelOpenGlobalSettings">
<source xml:lang="en">Open Global Settings</source>
</trans-unit>
<trans-unit id="labelOpenWorkspaceSettings">
<source xml:lang="en">Open Workspace Settings</source>
</trans-unit>
<trans-unit id="CreateProfileFromConnectionsListLabel">
<source xml:lang="en">Create Connection Profile</source>
</trans-unit>
<trans-unit id="CreateProfileLabel">
<source xml:lang="en">Create</source>
</trans-unit>
<trans-unit id="ClearRecentlyUsedLabel">
<source xml:lang="en">Clear Recent Connections List</source>
</trans-unit>
<trans-unit id="EditProfilesLabel">
<source xml:lang="en">Edit</source>
</trans-unit>
<trans-unit id="RemoveProfileLabel">
<source xml:lang="en">Remove</source>
</trans-unit>
<trans-unit id="ManageProfilesPrompt">
<source xml:lang="en">Manage Connection Profiles</source>
</trans-unit>
<trans-unit id="SampleServerName">
<source xml:lang="en">{{put-server-name-here}}</source>
</trans-unit>
<trans-unit id="serverPrompt">
<source xml:lang="en">Server name</source>
</trans-unit>
<trans-unit id="serverPlaceholder">
<source xml:lang="en">hostname\\instance or &lt;server&gt;.database.windows.net</source>
</trans-unit>
<trans-unit id="databasePrompt">
<source xml:lang="en">Database name</source>
</trans-unit>
<trans-unit id="databasePlaceholder">
<source xml:lang="en">[Optional] Database to connect (press Enter to connect to &lt;default&gt; database)</source>
</trans-unit>
<trans-unit id="databaseDefaultValue">
<source xml:lang="en">master</source>
</trans-unit>
<trans-unit id="authTypePrompt">
<source xml:lang="en">Authentication Type</source>
</trans-unit>
<trans-unit id="authTypeIntegrated">
<source xml:lang="en">Integrated</source>
</trans-unit>
<trans-unit id="authTypeSql">
<source xml:lang="en">SQL Login</source>
</trans-unit>
<trans-unit id="authTypeAdUniversal">
<source xml:lang="en">Active Directory Universal</source>
</trans-unit>
<trans-unit id="usernamePrompt">
<source xml:lang="en">User name</source>
</trans-unit>
<trans-unit id="usernamePlaceholder">
<source xml:lang="en">User name (SQL Login)</source>
</trans-unit>
<trans-unit id="passwordPrompt">
<source xml:lang="en">Password</source>
</trans-unit>
<trans-unit id="passwordPlaceholder">
<source xml:lang="en">Password (SQL Login)</source>
</trans-unit>
<trans-unit id="msgSavePassword">
<source xml:lang="en">Save Password? If 'No', password will be required each time you connect</source>
</trans-unit>
<trans-unit id="profileNamePrompt">
<source xml:lang="en">Profile Name</source>
</trans-unit>
<trans-unit id="profileNamePlaceholder">
<source xml:lang="en">[Optional] Enter a name for this profile</source>
</trans-unit>
<trans-unit id="filepathPrompt">
<source xml:lang="en">File path</source>
</trans-unit>
<trans-unit id="filepathPlaceholder">
<source xml:lang="en">File name</source>
</trans-unit>
<trans-unit id="filepathMessage">
<source xml:lang="en">File name</source>
</trans-unit>
<trans-unit id="overwritePrompt">
<source xml:lang="en">A file with this name already exists. Do you want to replace the existing file?</source>
</trans-unit>
<trans-unit id="overwritePlaceholder">
<source xml:lang="en">A file with this name already exists</source>
</trans-unit>
<trans-unit id="msgSaveResultInProgress">
<source xml:lang="en">A save request is already executing. Please wait for its completion.</source>
</trans-unit>
<trans-unit id="msgCannotOpenContent">
<source xml:lang="en">Error occurred opening content in editor.</source>
</trans-unit>
<trans-unit id="msgSaveStarted">
<source xml:lang="en">Started saving results to </source>
</trans-unit>
<trans-unit id="msgSaveFailed">
<source xml:lang="en">Failed to save results. </source>
</trans-unit>
<trans-unit id="msgSaveSucceeded">
<source xml:lang="en">Successfully saved results to </source>
</trans-unit>
<trans-unit id="msgSelectProfile">
<source xml:lang="en">Select connection profile</source>
</trans-unit>
<trans-unit id="msgSelectProfileToRemove">
<source xml:lang="en">Select profile to remove</source>
</trans-unit>
<trans-unit id="confirmRemoveProfilePrompt">
<source xml:lang="en">Confirm to remove this profile.</source>
</trans-unit>
<trans-unit id="msgNoProfilesSaved">
<source xml:lang="en">No connection profile to remove.</source>
</trans-unit>
<trans-unit id="msgProfileRemoved">
<source xml:lang="en">Profile removed successfully</source>
</trans-unit>
<trans-unit id="msgProfileCreated">
<source xml:lang="en">Profile created successfully</source>
</trans-unit>
<trans-unit id="msgProfileCreatedAndConnected">
<source xml:lang="en">Profile created and connected</source>
</trans-unit>
<trans-unit id="msgClearedRecentConnections">
<source xml:lang="en">Recent connections list cleared</source>
</trans-unit>
<trans-unit id="msgSelectionIsRequired">
<source xml:lang="en">Selection is required.</source>
</trans-unit>
<trans-unit id="msgIsRequired">
<source xml:lang="en"> is required.</source>
</trans-unit>
<trans-unit id="msgRetry">
<source xml:lang="en">Retry</source>
</trans-unit>
<trans-unit id="msgError">
<source xml:lang="en">Error: </source>
</trans-unit>
<trans-unit id="msgYes">
<source xml:lang="en">Yes</source>
</trans-unit>
<trans-unit id="msgNo">
<source xml:lang="en">No</source>
</trans-unit>
<trans-unit id="defaultDatabaseLabel">
<source xml:lang="en">&lt;default&gt;</source>
</trans-unit>
<trans-unit id="notConnectedLabel">
<source xml:lang="en">Disconnected</source>
</trans-unit>
<trans-unit id="notConnectedTooltip">
<source xml:lang="en">Click to connect to a database</source>
</trans-unit>
<trans-unit id="connectingLabel">
<source xml:lang="en">Connecting</source>
</trans-unit>
<trans-unit id="connectingTooltip">
<source xml:lang="en">Connecting to: </source>
</trans-unit>
<trans-unit id="connectedLabel">
<source xml:lang="en">Connected.</source>
</trans-unit>
<trans-unit id="connectErrorLabel">
<source xml:lang="en">Connection error</source>
</trans-unit>
<trans-unit id="connectErrorTooltip">
<source xml:lang="en">Error connecting to: </source>
</trans-unit>
<trans-unit id="connectErrorCode">
<source xml:lang="en">Errorcode: </source>
</trans-unit>
<trans-unit id="connectErrorMessage">
<source xml:lang="en">ErrorMessage: </source>
</trans-unit>
<trans-unit id="executeQueryLabel">
<source xml:lang="en">Executing query </source>
</trans-unit>
<trans-unit id="cancelingQueryLabel">
<source xml:lang="en">Canceling query </source>
</trans-unit>
<trans-unit id="updatingIntelliSenseLabel">
<source xml:lang="en">Updating IntelliSense...</source>
</trans-unit>
<trans-unit id="unfoundResult">
<source xml:lang="en">Data was disposed when text editor was closed; to view data please reexecute query.</source>
</trans-unit>
<trans-unit id="extensionNotInitializedError">
<source xml:lang="en">Unable to execute the command while the extension is initializing. Please try again later.</source>
</trans-unit>
<trans-unit id="untitledScheme">
<source xml:lang="en">untitled</source>
</trans-unit>
<trans-unit id="msgChangeLanguageMode">
<source xml:lang="en">To use this command, you must set the language to "SQL". Confirm to change language mode.</source>
</trans-unit>
<trans-unit id="msgChangedDatabaseContext">
<source xml:lang="en">Changed database context to "{0}" for document "{1}"</source>
</trans-unit>
<trans-unit id="msgPromptRetryCreateProfile">
<source xml:lang="en">Error: Unable to connect using the connection information provided. Retry profile creation?</source>
</trans-unit>
<trans-unit id="retryLabel">
<source xml:lang="en">Retry</source>
</trans-unit>
<trans-unit id="msgConnecting">
<source xml:lang="en">Connecting to server "{0}" on document "{1}".</source>
</trans-unit>
<trans-unit id="msgConnectedServerInfo">
<source xml:lang="en">Connected to server "{0}" on document "{1}". Server information: {2}</source>
</trans-unit>
<trans-unit id="msgConnectionFailed">
<source xml:lang="en">Error connecting to server "{0}". Details: {1}</source>
</trans-unit>
<trans-unit id="msgChangingDatabase">
<source xml:lang="en">Changing database context to "{0}" on server "{1}" on document "{2}".</source>
</trans-unit>
<trans-unit id="msgChangedDatabase">
<source xml:lang="en">Changed database context to "{0}" on server "{1}" on document "{2}".</source>
</trans-unit>
<trans-unit id="msgDisconnected">
<source xml:lang="en">Disconnected on document "{0}"</source>
</trans-unit>
<trans-unit id="msgErrorReadingConfigFile">
<source xml:lang="en">Error: Unable to load connection profiles from [{0}]. Check if the file is formatted correctly.</source>
</trans-unit>
<trans-unit id="msgErrorOpeningConfigFile">
<source xml:lang="en">Error: Unable to open connection profile settings file.</source>
</trans-unit>
<trans-unit id="titleResultsPane">
<source xml:lang="en">Results: {0}</source>
</trans-unit>
<trans-unit id="macOpenSslErrorMessage">
<source xml:lang="en">OpenSSL version >=1.0.1 is required to connect.</source>
</trans-unit>
<trans-unit id="macOpenSslHelpButton">
<source xml:lang="en">Help</source>
</trans-unit>
<trans-unit id="gettingDefinitionMessage">
<source xml:lang="en">Getting definition ...</source>
</trans-unit>
<trans-unit id="definitionRequestedStatus">
<source xml:lang="en">DefinitionRequested</source>
</trans-unit>
<trans-unit id="definitionRequestCompletedStatus">
<source xml:lang="en">DefinitionRequestCompleted</source>
</trans-unit>
<trans-unit id="updatingIntelliSenseStatus">
<source xml:lang="en">updatingIntelliSense</source>
</trans-unit>
<trans-unit id="intelliSenseUpdatedStatus">
<source xml:lang="en">intelliSenseUpdated</source>
</trans-unit>
<trans-unit id="testLocalizationConstant">
<source xml:lang="en">test_en</source>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="esn">
<body>
<trans-unit id="testLocalizationConstant">
<source xml:lang="en">test_en</source>
<target>test_es</target>
</trans-unit>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en">Choose a connection profile from the list below</source>
<target>Elija un perfil de conexión de la lista siguiente</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="fra">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>Choisissez un profil de connexion dans la liste ci-dessous</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="ita">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>Scegliere un profilo di connessione dalla lista qui sotto</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="jpn">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>下のリストから接続プロファイルを選択してください</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="kor">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>아래 목록에서 연결 프로필 선택</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" original="extension.i18ntest.JSON" source-language="en-US" target-language="rus">
<body>
<trans-unit id="recentConnectionsPlaceholder">
<source xml:lang="en-US">Choose a connection profile from the list below</source>
<target>Выберите профиль подключения из списка ниже</target>
</trans-unit>
</body>
</file>
</xliff>

Просмотреть файл

@ -56,6 +56,7 @@
"gulp": "github:gulpjs/gulp#4.0",
"gulp-clean-css": "^2.0.13",
"gulp-concat": "^2.6.0",
"gulp-filter": "^5.0.0",
"gulp-install": "^0.6.0",
"gulp-istanbul-report": "0.0.1",
"gulp-json-editor": "^2.2.1",
@ -83,6 +84,9 @@
"typescript": "^2.1.5",
"uglify-js": "mishoo/UglifyJS2#harmony",
"vscode": "^0.11.0",
"vscode-nls": "^2.0.2",
"vscode-nls-dev": "https://github.com/Raymondd/vscode-nls-dev/releases/download/2.0.2/build.tar.gz",
"xmldom": "^0.1.27",
"yargs": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz"
},
"dependencies": {
@ -451,6 +455,11 @@
"current",
"end"
]
},
"mssql.applyLocalization": {
"type": "boolean",
"description": "[Optional] Configuration options for localizing into VSCode's configured locale (must restart VSCode for settings to take effect)",
"default": false
}
}
}

Просмотреть файл

@ -6,7 +6,7 @@
'use strict';
const fs = require('fs');
import * as path from 'path';
import * as Constants from '../models/constants';
import * as Constants from '../constants/constants';
import {IConfig} from '../languageservice/interfaces';
/*

Просмотреть файл

@ -1,7 +1,7 @@
{
"service": {
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "0.2.0-alpha.26",
"version": "0.2.0-alpha.28",
"downloadFileNames": {
"Windows_7_86": "win-x86-netcoreapp1.0.zip",
"Windows_7_64": "win-x64-netcoreapp1.0.zip",

Просмотреть файл

@ -7,7 +7,7 @@
import Config from './config';
import { workspace, WorkspaceConfiguration } from 'vscode';
import * as Constants from '../models/constants';
import * as Constants from '../constants/constants';
import {IConfig} from '../languageservice/interfaces';
/*

Просмотреть файл

@ -6,7 +6,8 @@
import fs = require('fs');
import os = require('os');
import * as Constants from '../models/constants';
import * as Constants from '../constants/constants';
import * as LocalizedConstants from '../constants/localizedConstants';
import * as Utils from '../models/utils';
import { IConnectionProfile } from '../models/interfaces';
import { IConnectionConfig } from './iconnectionconfig';
@ -47,7 +48,7 @@ export class ConnectionConfig implements IConnectionConfig {
// No op if the settings file could not be parsed; we don't want to overwrite the corrupt file
if (!parsedSettingsFile) {
return Promise.reject(Utils.formatString(Constants.msgErrorReadingConfigFile, ConnectionConfig.configFilePath));
return Promise.reject(Utils.formatString(LocalizedConstants.msgErrorReadingConfigFile, ConnectionConfig.configFilePath));
}
let profiles = this.getProfilesFromParsedSettingsFile(parsedSettingsFile);
@ -90,7 +91,7 @@ export class ConnectionConfig implements IConnectionConfig {
if (profiles.length > 0) {
profiles = profiles.filter(conn => {
// filter any connection missing a server name or the sample that's shown by default
return !!(conn.server) && conn.server !== Constants.SampleServerName;
return !!(conn.server) && conn.server !== LocalizedConstants.SampleServerName;
});
}
@ -210,7 +211,7 @@ export class ConnectionConfig implements IConnectionConfig {
let fileObject: any = commentJson.parse(fileContents);
return fileObject;
} catch (e) { // Error parsing JSON
this.vscodeWrapper.showErrorMessage(Utils.formatString(Constants.msgErrorReadingConfigFile, filename));
this.vscodeWrapper.showErrorMessage(Utils.formatString(LocalizedConstants.msgErrorReadingConfigFile, filename));
}
} else {
return {};
@ -218,7 +219,7 @@ export class ConnectionConfig implements IConnectionConfig {
}
} catch (e) { // Error reading the file
if (e.code !== 'ENOENT') { // Ignore error if the file doesn't exist
this.vscodeWrapper.showErrorMessage(Utils.formatString(Constants.msgErrorReadingConfigFile, filename));
this.vscodeWrapper.showErrorMessage(Utils.formatString(LocalizedConstants.msgErrorReadingConfigFile, filename));
} else {
return {};
}

Просмотреть файл

@ -0,0 +1,86 @@
// Collection of Non-localizable Constants
export const languageId = 'sql';
export const extensionName = 'mssql';
export const extensionConfigSectionName = 'mssql';
export const connectionApplicationName = 'vscode-mssql';
export const outputChannelName = 'MSSQL';
export const connectionConfigFilename = 'settings.json';
export const connectionsArrayName = 'mssql.connections';
export const cmdRunQuery = 'extension.runQuery';
export const cmdCancelQuery = 'extension.cancelQuery';
export const cmdConnect = 'extension.connect';
export const cmdDisconnect = 'extension.disconnect';
export const cmdChooseDatabase = 'extension.chooseDatabase';
export const cmdShowReleaseNotes = 'extension.showReleaseNotes';
export const cmdShowGettingStarted = 'extension.showGettingStarted';
export const cmdNewQuery = 'extension.newQuery';
export const cmdManageConnectionProfiles = 'extension.manageProfiles';
export const sqlDbPrefix = '.database.windows.net';
export const defaultConnectionTimeout = 15;
export const azureSqlDbConnectionTimeout = 30;
export const azureDatabase = 'Azure';
export const defaultPortNumber = 1433;
export const sqlAuthentication = 'SqlLogin';
export const defaultDatabase = 'master';
export const errorPasswordExpired = 18487;
export const errorPasswordNeedsReset = 18488;
export const maxDisplayedStatusTextLength = 50;
export const outputContentTypeRoot = 'root';
export const outputContentTypeMessages = 'messages';
export const outputContentTypeResultsetMeta = 'resultsetsMeta';
export const outputContentTypeColumns = 'columns';
export const outputContentTypeRows = 'rows';
export const outputContentTypeConfig = 'config';
export const outputContentTypeSaveResults = 'saveResults';
export const outputContentTypeOpenLink = 'openLink';
export const outputContentTypeCopy = 'copyResults';
export const outputContentTypeEditorSelection = 'setEditorSelection';
export const outputContentTypeShowError = 'showError';
export const outputContentTypeShowWarning = 'showWarning';
export const outputServiceLocalhost = 'http://localhost:';
export const msgContentProviderSqlOutputHtml = 'dist/html/sqlOutput.ejs';
export const contentProviderMinFile = 'dist/js/app.min.js';
export const serviceCompatibleVersion = '1.0.0';
export const untitledSaveTimeThreshold = 10.0;
export const renamedOpenTimeThreshold = 10.0;
export const timeToWaitForLanguageModeChange = 10000.0;
export const macOpenSslHelpLink = 'https://github.com/Microsoft/vscode-mssql/wiki/OpenSSL-Configuration';
export const gettingStartedGuideLink = 'https://aka.ms/mssql-getting-started';
export const sqlToolsServiceCrashLink = 'https://github.com/Microsoft/vscode-mssql/wiki/SqlToolsService-Known-Issues';
// Configuration Constants
export const copyIncludeHeaders = 'copyIncludeHeaders';
export const configLogDebugInfo = 'logDebugInfo';
export const configMyConnections = 'connections';
export const configSaveAsCsv = 'saveAsCsv';
export const configSaveAsJson = 'saveAsJson';
export const configRecentConnections = 'recentConnections';
export const configMaxRecentConnections = 'maxRecentConnections';
export const configCopyRemoveNewLine = 'copyRemoveNewLine';
export const configSplitPaneSelection = 'splitPaneSelection';
export const extConfigResultKeys = ['shortcuts', 'messagesDefaultOpen'];
export const sqlToolsServiceInstallDirConfigKey = 'installDir';
export const sqlToolsServiceExecutableFilesConfigKey = 'executableFiles';
export const sqlToolsServiceVersionConfigKey = 'version';
export const sqlToolsServiceDownloadUrlConfigKey = 'downloadUrl';
export const extConfigResultFontFamily = 'resultsFontFamily';
export const extConfigResultFontSize = 'resultsFontSize';
export const configApplyLocalization = 'applyLocalization';
// ToolsService Constants
export const serviceInstallingTo = 'Installing SQL tools service to';
export const serviceInstalling = 'Installing';
export const serviceDownloading = 'Downloading';
export const serviceInstalled = 'Sql Tools Service installed';
export const serviceInstallationFailed = 'Failed to install Sql Tools Service';
export const sqlToolsServiceCrashMessage = 'SQL Tools Service component could not start.';
export const sqlToolsServiceCrashButton = 'View Known Issues';
export const serviceInitializingOutputChannelName = 'SqlToolsService Initialization';
export const serviceInitializing = 'Initializing SQL tools service for the mssql extension.';
export const commandsNotAvailableWhileInstallingTheService = 'Note: mssql commands will be available after installing the service.';
export const unsupportedPlatformErrorMessage = 'The platform is not supported';
export const serviceLoadingFailed = 'Failed to load Sql Tools Service';
export const invalidServiceFilePath = 'Invalid file path for Sql Tools Service';
export const sqlToolsServiceName = 'SQLToolsService';
export const serviceNotCompatibleError = 'Client is not compatible with the service layer';
export const sqlToolsServiceConfigKey = 'service';

Просмотреть файл

@ -0,0 +1,263 @@
/* tslint:disable */
// THIS IS A COMPUTER GENERATED FILE. CHANGES IN THIS FILE WILL BE OVERWRITTEN.
// TO ADD LOCALIZED CONSTANTS, ADD YOUR CONSTANT TO THE ENU XLIFF FILE UNDER ~/localization/xliff/enu/constants/localizedConstants.enu.xlf AND REBUILD THE PROJECT
import * as nls from 'vscode-nls';
export let configMyConnectionsNoServerName = 'Missing server name in user preferences connection: ';
export let msgLocalWebserviceStaticContent = 'LocalWebService: added static html content path: ';
export let msgLocalWebserviceStarted = 'LocalWebService listening on port ';
export let msgRunQueryAllBatchesExecuted = 'runQuery: all batches executed';
export let msgStartedExecute = 'Started query execution for document "{0}"';
export let msgFinishedExecute = 'Finished query execution for document "{0}"';
export let msgRunQueryError = 'runQuery: error: ';
export let msgRunQueryExecutingBatch = 'runQuery: executeBatch called with SQL: ';
export let msgRunQueryAddBatchResultsets = 'runQuery: adding resultsets for batch: ';
export let msgRunQueryAddBatchError = 'runQuery: adding error message for batch: ';
export let msgRunQueryConnectionActive = 'runQuery: active connection is connected, using it to run query';
export let msgRunQueryConnectionDisconnected = 'runQuery: active connection is disconnected, reconnecting';
export let msgRunQueryNoConnection = 'runQuery: no active connection - prompting for user';
export let msgRunQueryInProgress = 'A query is already running for this editor session. Please cancel this query or wait for its completion.';
export let runQueryBatchStartMessage = 'Started executing query at ';
export let runQueryBatchStartLine = 'Line {0}';
export let msgCancelQueryFailed = 'Canceling the query failed: {0}';
export let msgCancelQueryNotRunning = 'Cannot cancel query as no query is running.';
export let msgCancelQuerySuccess = 'Successfully canceled the query.';
export let msgContentProviderOnContentUpdated = 'Content provider: onContentUpdated called';
export let msgContentProviderAssociationFailure = 'Content provider: Unable to associate status view for current file';
export let msgContentProviderOnRootEndpoint = 'LocalWebService: Root end-point called';
export let msgContentProviderOnResultsEndpoint = 'LocalWebService: ResultsetsMeta endpoint called';
export let msgContentProviderOnMessagesEndpoint = 'LocalWebService: Messages end-point called';
export let msgContentProviderOnColumnsEndpoint = 'LocalWebService: Columns end-point called for index = ';
export let msgContentProviderOnRowsEndpoint = 'LocalWebService: Rows end-point called for index = ';
export let msgContentProviderOnClear = 'Content provider: clear called';
export let msgContentProviderOnUpdateContent = 'Content provider: updateContent called';
export let msgContentProviderProvideContent = 'Content provider: provideTextDocumentContent called: ';
export let msgChooseDatabaseNotConnected = 'No connection was found. Please connect to a server first.';
export let msgChooseDatabasePlaceholder = 'Choose a database from the list below';
export let msgConnectionError = 'Error {0}: {1}';
export let msgConnectionError2 = 'Failed to connect: {0}';
export let msgConnectionErrorPasswordExpired = 'Error {0}: {1} Please login as a different user and change the password using ALTER LOGIN.';
export let connectionErrorChannelName = 'Connection Errors';
export let msgPromptCancelConnect = 'Server connection in progress. Do you want to cancel?';
export let msgPromptClearRecentConnections = 'Confirm to clear recent connections list';
export let extensionActivated = 'activated.';
export let extensionDeactivated = 'de-activated.';
export let msgOpenSqlFile = 'To use this command, Open a .sql file -or- Change editor language to "SQL" -or- Select T-SQL text in the active SQL editor.';
export let recentConnectionsPlaceholder = 'Choose a connection profile from the list below';
export let msgNoConnectionsInSettings = 'To use this command, add connection profile to User Settings.';
export let labelOpenGlobalSettings = 'Open Global Settings';
export let labelOpenWorkspaceSettings = 'Open Workspace Settings';
export let CreateProfileFromConnectionsListLabel = 'Create Connection Profile';
export let CreateProfileLabel = 'Create';
export let ClearRecentlyUsedLabel = 'Clear Recent Connections List';
export let EditProfilesLabel = 'Edit';
export let RemoveProfileLabel = 'Remove';
export let ManageProfilesPrompt = 'Manage Connection Profiles';
export let SampleServerName = '{{put-server-name-here}}';
export let serverPrompt = 'Server name';
export let serverPlaceholder = 'hostname\\instance or <server>.database.windows.net';
export let databasePrompt = 'Database name';
export let databasePlaceholder = '[Optional] Database to connect (press Enter to connect to <default> database)';
export let databaseDefaultValue = 'master';
export let authTypePrompt = 'Authentication Type';
export let authTypeIntegrated = 'Integrated';
export let authTypeSql = 'SQL Login';
export let authTypeAdUniversal = 'Active Directory Universal';
export let usernamePrompt = 'User name';
export let usernamePlaceholder = 'User name (SQL Login)';
export let passwordPrompt = 'Password';
export let passwordPlaceholder = 'Password (SQL Login)';
export let msgSavePassword = 'Save Password? If \'No\', password will be required each time you connect';
export let profileNamePrompt = 'Profile Name';
export let profileNamePlaceholder = '[Optional] Enter a name for this profile';
export let filepathPrompt = 'File path';
export let filepathPlaceholder = 'File name';
export let filepathMessage = 'File name';
export let overwritePrompt = 'A file with this name already exists. Do you want to replace the existing file?';
export let overwritePlaceholder = 'A file with this name already exists';
export let msgSaveResultInProgress = 'A save request is already executing. Please wait for its completion.';
export let msgCannotOpenContent = 'Error occurred opening content in editor.';
export let msgSaveStarted = 'Started saving results to ';
export let msgSaveFailed = 'Failed to save results. ';
export let msgSaveSucceeded = 'Successfully saved results to ';
export let msgSelectProfile = 'Select connection profile';
export let msgSelectProfileToRemove = 'Select profile to remove';
export let confirmRemoveProfilePrompt = 'Confirm to remove this profile.';
export let msgNoProfilesSaved = 'No connection profile to remove.';
export let msgProfileRemoved = 'Profile removed successfully';
export let msgProfileCreated = 'Profile created successfully';
export let msgProfileCreatedAndConnected = 'Profile created and connected';
export let msgClearedRecentConnections = 'Recent connections list cleared';
export let msgSelectionIsRequired = 'Selection is required.';
export let msgIsRequired = ' is required.';
export let msgRetry = 'Retry';
export let msgError = 'Error: ';
export let msgYes = 'Yes';
export let msgNo = 'No';
export let defaultDatabaseLabel = '<default>';
export let notConnectedLabel = 'Disconnected';
export let notConnectedTooltip = 'Click to connect to a database';
export let connectingLabel = 'Connecting';
export let connectingTooltip = 'Connecting to: ';
export let connectedLabel = 'Connected.';
export let connectErrorLabel = 'Connection error';
export let connectErrorTooltip = 'Error connecting to: ';
export let connectErrorCode = 'Errorcode: ';
export let connectErrorMessage = 'ErrorMessage: ';
export let executeQueryLabel = 'Executing query ';
export let cancelingQueryLabel = 'Canceling query ';
export let updatingIntelliSenseLabel = 'Updating IntelliSense...';
export let unfoundResult = 'Data was disposed when text editor was closed; to view data please reexecute query.';
export let extensionNotInitializedError = 'Unable to execute the command while the extension is initializing. Please try again later.';
export let untitledScheme = 'untitled';
export let msgChangeLanguageMode = 'To use this command, you must set the language to "SQL". Confirm to change language mode.';
export let msgChangedDatabaseContext = 'Changed database context to "{0}" for document "{1}"';
export let msgPromptRetryCreateProfile = 'Error: Unable to connect using the connection information provided. Retry profile creation?';
export let retryLabel = 'Retry';
export let msgConnecting = 'Connecting to server "{0}" on document "{1}".';
export let msgConnectedServerInfo = 'Connected to server "{0}" on document "{1}". Server information: {2}';
export let msgConnectionFailed = 'Error connecting to server "{0}". Details: {1}';
export let msgChangingDatabase = 'Changing database context to "{0}" on server "{1}" on document "{2}".';
export let msgChangedDatabase = 'Changed database context to "{0}" on server "{1}" on document "{2}".';
export let msgDisconnected = 'Disconnected on document "{0}"';
export let msgErrorReadingConfigFile = 'Error: Unable to load connection profiles from [{0}]. Check if the file is formatted correctly.';
export let msgErrorOpeningConfigFile = 'Error: Unable to open connection profile settings file.';
export let titleResultsPane = 'Results: {0}';
export let macOpenSslErrorMessage = 'OpenSSL version >=1.0.1 is required to connect.';
export let macOpenSslHelpButton = 'Help';
export let gettingDefinitionMessage = 'Getting definition ...';
export let definitionRequestedStatus = 'DefinitionRequested';
export let definitionRequestCompletedStatus = 'DefinitionRequestCompleted';
export let updatingIntelliSenseStatus = 'updatingIntelliSense';
export let intelliSenseUpdatedStatus = 'intelliSenseUpdated';
export let testLocalizationConstant = 'test_en';
export let loadLocalizedConstants = (locale: string) => {
let localize = nls.config({ locale: locale })();
configMyConnectionsNoServerName = localize('configMyConnectionsNoServerName', 'Missing server name in user preferences connection: ');
msgLocalWebserviceStaticContent = localize('msgLocalWebserviceStaticContent', 'LocalWebService: added static html content path: ');
msgLocalWebserviceStarted = localize('msgLocalWebserviceStarted', 'LocalWebService listening on port ');
msgRunQueryAllBatchesExecuted = localize('msgRunQueryAllBatchesExecuted', 'runQuery: all batches executed');
msgStartedExecute = localize('msgStartedExecute', 'Started query execution for document "{0}"');
msgFinishedExecute = localize('msgFinishedExecute', 'Finished query execution for document "{0}"');
msgRunQueryError = localize('msgRunQueryError', 'runQuery: error: ');
msgRunQueryExecutingBatch = localize('msgRunQueryExecutingBatch', 'runQuery: executeBatch called with SQL: ');
msgRunQueryAddBatchResultsets = localize('msgRunQueryAddBatchResultsets', 'runQuery: adding resultsets for batch: ');
msgRunQueryAddBatchError = localize('msgRunQueryAddBatchError', 'runQuery: adding error message for batch: ');
msgRunQueryConnectionActive = localize('msgRunQueryConnectionActive', 'runQuery: active connection is connected, using it to run query');
msgRunQueryConnectionDisconnected = localize('msgRunQueryConnectionDisconnected', 'runQuery: active connection is disconnected, reconnecting');
msgRunQueryNoConnection = localize('msgRunQueryNoConnection', 'runQuery: no active connection - prompting for user');
msgRunQueryInProgress = localize('msgRunQueryInProgress', 'A query is already running for this editor session. Please cancel this query or wait for its completion.');
runQueryBatchStartMessage = localize('runQueryBatchStartMessage', 'Started executing query at ');
runQueryBatchStartLine = localize('runQueryBatchStartLine', 'Line {0}');
msgCancelQueryFailed = localize('msgCancelQueryFailed', 'Canceling the query failed: {0}');
msgCancelQueryNotRunning = localize('msgCancelQueryNotRunning', 'Cannot cancel query as no query is running.');
msgCancelQuerySuccess = localize('msgCancelQuerySuccess', 'Successfully canceled the query.');
msgContentProviderOnContentUpdated = localize('msgContentProviderOnContentUpdated', 'Content provider: onContentUpdated called');
msgContentProviderAssociationFailure = localize('msgContentProviderAssociationFailure', 'Content provider: Unable to associate status view for current file');
msgContentProviderOnRootEndpoint = localize('msgContentProviderOnRootEndpoint', 'LocalWebService: Root end-point called');
msgContentProviderOnResultsEndpoint = localize('msgContentProviderOnResultsEndpoint', 'LocalWebService: ResultsetsMeta endpoint called');
msgContentProviderOnMessagesEndpoint = localize('msgContentProviderOnMessagesEndpoint', 'LocalWebService: Messages end-point called');
msgContentProviderOnColumnsEndpoint = localize('msgContentProviderOnColumnsEndpoint', 'LocalWebService: Columns end-point called for index = ');
msgContentProviderOnRowsEndpoint = localize('msgContentProviderOnRowsEndpoint', 'LocalWebService: Rows end-point called for index = ');
msgContentProviderOnClear = localize('msgContentProviderOnClear', 'Content provider: clear called');
msgContentProviderOnUpdateContent = localize('msgContentProviderOnUpdateContent', 'Content provider: updateContent called');
msgContentProviderProvideContent = localize('msgContentProviderProvideContent', 'Content provider: provideTextDocumentContent called: ');
msgChooseDatabaseNotConnected = localize('msgChooseDatabaseNotConnected', 'No connection was found. Please connect to a server first.');
msgChooseDatabasePlaceholder = localize('msgChooseDatabasePlaceholder', 'Choose a database from the list below');
msgConnectionError = localize('msgConnectionError', 'Error {0}: {1}');
msgConnectionError2 = localize('msgConnectionError2', 'Failed to connect: {0}');
msgConnectionErrorPasswordExpired = localize('msgConnectionErrorPasswordExpired', 'Error {0}: {1} Please login as a different user and change the password using ALTER LOGIN.');
connectionErrorChannelName = localize('connectionErrorChannelName', 'Connection Errors');
msgPromptCancelConnect = localize('msgPromptCancelConnect', 'Server connection in progress. Do you want to cancel?');
msgPromptClearRecentConnections = localize('msgPromptClearRecentConnections', 'Confirm to clear recent connections list');
extensionActivated = localize('extensionActivated', 'activated.');
extensionDeactivated = localize('extensionDeactivated', 'de-activated.');
msgOpenSqlFile = localize('msgOpenSqlFile', 'To use this command, Open a .sql file -or- Change editor language to "SQL" -or- Select T-SQL text in the active SQL editor.');
recentConnectionsPlaceholder = localize('recentConnectionsPlaceholder', 'Choose a connection profile from the list below');
msgNoConnectionsInSettings = localize('msgNoConnectionsInSettings', 'To use this command, add connection profile to User Settings.');
labelOpenGlobalSettings = localize('labelOpenGlobalSettings', 'Open Global Settings');
labelOpenWorkspaceSettings = localize('labelOpenWorkspaceSettings', 'Open Workspace Settings');
CreateProfileFromConnectionsListLabel = localize('CreateProfileFromConnectionsListLabel', 'Create Connection Profile');
CreateProfileLabel = localize('CreateProfileLabel', 'Create');
ClearRecentlyUsedLabel = localize('ClearRecentlyUsedLabel', 'Clear Recent Connections List');
EditProfilesLabel = localize('EditProfilesLabel', 'Edit');
RemoveProfileLabel = localize('RemoveProfileLabel', 'Remove');
ManageProfilesPrompt = localize('ManageProfilesPrompt', 'Manage Connection Profiles');
SampleServerName = localize('SampleServerName', '{{put-server-name-here}}');
serverPrompt = localize('serverPrompt', 'Server name');
serverPlaceholder = localize('serverPlaceholder', 'hostname\\instance or <server>.database.windows.net');
databasePrompt = localize('databasePrompt', 'Database name');
databasePlaceholder = localize('databasePlaceholder', '[Optional] Database to connect (press Enter to connect to <default> database)');
databaseDefaultValue = localize('databaseDefaultValue', 'master');
authTypePrompt = localize('authTypePrompt', 'Authentication Type');
authTypeIntegrated = localize('authTypeIntegrated', 'Integrated');
authTypeSql = localize('authTypeSql', 'SQL Login');
authTypeAdUniversal = localize('authTypeAdUniversal', 'Active Directory Universal');
usernamePrompt = localize('usernamePrompt', 'User name');
usernamePlaceholder = localize('usernamePlaceholder', 'User name (SQL Login)');
passwordPrompt = localize('passwordPrompt', 'Password');
passwordPlaceholder = localize('passwordPlaceholder', 'Password (SQL Login)');
msgSavePassword = localize('msgSavePassword', 'Save Password? If \'No\', password will be required each time you connect');
profileNamePrompt = localize('profileNamePrompt', 'Profile Name');
profileNamePlaceholder = localize('profileNamePlaceholder', '[Optional] Enter a name for this profile');
filepathPrompt = localize('filepathPrompt', 'File path');
filepathPlaceholder = localize('filepathPlaceholder', 'File name');
filepathMessage = localize('filepathMessage', 'File name');
overwritePrompt = localize('overwritePrompt', 'A file with this name already exists. Do you want to replace the existing file?');
overwritePlaceholder = localize('overwritePlaceholder', 'A file with this name already exists');
msgSaveResultInProgress = localize('msgSaveResultInProgress', 'A save request is already executing. Please wait for its completion.');
msgCannotOpenContent = localize('msgCannotOpenContent', 'Error occurred opening content in editor.');
msgSaveStarted = localize('msgSaveStarted', 'Started saving results to ');
msgSaveFailed = localize('msgSaveFailed', 'Failed to save results. ');
msgSaveSucceeded = localize('msgSaveSucceeded', 'Successfully saved results to ');
msgSelectProfile = localize('msgSelectProfile', 'Select connection profile');
msgSelectProfileToRemove = localize('msgSelectProfileToRemove', 'Select profile to remove');
confirmRemoveProfilePrompt = localize('confirmRemoveProfilePrompt', 'Confirm to remove this profile.');
msgNoProfilesSaved = localize('msgNoProfilesSaved', 'No connection profile to remove.');
msgProfileRemoved = localize('msgProfileRemoved', 'Profile removed successfully');
msgProfileCreated = localize('msgProfileCreated', 'Profile created successfully');
msgProfileCreatedAndConnected = localize('msgProfileCreatedAndConnected', 'Profile created and connected');
msgClearedRecentConnections = localize('msgClearedRecentConnections', 'Recent connections list cleared');
msgSelectionIsRequired = localize('msgSelectionIsRequired', 'Selection is required.');
msgIsRequired = localize('msgIsRequired', ' is required.');
msgRetry = localize('msgRetry', 'Retry');
msgError = localize('msgError', 'Error: ');
msgYes = localize('msgYes', 'Yes');
msgNo = localize('msgNo', 'No');
defaultDatabaseLabel = localize('defaultDatabaseLabel', '<default>');
notConnectedLabel = localize('notConnectedLabel', 'Disconnected');
notConnectedTooltip = localize('notConnectedTooltip', 'Click to connect to a database');
connectingLabel = localize('connectingLabel', 'Connecting');
connectingTooltip = localize('connectingTooltip', 'Connecting to: ');
connectedLabel = localize('connectedLabel', 'Connected.');
connectErrorLabel = localize('connectErrorLabel', 'Connection error');
connectErrorTooltip = localize('connectErrorTooltip', 'Error connecting to: ');
connectErrorCode = localize('connectErrorCode', 'Errorcode: ');
connectErrorMessage = localize('connectErrorMessage', 'ErrorMessage: ');
executeQueryLabel = localize('executeQueryLabel', 'Executing query ');
cancelingQueryLabel = localize('cancelingQueryLabel', 'Canceling query ');
updatingIntelliSenseLabel = localize('updatingIntelliSenseLabel', 'Updating IntelliSense...');
unfoundResult = localize('unfoundResult', 'Data was disposed when text editor was closed; to view data please reexecute query.');
extensionNotInitializedError = localize('extensionNotInitializedError', 'Unable to execute the command while the extension is initializing. Please try again later.');
untitledScheme = localize('untitledScheme', 'untitled');
msgChangeLanguageMode = localize('msgChangeLanguageMode', 'To use this command, you must set the language to "SQL". Confirm to change language mode.');
msgChangedDatabaseContext = localize('msgChangedDatabaseContext', 'Changed database context to "{0}" for document "{1}"');
msgPromptRetryCreateProfile = localize('msgPromptRetryCreateProfile', 'Error: Unable to connect using the connection information provided. Retry profile creation?');
retryLabel = localize('retryLabel', 'Retry');
msgConnecting = localize('msgConnecting', 'Connecting to server "{0}" on document "{1}".');
msgConnectedServerInfo = localize('msgConnectedServerInfo', 'Connected to server "{0}" on document "{1}". Server information: {2}');
msgConnectionFailed = localize('msgConnectionFailed', 'Error connecting to server "{0}". Details: {1}');
msgChangingDatabase = localize('msgChangingDatabase', 'Changing database context to "{0}" on server "{1}" on document "{2}".');
msgChangedDatabase = localize('msgChangedDatabase', 'Changed database context to "{0}" on server "{1}" on document "{2}".');
msgDisconnected = localize('msgDisconnected', 'Disconnected on document "{0}"');
msgErrorReadingConfigFile = localize('msgErrorReadingConfigFile', 'Error: Unable to load connection profiles from [{0}]. Check if the file is formatted correctly.');
msgErrorOpeningConfigFile = localize('msgErrorOpeningConfigFile', 'Error: Unable to open connection profile settings file.');
titleResultsPane = localize('titleResultsPane', 'Results: {0}');
macOpenSslErrorMessage = localize('macOpenSslErrorMessage', 'OpenSSL version >=1.0.1 is required to connect.');
macOpenSslHelpButton = localize('macOpenSslHelpButton', 'Help');
gettingDefinitionMessage = localize('gettingDefinitionMessage', 'Getting definition ...');
definitionRequestedStatus = localize('definitionRequestedStatus', 'DefinitionRequested');
definitionRequestCompletedStatus = localize('definitionRequestCompletedStatus', 'DefinitionRequestCompleted');
updatingIntelliSenseStatus = localize('updatingIntelliSenseStatus', 'updatingIntelliSense');
intelliSenseUpdatedStatus = localize('intelliSenseUpdatedStatus', 'intelliSenseUpdated');
testLocalizationConstant = localize('testLocalizationConstant', 'test_en');
};

Просмотреть файл

@ -13,7 +13,8 @@ import { BatchSummary, QueryExecuteParams, QueryExecuteRequest,
QueryDisposeRequest, QueryExecuteBatchNotificationParams } from '../models/contracts/queryExecute';
import { QueryCancelParams, QueryCancelResult, QueryCancelRequest } from '../models/contracts/QueryCancel';
import { ISlickRange, ISelectionData } from '../models/interfaces';
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import * as Utils from './../models/utils';
import * as os from 'os';
@ -111,7 +112,7 @@ export default class QueryRunner {
// Pulls the query text from the current document/selection and initiates the query
public runQuery(selection: ISelectionData): Thenable<void> {
const self = this;
this._vscodeWrapper.logToOutputChannel(Utils.formatString(Constants.msgStartedExecute, this._uri));
this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgStartedExecute, this._uri));
// Put together the request
let queryDetails: QueryExecuteParams = {
@ -140,7 +141,7 @@ export default class QueryRunner {
// handle the result of the notification
public handleQueryComplete(result: QueryExecuteCompleteNotificationResult): void {
this._vscodeWrapper.logToOutputChannel(Utils.formatString(Constants.msgFinishedExecute, this._uri));
this._vscodeWrapper.logToOutputChannel(Utils.formatString(LocalizedConstants.msgFinishedExecute, this._uri));
// Store the batch sets we got back as a source of "truth"
this._isExecuting = false;

Просмотреть файл

@ -1,7 +1,8 @@
'use strict';
import vscode = require('vscode');
import { ConnectionCredentials } from '../models/connectionCredentials';
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import * as ConnectionContracts from '../models/contracts/connection';
import * as LanguageServiceContracts from '../models/contracts/languageService';
import Utils = require('../models/utils');
@ -194,7 +195,7 @@ export default class ConnectionManager {
// Using a lambda here to perform variable capture on the 'this' reference
const self = this;
return (event: LanguageServiceContracts.IntelliSenseReadyParams): void => {
self._statusView.languageServiceStatusChanged(event.ownerUri, Constants.intelliSenseUpdatedStatus);
self._statusView.languageServiceStatusChanged(event.ownerUri, LocalizedConstants.intelliSenseUpdatedStatus);
let connection = self.getConnectionInfo(event.ownerUri);
if (connection !== undefined) {
connection.intelliSenseTimer.end();
@ -231,7 +232,7 @@ export default class ConnectionManager {
self._statusView.connectSuccess(event.ownerUri, connectionInfo.credentials, connectionInfo.serverInfo);
let logMessage = Utils.formatString(Constants.msgChangedDatabaseContext, event.connection.databaseName, event.ownerUri);
let logMessage = Utils.formatString(LocalizedConstants.msgChangedDatabaseContext, event.connection.databaseName, event.ownerUri);
self.vscodeWrapper.logToOutputChannel(logMessage);
}
@ -281,10 +282,10 @@ export default class ConnectionManager {
connection.credentials = newCredentials;
this.statusView.connectSuccess(fileUri, newCredentials, connection.serverInfo);
this.statusView.languageServiceStatusChanged(fileUri, Constants.updatingIntelliSenseStatus);
this.statusView.languageServiceStatusChanged(fileUri, LocalizedConstants.updatingIntelliSenseStatus);
this._vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgConnectedServerInfo, connection.credentials.server, fileUri, JSON.stringify(connection.serverInfo))
Utils.formatString(LocalizedConstants.msgConnectedServerInfo, connection.credentials.server, fileUri, JSON.stringify(connection.serverInfo))
);
connection.extensionTimer.end();
@ -307,29 +308,32 @@ export default class ConnectionManager {
// Check if the error is an expired password
if (result.errorNumber === Constants.errorPasswordExpired || result.errorNumber === Constants.errorPasswordNeedsReset) {
// TODO: we should allow the user to change their password here once corefx supports SqlConnection.ChangePassword()
Utils.showErrorMsg(Utils.formatString(Constants.msgConnectionErrorPasswordExpired, result.errorNumber, result.errorMessage));
Utils.showErrorMsg(Utils.formatString(LocalizedConstants.msgConnectionErrorPasswordExpired, result.errorNumber, result.errorMessage));
} else {
Utils.showErrorMsg(Utils.formatString(Constants.msgConnectionError, result.errorNumber, result.errorMessage));
Utils.showErrorMsg(Utils.formatString(LocalizedConstants.msgConnectionError, result.errorNumber, result.errorMessage));
}
} else {
PlatformInformation.GetCurrent().then( platformInfo => {
if (platformInfo.runtimeId === Runtime.OSX_10_11_64 &&
result.messages.indexOf('Unable to load DLL \'System.Security.Cryptography.Native\'') !== -1) {
this.vscodeWrapper.showErrorMessage(Utils.formatString(Constants.msgConnectionError2,
Constants.macOpenSslErrorMessage), Constants.macOpenSslHelpButton).then(action => {
if (action && action === Constants.macOpenSslHelpButton) {
this.vscodeWrapper.showErrorMessage(Utils.formatString(LocalizedConstants.msgConnectionError2,
LocalizedConstants.macOpenSslErrorMessage), LocalizedConstants.macOpenSslHelpButton).then(action => {
if (action && action === LocalizedConstants.macOpenSslHelpButton) {
opener(Constants.macOpenSslHelpLink);
}
});
} else {
Utils.showErrorMsg(Utils.formatString(Constants.msgConnectionError2, result.messages));
Utils.showErrorMsg(Utils.formatString(LocalizedConstants.msgConnectionError2, result.messages));
}
});
}
this.statusView.connectError(fileUri, connection.credentials, result);
this.vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgConnectionFailed, connection.credentials.server, result.errorMessage ? result.errorMessage : result.messages)
Utils.formatString(
LocalizedConstants.msgConnectionFailed,
connection.credentials.server,
result.errorMessage ? result.errorMessage : result.messages)
);
}
@ -361,7 +365,7 @@ export default class ConnectionManager {
return new Promise<boolean>( (resolve, reject) => {
if (!self.isConnected(fileUri)) {
self.vscodeWrapper.showWarningMessage(Constants.msgChooseDatabaseNotConnected);
self.vscodeWrapper.showWarningMessage(LocalizedConstants.msgChooseDatabaseNotConnected);
resolve(false);
return;
}
@ -374,7 +378,7 @@ export default class ConnectionManager {
self.connectionUI.showDatabasesOnCurrentServer(self._connections[fileUri].credentials, result.databaseNames).then( newDatabaseCredentials => {
if (newDatabaseCredentials) {
self.vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgChangingDatabase, newDatabaseCredentials.database, newDatabaseCredentials.server, fileUri)
Utils.formatString(LocalizedConstants.msgChangingDatabase, newDatabaseCredentials.database, newDatabaseCredentials.server, fileUri)
);
self.disconnect(fileUri).then( () => {
@ -382,7 +386,10 @@ export default class ConnectionManager {
Telemetry.sendTelemetryEvent('UseDatabase');
self.vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgChangedDatabase, newDatabaseCredentials.database, newDatabaseCredentials.server, fileUri)
Utils.formatString(
LocalizedConstants.msgChangedDatabase,
newDatabaseCredentials.database,
newDatabaseCredentials.server, fileUri)
);
resolve(true);
}).catch(err => {
@ -418,7 +425,7 @@ export default class ConnectionManager {
Telemetry.sendTelemetryEvent('DatabaseDisconnected');
self.vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgDisconnected, fileUri)
Utils.formatString(LocalizedConstants.msgDisconnected, fileUri)
);
}
@ -468,7 +475,7 @@ export default class ConnectionManager {
return new Promise<boolean>((resolve, reject) => {
if (!fileUri) {
// A text document needs to be open before we can connect
self.vscodeWrapper.showWarningMessage(Constants.msgOpenSqlFile);
self.vscodeWrapper.showWarningMessage(LocalizedConstants.msgOpenSqlFile);
resolve(false);
return;
} else if (!self.vscodeWrapper.isEditingSqlFile) {
@ -500,7 +507,7 @@ export default class ConnectionManager {
self.statusView.connecting(fileUri, connectionCreds);
self.vscodeWrapper.logToOutputChannel(
Utils.formatString(Constants.msgConnecting, connectionCreds.server, fileUri)
Utils.formatString(LocalizedConstants.msgConnecting, connectionCreds.server, fileUri)
);
// Setup the handler for the connection complete notification to call

Просмотреть файл

@ -4,7 +4,8 @@ import * as ws from 'ws';
import url = require('url');
import querystring = require('querystring');
import Utils = require('../models/utils');
import Constants = require('../models/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import Constants = require('../constants/constants');
import Interfaces = require('../models/interfaces');
import http = require('http');
const bodyParser = require('body-parser');
@ -39,7 +40,7 @@ export default class LocalWebService {
this.app.use(express.static(LocalWebService.staticContentPath));
this.app.use(bodyParser.json({limit: '50mb', type: 'application/json'}));
this.app.set('view engine', 'ejs');
Utils.logDebug(Constants.msgLocalWebserviceStaticContent + LocalWebService.staticContentPath);
Utils.logDebug(LocalizedConstants.msgLocalWebserviceStaticContent + LocalWebService.staticContentPath);
this.server.on('request', this.app);
// Handle new connections to the web socket server
@ -129,7 +130,7 @@ export default class LocalWebService {
start(): void {
const port = this.server.listen(0).address().port; // 0 = listen on a random port
Utils.logDebug(Constants.msgLocalWebserviceStarted + port);
Utils.logDebug(LocalizedConstants.msgLocalWebserviceStarted + port);
LocalWebService._servicePort = port.toString();
}
}

Просмотреть файл

@ -6,7 +6,8 @@
'use strict';
import * as events from 'events';
import vscode = require('vscode');
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import Utils = require('../models/utils');
import { SqlOutputContentProvider } from '../models/SqlOutputContentProvider';
import StatusView from '../views/statusView';
@ -78,7 +79,7 @@ export default class MainController implements vscode.Disposable {
* Deactivates the extension
*/
public deactivate(): void {
Utils.logDebug(Constants.extensionDeactivated);
Utils.logDebug(LocalizedConstants.extensionDeactivated);
this.onDisconnect();
this._statusview.dispose();
}
@ -162,7 +163,7 @@ export default class MainController implements vscode.Disposable {
self.showReleaseNotesPrompt();
Utils.logDebug(Constants.extensionActivated);
Utils.logDebug(LocalizedConstants.extensionActivated);
self._initialized = true;
resolve(true);
}).catch(err => {
@ -243,7 +244,7 @@ export default class MainController implements vscode.Disposable {
self.onRunQuery();
}
}).catch(err => {
self._vscodeWrapper.showErrorMessage(Constants.msgError + err);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgError + err);
});
} else if (!this._connectionMgr.isConnected(this._vscodeWrapper.activeTextEditorUri)) {
// If we are disconnected, prompt the user to choose a connection before executing
@ -252,7 +253,7 @@ export default class MainController implements vscode.Disposable {
self.onRunQuery();
}
}).catch(err => {
self._vscodeWrapper.showErrorMessage(Constants.msgError + err);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgError + err);
});
} else {
let editor = this._vscodeWrapper.activeTextEditor;
@ -294,7 +295,7 @@ export default class MainController implements vscode.Disposable {
private runAndLogErrors<T>(promise: Promise<T>, handlerName: string): Promise<T> {
let self = this;
return promise.catch(err => {
self._vscodeWrapper.showErrorMessage(Constants.msgError + err);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgError + err);
Telemetry.sendTelemetryEventForException(err, handlerName);
});
}
@ -320,7 +321,7 @@ export default class MainController implements vscode.Disposable {
*/
private CanRunCommand(): boolean {
if (this._connectionMgr === undefined) {
Utils.showErrorMsg(Constants.extensionNotInitializedError);
Utils.showErrorMsg(LocalizedConstants.extensionNotInitializedError);
return false;
}
return true;
@ -424,7 +425,7 @@ export default class MainController implements vscode.Disposable {
// If there was a saveTextDoc event just before this closeTextDoc event and it
// was untitled then we know it was an untitled save
if (this._lastSavedUri &&
closedDocumentUriScheme === Constants.untitledScheme &&
closedDocumentUriScheme === LocalizedConstants.untitledScheme &&
this._lastSavedTimer.getDuration() < Constants.untitledSaveTimeThreshold) {
// Untitled file was saved and connection will be transfered
this._connectionMgr.transferFileConnection(closedDocumentUri, this._lastSavedUri);

Просмотреть файл

@ -1,7 +1,7 @@
import vscode = require('vscode');
import * as Constants from './../models/constants';
import * as Constants from './../constants/constants';
export import TextEditor = vscode.TextEditor;

Просмотреть файл

@ -1,14 +1,26 @@
'use strict';
import vscode = require('vscode');
import Constants = require('./constants/constants');
import * as LocalizedConstants from './constants/localizedConstants';
import MainController from './controllers/mainController';
import VscodeWrapper from './controllers/vscodeWrapper';
let controller: MainController = undefined;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext): Promise<boolean> {
controller = new MainController(context);
let vscodeWrapper = new VscodeWrapper();
controller = new MainController(context, undefined, vscodeWrapper);
context.subscriptions.push(controller);
// Checking if localization should be applied
let config = vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
let applyLocalization = config[Constants.configApplyLocalization];
if (applyLocalization) {
LocalizedConstants.loadLocalizedConstants(vscode.env.language);
}
return controller.activate();
}

Просмотреть файл

@ -7,7 +7,7 @@
import {IStatusView} from './interfaces';
import vscode = require('vscode');
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
/*
* The status class which includes the service initialization result.

Просмотреть файл

@ -9,7 +9,7 @@ import {Runtime, getRuntimeDisplayName} from '../models/platform';
import * as path from 'path';
import {IConfig, IStatusView, IPackage, PackageError, IHttpClient, IDecompressProvider} from './interfaces';
import {ILogger} from '../models/interfaces';
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import * as tmp from 'tmp';
let fse = require('fs-extra');

Просмотреть файл

@ -14,7 +14,7 @@ import Telemetry from '../models/telemetry';
import * as Utils from '../models/utils';
import {VersionRequest} from '../models/contracts';
import {Logger} from '../models/logger';
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import ServerProvider from './server';
import ServiceDownloadProvider from './serviceDownloadProvider';
import DecompressProvider from './decompressProvider';
@ -24,6 +24,7 @@ import {PlatformInformation} from '../models/platform';
import {ServerInitializationResult, ServerStatusView} from './serverStatus';
import StatusView from '../views/statusView';
import * as LanguageServiceContracts from '../models/contracts/languageService';
let vscode = require('vscode');
let opener = require('opener');
let _channel: OutputChannel = undefined;
@ -294,15 +295,24 @@ export default class SqlToolsServiceClient {
serverCommand = 'dotnet';
}
// Enable diagnostic logging in the service if it is configured
// Get the extenion's configuration
let config = workspace.getConfiguration(Constants.extensionConfigSectionName);
if (config) {
// Enable diagnostic logging in the service if it is configured
let logDebugInfo = config[Constants.configLogDebugInfo];
if (logDebugInfo) {
serverArgs.push('--enable-logging');
}
// Send Locale for sqltoolsservice localization
let applyLocalization = config[Constants.configApplyLocalization];
if (applyLocalization) {
let locale = vscode.env.language;
serverArgs.push('--locale ' + locale);
}
}
// run the service host using dotnet.exe from the path
let serverOptions: ServerOptions = { command: serverCommand, args: serverArgs, transport: TransportKind.stdio };
return serverOptions;

Просмотреть файл

@ -2,7 +2,8 @@
import vscode = require('vscode');
import path = require('path');
import os = require('os');
import Constants = require('./constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import LocalWebService from '../controllers/localWebService';
import Utils = require('./utils');
import Interfaces = require('./interfaces');
@ -229,7 +230,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
// If the query is already in progress, don't attempt to send it
if (existingRunner.isExecutingQuery) {
this._vscodeWrapper.showInformationMessage(Constants.msgRunQueryInProgress);
this._vscodeWrapper.showInformationMessage(LocalizedConstants.msgRunQueryInProgress);
return;
}
@ -258,12 +259,12 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
}
let message = {
message: Constants.runQueryBatchStartMessage,
message: LocalizedConstants.runQueryBatchStartMessage,
batchId: undefined,
isError: false,
time: new Date().toLocaleTimeString(),
link: {
text: Utils.formatString(Constants.runQueryBatchStartLine, batch.selection.startLine + 1),
text: Utils.formatString(LocalizedConstants.runQueryBatchStartLine, batch.selection.startLine + 1),
uri: link
}
};
@ -282,7 +283,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
}
queryRunner.runQuery(selection);
let paneTitle = Utils.formatString(Constants.titleResultsPane, queryRunner.title);
let paneTitle = Utils.formatString(LocalizedConstants.titleResultsPane, queryRunner.title);
// Always run this command even if just updating to avoid a bug - tfs 8686842
this.displayResultPane(resultsUri, paneTitle);
}
@ -334,7 +335,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
}
if (queryRunner === undefined || !queryRunner.isExecutingQuery) {
self._vscodeWrapper.showInformationMessage(Constants.msgCancelQueryNotRunning);
self._vscodeWrapper.showInformationMessage(LocalizedConstants.msgCancelQueryNotRunning);
return;
}
@ -344,7 +345,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
// Cancel the query
queryRunner.cancel().then(success => undefined, error => {
// On error, show error message
self._vscodeWrapper.showErrorMessage(Utils.formatString(Constants.msgCancelQueryFailed, error));
self._vscodeWrapper.showErrorMessage(Utils.formatString(LocalizedConstants.msgCancelQueryFailed, error));
});
}
@ -480,7 +481,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
edit.insert(new vscode.Position(0, 0), content);
}).then(result => {
if (!result) {
self._vscodeWrapper.showErrorMessage(Constants.msgCannotOpenContent);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgCannotOpenContent);
}
});
}, (error: any) => {

Просмотреть файл

@ -1,5 +1,5 @@
'use strict';
import Constants = require('./constants');
import LocalizedConstants = require('../constants/localizedConstants');
import { ConnectionDetails } from './contracts/connection';
import { IConnectionCredentials, IConnectionProfile, AuthenticationTypes } from './interfaces';
import { ConnectionStore } from './connectionStore';
@ -91,8 +91,8 @@ export class ConnectionCredentials implements IConnectionCredentials {
// Potentially ask to save password
questions.push({
type: QuestionTypes.confirm,
name: Constants.msgSavePassword,
message: Constants.msgSavePassword,
name: LocalizedConstants.msgSavePassword,
message: LocalizedConstants.msgSavePassword,
shouldPrompt: (answers) => {
if (isProfile) {
// For profiles, ask to save password if we are using SQL authentication and the user just entered their password for the first time
@ -151,20 +151,20 @@ export class ConnectionCredentials implements IConnectionCredentials {
// Server must be present
{
type: QuestionTypes.input,
name: Constants.serverPrompt,
message: Constants.serverPrompt,
placeHolder: Constants.serverPlaceholder,
name: LocalizedConstants.serverPrompt,
message: LocalizedConstants.serverPrompt,
placeHolder: LocalizedConstants.serverPlaceholder,
default: defaultProfileValues ? defaultProfileValues.server : undefined,
shouldPrompt: (answers) => utils.isEmpty(credentials.server),
validate: (value) => ConnectionCredentials.validateRequiredString(Constants.serverPrompt, value),
validate: (value) => ConnectionCredentials.validateRequiredString(LocalizedConstants.serverPrompt, value),
onAnswered: (value) => credentials.server = value
},
// Database name is not required, prompt is optional
{
type: QuestionTypes.input,
name: Constants.databasePrompt,
message: Constants.databasePrompt,
placeHolder: Constants.databasePlaceholder,
name: LocalizedConstants.databasePrompt,
message: LocalizedConstants.databasePrompt,
placeHolder: LocalizedConstants.databasePlaceholder,
default: defaultProfileValues ? defaultProfileValues.database : undefined,
shouldPrompt: (answers) => promptForDbName,
onAnswered: (value) => credentials.database = value
@ -172,8 +172,8 @@ export class ConnectionCredentials implements IConnectionCredentials {
// AuthenticationType is required if there is more than 1 option on this platform
{
type: QuestionTypes.expand,
name: Constants.authTypePrompt,
message: Constants.authTypePrompt,
name: LocalizedConstants.authTypePrompt,
message: LocalizedConstants.authTypePrompt,
choices: authenticationChoices,
shouldPrompt: (answers) => utils.isEmpty(credentials.authenticationType) && authenticationChoices.length > 1,
onAnswered: (value) => {
@ -183,24 +183,24 @@ export class ConnectionCredentials implements IConnectionCredentials {
// Username must be pressent
{
type: QuestionTypes.input,
name: Constants.usernamePrompt,
message: Constants.usernamePrompt,
placeHolder: Constants.usernamePlaceholder,
name: LocalizedConstants.usernamePrompt,
message: LocalizedConstants.usernamePrompt,
placeHolder: LocalizedConstants.usernamePlaceholder,
default: defaultProfileValues ? defaultProfileValues.user : undefined,
shouldPrompt: (answers) => ConnectionCredentials.shouldPromptForUser(credentials),
validate: (value) => ConnectionCredentials.validateRequiredString(Constants.usernamePrompt, value),
validate: (value) => ConnectionCredentials.validateRequiredString(LocalizedConstants.usernamePrompt, value),
onAnswered: (value) => credentials.user = value
},
// Password may or may not be necessary
{
type: QuestionTypes.password,
name: Constants.passwordPrompt,
message: Constants.passwordPrompt,
placeHolder: Constants.passwordPlaceholder,
name: LocalizedConstants.passwordPrompt,
message: LocalizedConstants.passwordPrompt,
placeHolder: LocalizedConstants.passwordPlaceholder,
shouldPrompt: (answers) => ConnectionCredentials.shouldPromptForPassword(credentials),
validate: (value) => {
if (isPasswordRequired) {
return ConnectionCredentials.validateRequiredString(Constants.passwordPrompt, value);
return ConnectionCredentials.validateRequiredString(LocalizedConstants.passwordPrompt, value);
}
return undefined;
},
@ -230,18 +230,18 @@ export class ConnectionCredentials implements IConnectionCredentials {
// Validates a string is not empty, returning undefined if true and an error message if not
protected static validateRequiredString(property: string, value: string): string {
if (utils.isEmpty(value)) {
return property + Constants.msgIsRequired;
return property + LocalizedConstants.msgIsRequired;
}
return undefined;
}
public static getAuthenticationTypesChoice(): INameValueChoice[] {
let choices: INameValueChoice[] = [
{ name: Constants.authTypeSql, value: utils.authTypeToString(AuthenticationTypes.SqlLogin) }
{ name: LocalizedConstants.authTypeSql, value: utils.authTypeToString(AuthenticationTypes.SqlLogin) }
];
// In the case of win32 support integrated. For all others only SqlAuth supported
if ('win32' === os.platform()) {
choices.push({ name: Constants.authTypeIntegrated, value: utils.authTypeToString(AuthenticationTypes.Integrated) });
choices.push({ name: LocalizedConstants.authTypeIntegrated, value: utils.authTypeToString(AuthenticationTypes.Integrated) });
}
// TODO When Azure Active Directory is supported, add this here

Просмотреть файл

@ -1,5 +1,6 @@
'use strict';
import Constants = require('./constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import Interfaces = require('./interfaces');
import * as ConnectionContracts from '../models/contracts/connection';
import * as Utils from './utils';
@ -116,7 +117,7 @@ export function getConnectionDisplayString(creds: Interfaces.IConnectionCredenti
if (creds.database !== '') {
text = appendIfNotEmpty(text, creds.database);
} else {
text = appendIfNotEmpty(text, Constants.defaultDatabaseLabel);
text = appendIfNotEmpty(text, LocalizedConstants.defaultDatabaseLabel);
}
let user: string = getUserNameOrDomainLogin(creds);
text = appendIfNotEmpty(text, user);

Просмотреть файл

@ -1,6 +1,5 @@
'use strict';
// import vscode = require('vscode');
import Constants = require('./constants');
import LocalizedConstants = require('../constants/localizedConstants');
import { IConnectionProfile, AuthenticationTypes } from './interfaces';
import { ConnectionCredentials } from './connectionCredentials';
import { QuestionTypes, IQuestion, IPrompter, INameValueChoice } from '../prompts/question';
@ -35,16 +34,16 @@ export class ConnectionProfile extends ConnectionCredentials implements IConnect
questions.push(
{
type: QuestionTypes.confirm,
name: Constants.msgSavePassword,
message: Constants.msgSavePassword,
name: LocalizedConstants.msgSavePassword,
message: LocalizedConstants.msgSavePassword,
shouldPrompt: (answers) => ConnectionCredentials.isPasswordBasedCredential(profile),
onAnswered: (value) => profile.savePassword = value
},
{
type: QuestionTypes.input,
name: Constants.profileNamePrompt,
message: Constants.profileNamePrompt,
placeHolder: Constants.profileNamePlaceholder,
name: LocalizedConstants.profileNamePrompt,
message: LocalizedConstants.profileNamePrompt,
placeHolder: LocalizedConstants.profileNamePlaceholder,
default: defaultProfileValues ? defaultProfileValues.profileName : undefined,
onAnswered: (value) => {
// Fall back to a default name if none specified

Просмотреть файл

@ -1,6 +1,7 @@
'use strict';
import vscode = require('vscode');
import Constants = require('./constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import ConnInfo = require('./connectionInfo');
import Utils = require('../models/utils');
import ValidationException from '../utils/validationException';
@ -105,7 +106,7 @@ export class ConnectionStore {
public getPickListItems(): IConnectionCredentialsQuickPickItem[] {
let pickListItems: IConnectionCredentialsQuickPickItem[] = this.loadAllConnections();
pickListItems.push(<IConnectionCredentialsQuickPickItem> {
label: Constants.CreateProfileFromConnectionsListLabel,
label: LocalizedConstants.CreateProfileFromConnectionsListLabel,
connectionCreds: undefined,
quickPickItemType: CredentialsQuickPickItemType.NewConnection
});
@ -419,7 +420,7 @@ export class ConnectionStore {
let connection = ConnInfo.fixupConnectionCredentials(element);
connections.push(connection);
} else {
Utils.logDebug(Constants.configMyConnectionsNoServerName + ' index (' + index + '): ' + element.toString());
Utils.logDebug(LocalizedConstants.configMyConnectionsNoServerName + ' index (' + index + '): ' + element.toString());
}
}
}

Просмотреть файл

@ -1,254 +0,0 @@
// constants
export const languageId = 'sql';
export const extensionName = 'mssql';
export const extensionConfigSectionName = 'mssql';
export const connectionApplicationName = 'vscode-mssql';
export const outputChannelName = 'MSSQL';
export const connectionConfigFilename = 'settings.json';
export const connectionsArrayName = 'mssql.connections';
export const cmdRunQuery = 'extension.runQuery';
export const cmdCancelQuery = 'extension.cancelQuery';
export const cmdConnect = 'extension.connect';
export const cmdDisconnect = 'extension.disconnect';
export const cmdChooseDatabase = 'extension.chooseDatabase';
export const cmdShowReleaseNotes = 'extension.showReleaseNotes';
export const cmdShowGettingStarted = 'extension.showGettingStarted';
export const cmdNewQuery = 'extension.newQuery';
export const cmdManageConnectionProfiles = 'extension.manageProfiles';
export const sqlDbPrefix = '.database.windows.net';
export const defaultConnectionTimeout = 15;
export const azureSqlDbConnectionTimeout = 30;
export const azureDatabase = 'Azure';
export const defaultPortNumber = 1433;
export const sqlAuthentication = 'SqlLogin';
export const defaultDatabase = 'master';
export const errorPasswordExpired = 18487;
export const errorPasswordNeedsReset = 18488;
export const maxDisplayedStatusTextLength = 50;
export const outputContentTypeRoot = 'root';
export const outputContentTypeMessages = 'messages';
export const outputContentTypeResultsetMeta = 'resultsetsMeta';
export const outputContentTypeColumns = 'columns';
export const outputContentTypeRows = 'rows';
export const outputContentTypeConfig = 'config';
export const outputContentTypeSaveResults = 'saveResults';
export const outputContentTypeOpenLink = 'openLink';
export const outputContentTypeCopy = 'copyResults';
export const outputContentTypeEditorSelection = 'setEditorSelection';
export const outputContentTypeShowError = 'showError';
export const outputContentTypeShowWarning = 'showWarning';
export const outputServiceLocalhost = 'http://localhost:';
export const msgContentProviderSqlOutputHtml = 'dist/html/sqlOutput.ejs';
export const contentProviderMinFile = 'dist/js/app.min.js';
export const copyIncludeHeaders = 'copyIncludeHeaders';
export const configLogDebugInfo = 'logDebugInfo';
export const configMyConnections = 'connections';
export const configSaveAsCsv = 'saveAsCsv';
export const configSaveAsJson = 'saveAsJson';
export const configRecentConnections = 'recentConnections';
export const configMaxRecentConnections = 'maxRecentConnections';
export const configCopyRemoveNewLine = 'copyRemoveNewLine';
export const configSplitPaneSelection = 'splitPaneSelection';
// localizable strings
export const configMyConnectionsNoServerName = 'Missing server name in user preferences connection: ';
export const msgLocalWebserviceStaticContent = 'LocalWebService: added static html content path: ';
export const msgLocalWebserviceStarted = 'LocalWebService listening on port ';
export const msgRunQueryAllBatchesExecuted = 'runQuery: all batches executed';
export const msgStartedExecute = 'Started query execution for document "{0}"';
export const msgFinishedExecute = 'Finished query execution for document "{0}"';
export const msgRunQueryError = 'runQuery: error: ';
export const msgRunQueryExecutingBatch = 'runQuery: executeBatch called with SQL: ';
export const msgRunQueryAddBatchResultsets = 'runQuery: adding resultsets for batch: ';
export const msgRunQueryAddBatchError = 'runQuery: adding error message for batch: ';
export const msgRunQueryConnectionActive = 'runQuery: active connection is connected, using it to run query';
export const msgRunQueryConnectionDisconnected = 'runQuery: active connection is disconnected, reconnecting';
export const msgRunQueryNoConnection = 'runQuery: no active connection - prompting for user';
export const msgRunQueryInProgress = 'A query is already running for this editor session. Please cancel this query or wait for its completion.';
export const runQueryBatchStartMessage = 'Started executing query at ';
export const runQueryBatchStartLine = 'Line {0}';
export const msgCancelQueryFailed = 'Canceling the query failed: {0}';
export const msgCancelQueryNotRunning = 'Cannot cancel query as no query is running.';
export const msgCancelQuerySuccess = 'Successfully canceled the query.';
export const msgContentProviderOnContentUpdated = 'Content provider: onContentUpdated called';
export const msgContentProviderAssociationFailure = 'Content provider: Unable to associate status view for current file';
export const msgContentProviderOnRootEndpoint = 'LocalWebService: Root end-point called';
export const msgContentProviderOnResultsEndpoint = 'LocalWebService: ResultsetsMeta endpoint called';
export const msgContentProviderOnMessagesEndpoint = 'LocalWebService: Messages end-point called';
export const msgContentProviderOnColumnsEndpoint = 'LocalWebService: Columns end-point called for index = ';
export const msgContentProviderOnRowsEndpoint = 'LocalWebService: Rows end-point called for index = ';
export const msgContentProviderOnClear = 'Content provider: clear called';
export const msgContentProviderOnUpdateContent = 'Content provider: updateContent called';
export const msgContentProviderProvideContent = 'Content provider: provideTextDocumentContent called: ';
export const msgChooseDatabaseNotConnected = 'No connection was found. Please connect to a server first.';
export const msgChooseDatabasePlaceholder = 'Choose a database from the list below';
export const msgConnectionError = 'Error {0}: {1}';
export const msgConnectionError2 = 'Failed to connect: {0}';
export const msgConnectionErrorPasswordExpired = 'Error {0}: {1} Please login as a different user and change the password using ALTER LOGIN.';
export const connectionErrorChannelName = 'Connection Errors';
export const msgPromptCancelConnect = 'Server connection in progress. Do you want to cancel?';
export const msgPromptClearRecentConnections = 'Confirm to clear recent connections list';
export const extensionActivated = 'activated.';
export const extensionDeactivated = 'de-activated.';
export const msgOpenSqlFile = 'To use this command, Open a .sql file -or- ' +
'Change editor language to "SQL" -or- ' +
'Select T-SQL text in the active SQL editor.';
export const recentConnectionsPlaceholder = 'Choose a connection profile from the list below';
export const msgNoConnectionsInSettings = 'To use this command, add connection profile to User Settings.';
export const labelOpenGlobalSettings = 'Open Global Settings';
export const labelOpenWorkspaceSettings = 'Open Workspace Settings';
export const CreateProfileFromConnectionsListLabel = 'Create Connection Profile';
export const CreateProfileLabel = 'Create';
export const ClearRecentlyUsedLabel = 'Clear Recent Connections List';
export const EditProfilesLabel = 'Edit';
export const RemoveProfileLabel = 'Remove';
export const ManageProfilesPrompt = 'Manage Connection Profiles';
export const SampleServerName = '{{put-server-name-here}}';
export const serverPrompt = 'Server name';
export const serverPlaceholder = 'hostname\\instance or <server>.database.windows.net';
export const databasePrompt = 'Database name';
export const databasePlaceholder = '[Optional] Database to connect (press Enter to connect to <default> database)';
export const databaseDefaultValue = 'master';
export const authTypePrompt = 'Authentication Type';
export const authTypeIntegrated = 'Integrated';
export const authTypeSql = 'SQL Login';
export const authTypeAdUniversal = 'Active Directory Universal';
export const usernamePrompt = 'User name';
export const usernamePlaceholder = 'User name (SQL Login)';
export const passwordPrompt = 'Password';
export const passwordPlaceholder = 'Password (SQL Login)';
export const msgSavePassword = 'Save Password? If \'No\', password will be required each time you connect';
export const profileNamePrompt = 'Profile Name';
export const profileNamePlaceholder = '[Optional] Enter a name for this profile';
export const filepathPrompt = 'File path';
export const filepathPlaceholder = 'File name';
export const filepathMessage = 'File name';
export const overwritePrompt = 'A file with this name already exists. Do you want to replace the existing file?';
export const overwritePlaceholder = 'A file with this name already exists';
export const msgSaveResultInProgress = 'A save request is already executing. Please wait for its completion.';
export const msgCannotOpenContent = 'Error occurred opening content in editor.';
export const msgSaveStarted = 'Started saving results to ';
export const msgSaveFailed = 'Failed to save results. ';
export const msgSaveSucceeded = 'Successfully saved results to ';
export const msgSelectProfile = 'Select connection profile';
export const msgSelectProfileToRemove = 'Select profile to remove';
export const confirmRemoveProfilePrompt = 'Confirm to remove this profile.';
export const msgNoProfilesSaved = 'No connection profile to remove.';
export const msgProfileRemoved = 'Profile removed successfully';
export const msgProfileCreated = 'Profile created successfully';
export const msgProfileCreatedAndConnected = 'Profile created and connected';
export const msgClearedRecentConnections = 'Recent connections list cleared';
export const msgSelectionIsRequired = 'Selection is required.';
export const msgIsRequired = ' is required.';
export const msgRetry = 'Retry';
export const msgError = 'Error: ';
export const msgYes = 'Yes';
export const msgNo = 'No';
export const defaultDatabaseLabel = '<default>';
export const notConnectedLabel = 'Disconnected';
export const notConnectedTooltip = 'Click to connect to a database';
export const connectingLabel = 'Connecting';
export const connectingTooltip = 'Connecting to: ';
export const connectedLabel = 'Connected.';
export const connectErrorLabel = 'Connection error';
export const connectErrorTooltip = 'Error connecting to: ';
export const connectErrorCode = 'Errorcode: ';
export const connectErrorMessage = 'ErrorMessage: ';
export const executeQueryLabel = 'Executing query ';
export const cancelingQueryLabel = 'Canceling query ';
export const updatingIntelliSenseLabel = 'Updating IntelliSense...';
export const unfoundResult = 'Data was disposed when text editor was closed; to view data please reexecute query.';
export const serviceCompatibleVersion = '1.0.0';
export const serviceNotCompatibleError = 'Client is not compatible with the service layer';
export const serviceInstalling = 'Installing';
export const serviceInstallingTo = 'Installing SQL tools service to';
export const serviceInitializing = 'Initializing SQL tools service for the mssql extension.';
export const commandsNotAvailableWhileInstallingTheService = 'Note: mssql commands will be available after installing the service.';
export const serviceDownloading = 'Downloading';
export const serviceInstalled = 'Sql Tools Service installed';
export const serviceInstallationFailed = 'Failed to install Sql Tools Service';
export const serviceLoadingFailed = 'Failed to load Sql Tools Service';
export const unsupportedPlatformErrorMessage = 'The platform is not supported';
export const invalidServiceFilePath = 'Invalid file path for Sql Tools Service';
export const extensionNotInitializedError = 'Unable to execute the command while the extension is initializing. Please try again later.';
export const untitledScheme = 'untitled';
export const untitledSaveTimeThreshold = 10.0;
export const renamedOpenTimeThreshold = 10.0;
export const msgChangeLanguageMode = 'To use this command, you must set the language to \"SQL\". Confirm to change language mode.';
export const timeToWaitForLanguageModeChange = 10000.0;
export const msgChangedDatabaseContext = 'Changed database context to \"{0}\" for document \"{1}\"';
export const msgPromptRetryCreateProfile = 'Error: Unable to connect using the connection information provided. Retry profile creation?';
export const retryLabel = 'Retry';
export const msgConnecting = 'Connecting to server \"{0}\" on document \"{1}\".';
export const msgConnectedServerInfo = 'Connected to server \"{0}\" on document \"{1}\". Server information: {2}';
export const msgConnectionFailed = 'Error connecting to server \"{0}\". Details: {1}';
export const msgChangingDatabase = 'Changing database context to \"{0}\" on server \"{1}\" on document \"{2}\".';
export const msgChangedDatabase = 'Changed database context to \"{0}\" on server \"{1}\" on document \"{2}\".';
export const msgDisconnected = 'Disconnected on document \"{0}\"';
export const msgErrorReadingConfigFile = 'Error: Unable to load connection profiles from [{0}]. Check if the file is formatted correctly.';
export const msgErrorOpeningConfigFile = 'Error: Unable to open connection profile settings file.';
export const sqlToolsServiceConfigKey = 'service';
export const sqlToolsServiceInstallDirConfigKey = 'installDir';
export const sqlToolsServiceExecutableFilesConfigKey = 'executableFiles';
export const sqlToolsServiceVersionConfigKey = 'version';
export const sqlToolsServiceDownloadUrlConfigKey = 'downloadUrl';
export const extConfigResultKeys = ['shortcuts', 'messagesDefaultOpen'];
export const extConfigResultFontFamily = 'resultsFontFamily';
export const extConfigResultFontSize = 'resultsFontSize';
export const titleResultsPane = 'Results: {0}';
export const macOpenSslErrorMessage = `OpenSSL version >=1.0.1 is required to connect.`;
export const macOpenSslHelpButton = 'Help';
export const macOpenSslHelpLink = 'https://github.com/Microsoft/vscode-mssql/wiki/OpenSSL-Configuration';
export const sqlToolsServiceName = 'SQLToolsService';
export const serviceInitializingOutputChannelName = 'SqlToolsService Initialization';
export const gettingStartedGuideLink = 'https://aka.ms/mssql-getting-started';
export const sqlToolsServiceCrashMessage = 'SQL Tools Service component could not start.';
export const sqlToolsServiceCrashButton = 'View Known Issues';
export const sqlToolsServiceCrashLink = 'https://github.com/Microsoft/vscode-mssql/wiki/SqlToolsService-Known-Issues';
export const gettingDefinitionMessage = 'Getting definition ...';
export const definitionRequestedStatus = 'DefinitionRequested';
export const definitionRequestCompletedStatus = 'DefinitionRequestCompleted';
export const updatingIntelliSenseStatus = 'updatingIntelliSense';
export const intelliSenseUpdatedStatus = 'intelliSenseUpdated';

Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
import vscode = require('vscode');
import Constants = require('./constants');
import Constants = require('../constants/constants');
// interfaces
export enum ContentType {

Просмотреть файл

@ -1,6 +1,7 @@
import path = require('path');
import vscode = require('vscode');
import Constants = require('./constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import os = require('os');
import fs = require('fs');
import Interfaces = require('./interfaces');
@ -52,29 +53,29 @@ export default class ResultsSerializer {
// prompt user to enter file path
{
type: QuestionTypes.input,
name: Constants.filepathPrompt,
message: Constants.filepathMessage,
name: LocalizedConstants.filepathPrompt,
message: LocalizedConstants.filepathMessage,
placeHolder: filepathPlaceHolder,
validate: (value) => this.validateFilePath(Constants.filepathPrompt, value)
validate: (value) => this.validateFilePath(LocalizedConstants.filepathPrompt, value)
},
// prompt to overwrite file if file already exists
{
type: QuestionTypes.confirm,
name: Constants.overwritePrompt,
message: Constants.overwritePrompt,
placeHolder: Constants.overwritePlaceholder,
shouldPrompt: (answers) => this.fileExists(answers[Constants.filepathPrompt]),
name: LocalizedConstants.overwritePrompt,
message: LocalizedConstants.overwritePrompt,
placeHolder: LocalizedConstants.overwritePlaceholder,
shouldPrompt: (answers) => this.fileExists(answers[LocalizedConstants.filepathPrompt]),
onAnswered: (value) => prompted = true
}
];
return this._prompter.prompt(questions).then(answers => {
if (answers && answers[Constants.filepathPrompt] ) {
if (answers && answers[LocalizedConstants.filepathPrompt] ) {
// return filename if file does not exist or if user opted to overwrite file
if (!prompted || (prompted && answers[Constants.overwritePrompt])) {
return answers[Constants.filepathPrompt];
if (!prompted || (prompted && answers[LocalizedConstants.overwritePrompt])) {
return answers[LocalizedConstants.filepathPrompt];
}
// call prompt again if user did not opt to overwrite
if (prompted && !answers[Constants.overwritePrompt]) {
if (prompted && !answers[LocalizedConstants.overwritePrompt]) {
return self.promptForFilepath();
}
}
@ -159,7 +160,7 @@ export default class ResultsSerializer {
private validateFilePath(property: string, value: string): string {
if (Utils.isEmpty(value.trim())) {
return property + Constants.msgIsRequired;
return property + LocalizedConstants.msgIsRequired;
}
return undefined;
}
@ -216,24 +217,24 @@ export default class ResultsSerializer {
type = Contracts.SaveResultsAsJsonRequest.type;
}
self._vscodeWrapper.logToOutputChannel(Constants.msgSaveStarted + this._filePath);
self._vscodeWrapper.logToOutputChannel(LocalizedConstants.msgSaveStarted + this._filePath);
// send message to the sqlserverclient for converting resuts to the requested format and saving to filepath
return self._client.sendRequest( type, saveResultsParams).then(result => {
if (result.messages) {
self._vscodeWrapper.showErrorMessage(Constants.msgSaveFailed + result.messages);
self._vscodeWrapper.logToOutputChannel(Constants.msgSaveFailed + result.messages);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgSaveFailed + result.messages);
self._vscodeWrapper.logToOutputChannel(LocalizedConstants.msgSaveFailed + result.messages);
} else {
self._vscodeWrapper.showInformationMessage(Constants.msgSaveSucceeded + this._filePath);
self._vscodeWrapper.logToOutputChannel(Constants.msgSaveSucceeded + filePath);
self._vscodeWrapper.showInformationMessage(LocalizedConstants.msgSaveSucceeded + this._filePath);
self._vscodeWrapper.logToOutputChannel(LocalizedConstants.msgSaveSucceeded + filePath);
self.openSavedFile(self._filePath);
}
// telemetry for save results
Telemetry.sendTelemetryEvent('SavedResults', { 'type': format });
}, error => {
self._vscodeWrapper.showErrorMessage(Constants.msgSaveFailed + error);
self._vscodeWrapper.logToOutputChannel(Constants.msgSaveFailed + error);
self._vscodeWrapper.showErrorMessage(LocalizedConstants.msgSaveFailed + error);
self._vscodeWrapper.logToOutputChannel(LocalizedConstants.msgSaveFailed + error);
});
}

Просмотреть файл

@ -3,7 +3,7 @@ import * as getmac from 'getmac';
import * as crypto from 'crypto';
import * as os from 'os';
import vscode = require('vscode');
import Constants = require('./constants');
import Constants = require('../constants/constants');
import * as interfaces from './interfaces';
import {ExtensionContext} from 'vscode';
import fs = require('fs');

Просмотреть файл

@ -4,7 +4,7 @@
// License: https://github.com/DonJayamanne/bowerVSCode/blob/master/LICENSE
import {window, OutputChannel } from 'vscode';
import * as Constants from '../models/constants';
import * as Constants from '../constants/constants';
import * as nodeUtil from 'util';
import PromptFactory from './factory';
import EscapeException from '../utils/EscapeException';

Просмотреть файл

@ -5,7 +5,7 @@
import {window, QuickPickOptions} from 'vscode';
import Prompt from './prompt';
import Constants = require('../models/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import EscapeException from '../utils/EscapeException';
export default class ConfirmPrompt extends Prompt {
@ -16,8 +16,8 @@ export default class ConfirmPrompt extends Prompt {
public render(): any {
let choices: { [id: string]: boolean } = {};
choices[Constants.msgYes] = true;
choices[Constants.msgNo] = false;
choices[LocalizedConstants.msgYes] = true;
choices[LocalizedConstants.msgNo] = false;
const options: QuickPickOptions = {
placeHolder: this._question.message

Просмотреть файл

@ -1,6 +1,7 @@
'use strict';
import vscode = require('vscode');
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import { ConnectionCredentials } from '../models/connectionCredentials';
import ConnectionManager from '../controllers/connectionManager';
import { ConnectionStore } from '../models/connectionStore';
@ -29,7 +30,7 @@ export class ConnectionUI {
private _connectionStore: ConnectionStore,
private _prompter: IPrompter,
private _vscodeWrapper?: VscodeWrapper) {
this._errorOutputChannel = vscode.window.createOutputChannel(Constants.connectionErrorChannelName);
this._errorOutputChannel = vscode.window.createOutputChannel(LocalizedConstants.connectionErrorChannelName);
if (!this.vscodeWrapper) {
this.vscodeWrapper = new VscodeWrapper();
}
@ -74,7 +75,7 @@ export class ConnectionUI {
} else {
// We have recent connections - show them in a picklist
self.promptItemChoice({
placeHolder: Constants.recentConnectionsPlaceholder,
placeHolder: LocalizedConstants.recentConnectionsPlaceholder,
matchOnDescription: true
}, picklist)
.then(selection => {
@ -133,8 +134,8 @@ export class ConnectionUI {
return new Promise<boolean>((resolve, reject) => {
let question: IQuestion = {
type: QuestionTypes.confirm,
name: Constants.msgPromptCancelConnect,
message: Constants.msgPromptCancelConnect
name: LocalizedConstants.msgPromptCancelConnect,
message: LocalizedConstants.msgPromptCancelConnect
};
self._prompter.promptSingle(question).then(result => {
resolve(result ? true : false);
@ -153,8 +154,8 @@ export class ConnectionUI {
return new Promise<boolean>((resolve, reject) => {
let question: IQuestion = {
type: QuestionTypes.confirm,
name: Constants.msgChangeLanguageMode,
message: Constants.msgChangeLanguageMode
name: LocalizedConstants.msgChangeLanguageMode,
message: LocalizedConstants.msgChangeLanguageMode
};
self._prompter.promptSingle(question).then( value => {
if (value) {
@ -195,7 +196,7 @@ export class ConnectionUI {
});
const pickListOptions: vscode.QuickPickOptions = {
placeHolder: Constants.msgChooseDatabasePlaceholder
placeHolder: LocalizedConstants.msgChooseDatabasePlaceholder
};
// show database picklist, and modify the current connection to switch the active database
@ -239,8 +240,8 @@ export class ConnectionUI {
return new Promise<boolean>((resolve, reject) => {
let question: IQuestion = {
type: QuestionTypes.confirm,
name: Constants.msgPromptClearRecentConnections,
message: Constants.msgPromptClearRecentConnections
name: LocalizedConstants.msgPromptClearRecentConnections,
message: LocalizedConstants.msgPromptClearRecentConnections
};
self._prompter.promptSingle(question).then(result => {
resolve(result ? true : false);
@ -255,16 +256,16 @@ export class ConnectionUI {
return new Promise<boolean>((resolve, reject) => {
// Create profile, clear recent connections, edit profiles, or remove profile?
let choices: INameValueChoice[] = [
{ name: Constants.CreateProfileLabel, value: ManageProfileTask.Create },
{ name: Constants.ClearRecentlyUsedLabel, value: ManageProfileTask.ClearRecentlyUsed},
{ name: Constants.EditProfilesLabel, value: ManageProfileTask.Edit},
{ name: Constants.RemoveProfileLabel, value: ManageProfileTask.Remove}
{ name: LocalizedConstants.CreateProfileLabel, value: ManageProfileTask.Create },
{ name: LocalizedConstants.ClearRecentlyUsedLabel, value: ManageProfileTask.ClearRecentlyUsed},
{ name: LocalizedConstants.EditProfilesLabel, value: ManageProfileTask.Edit},
{ name: LocalizedConstants.RemoveProfileLabel, value: ManageProfileTask.Remove}
];
let question: IQuestion = {
type: QuestionTypes.expand,
name: Constants.ManageProfilesPrompt,
message: Constants.ManageProfilesPrompt,
name: LocalizedConstants.ManageProfilesPrompt,
message: LocalizedConstants.ManageProfilesPrompt,
choices: choices,
onAnswered: (value) => {
switch (value) {
@ -277,7 +278,7 @@ export class ConnectionUI {
self.promptToClearRecentConnectionsList().then(result => {
if (result) {
self.connectionManager.clearRecentConnectionsList().then(() => {
self.vscodeWrapper.showInformationMessage(Constants.msgClearedRecentConnections);
self.vscodeWrapper.showInformationMessage(LocalizedConstants.msgClearedRecentConnections);
resolve(true);
});
} else {
@ -328,9 +329,9 @@ export class ConnectionUI {
}).then(savedProfile => {
if (savedProfile) {
if (validate) {
self.vscodeWrapper.showInformationMessage(Constants.msgProfileCreatedAndConnected);
self.vscodeWrapper.showInformationMessage(LocalizedConstants.msgProfileCreatedAndConnected);
} else {
self.vscodeWrapper.showInformationMessage(Constants.msgProfileCreated);
self.vscodeWrapper.showInformationMessage(LocalizedConstants.msgProfileCreated);
}
}
return savedProfile;
@ -372,8 +373,8 @@ export class ConnectionUI {
private promptForRetryCreateProfile(profile: IConnectionProfile): PromiseLike<IConnectionProfile> {
// Ask if the user would like to fix the profile
return this._vscodeWrapper.showErrorMessage(Constants.msgPromptRetryCreateProfile, Constants.retryLabel).then(result => {
if (result === Constants.retryLabel) {
return this._vscodeWrapper.showErrorMessage(LocalizedConstants.msgPromptRetryCreateProfile, LocalizedConstants.retryLabel).then(result => {
if (result === LocalizedConstants.retryLabel) {
return ConnectionProfile.createProfile(this._prompter, profile);
} else {
return undefined;
@ -410,7 +411,7 @@ export class ConnectionUI {
}).then(result => {
if (result) {
// TODO again consider moving information prompts to the prompt package
vscode.window.showInformationMessage(Constants.msgProfileRemoved);
vscode.window.showInformationMessage(LocalizedConstants.msgProfileRemoved);
}
return result;
});
@ -421,7 +422,7 @@ export class ConnectionUI {
if (!profiles || profiles.length === 0) {
// Inform the user we have no profiles available for deletion
// TODO: consider moving to prompter if we separate all UI logic from workflows in the future
vscode.window.showErrorMessage(Constants.msgNoProfilesSaved);
vscode.window.showErrorMessage(LocalizedConstants.msgNoProfilesSaved);
return Promise.resolve(undefined);
}
@ -432,7 +433,7 @@ export class ConnectionUI {
// 1: what profile should we remove?
type: QuestionTypes.expand,
name: chooseProfile,
message: Constants.msgSelectProfileToRemove,
message: LocalizedConstants.msgSelectProfileToRemove,
matchOptions: { matchOnDescription: true },
choices: profiles
},
@ -440,7 +441,7 @@ export class ConnectionUI {
// 2: Confirm removal before proceeding
type: QuestionTypes.confirm,
name: confirm,
message: Constants.confirmRemoveProfilePrompt
message: LocalizedConstants.confirmRemoveProfilePrompt
}
];

Просмотреть файл

@ -1,5 +1,6 @@
import vscode = require('vscode');
import Constants = require('../models/constants');
import Constants = require('../constants/constants');
import LocalizedConstants = require('../constants/localizedConstants');
import ConnInfo = require('../models/connectionInfo');
import * as ConnectionContracts from '../models/contracts/connection';
import Interfaces = require('../models/interfaces');
@ -95,8 +96,8 @@ export default class StatusView implements vscode.Disposable {
public notConnected(fileUri: string): void {
let bar = this.getStatusBar(fileUri);
bar.statusConnection.text = Constants.notConnectedLabel;
bar.statusConnection.tooltip = Constants.notConnectedTooltip;
bar.statusConnection.text = LocalizedConstants.notConnectedLabel;
bar.statusConnection.tooltip = LocalizedConstants.notConnectedTooltip;
bar.statusConnection.command = Constants.cmdConnect;
this.showStatusBarItem(fileUri, bar.statusConnection);
bar.statusLanguageService.text = '';
@ -106,9 +107,9 @@ export default class StatusView implements vscode.Disposable {
public connecting(fileUri: string, connCreds: Interfaces.IConnectionCredentials): void {
let bar = this.getStatusBar(fileUri);
bar.statusConnection.command = Constants.cmdDisconnect;
bar.statusConnection.tooltip = Constants.connectingTooltip + ConnInfo.getTooltip(connCreds);
bar.statusConnection.tooltip = LocalizedConstants.connectingTooltip + ConnInfo.getTooltip(connCreds);
this.showStatusBarItem(fileUri, bar.statusConnection);
this.showProgress(fileUri, Constants.connectingLabel, bar.statusConnection);
this.showProgress(fileUri, LocalizedConstants.connectingLabel, bar.statusConnection);
}
public connectSuccess(fileUri: string, connCreds: Interfaces.IConnectionCredentials, serverInfo: ConnectionContracts.ServerInfo): void {
@ -122,14 +123,14 @@ export default class StatusView implements vscode.Disposable {
public connectError(fileUri: string, credentials: Interfaces.IConnectionCredentials, error: ConnectionContracts.ConnectionCompleteParams): void {
let bar = this.getStatusBar(fileUri);
bar.statusConnection.command = Constants.cmdConnect;
bar.statusConnection.text = Constants.connectErrorLabel;
bar.statusConnection.text = LocalizedConstants.connectErrorLabel;
if (error.errorNumber && error.errorMessage && !Utils.isEmpty(error.errorMessage)) {
bar.statusConnection.tooltip = Constants.connectErrorTooltip + credentials.server + '\n' +
Constants.connectErrorCode + error.errorNumber + '\n' +
Constants.connectErrorMessage + error.errorMessage;
bar.statusConnection.tooltip = LocalizedConstants.connectErrorTooltip + credentials.server + '\n' +
LocalizedConstants.connectErrorCode + error.errorNumber + '\n' +
LocalizedConstants.connectErrorMessage + error.errorMessage;
} else {
bar.statusConnection.tooltip = Constants.connectErrorTooltip + credentials.server + '\n' +
Constants.connectErrorMessage + error.messages;
bar.statusConnection.tooltip = LocalizedConstants.connectErrorTooltip + credentials.server + '\n' +
LocalizedConstants.connectErrorMessage + error.messages;
}
this.showStatusBarItem(fileUri, bar.statusConnection);
}
@ -137,9 +138,9 @@ export default class StatusView implements vscode.Disposable {
public executingQuery(fileUri: string): void {
let bar = this.getStatusBar(fileUri);
bar.statusQuery.command = undefined;
bar.statusQuery.tooltip = Constants.executeQueryLabel;
bar.statusQuery.tooltip = LocalizedConstants.executeQueryLabel;
this.showStatusBarItem(fileUri, bar.statusQuery);
this.showProgress(fileUri, Constants.executeQueryLabel, bar.statusQuery);
this.showProgress(fileUri, LocalizedConstants.executeQueryLabel, bar.statusQuery);
}
public executedQuery(fileUri: string): void {
@ -152,9 +153,9 @@ export default class StatusView implements vscode.Disposable {
bar.statusQuery.hide();
bar.statusQuery.command = undefined;
bar.statusQuery.tooltip = Constants.cancelingQueryLabel;
bar.statusQuery.tooltip = LocalizedConstants.cancelingQueryLabel;
this.showStatusBarItem(fileUri, bar.statusQuery);
this.showProgress(fileUri, Constants.cancelingQueryLabel, bar.statusQuery);
this.showProgress(fileUri, LocalizedConstants.cancelingQueryLabel, bar.statusQuery);
}
public languageServiceStatusChanged(fileUri: string, status: string): void {
@ -172,20 +173,20 @@ export default class StatusView implements vscode.Disposable {
getCurrentStatus: () => string,
updateMessage: (message: string) => void): void {
switch (newStatus) {
case Constants.definitionRequestedStatus:
case LocalizedConstants.definitionRequestedStatus:
setTimeout(() => {
if (getCurrentStatus() !== Constants.definitionRequestCompletedStatus) {
updateMessage(Constants.gettingDefinitionMessage);
if (getCurrentStatus() !== LocalizedConstants.definitionRequestCompletedStatus) {
updateMessage(LocalizedConstants.gettingDefinitionMessage);
}
}, 500);
break;
case Constants.definitionRequestCompletedStatus:
case LocalizedConstants.definitionRequestCompletedStatus:
updateMessage('');
break;
case Constants.updatingIntelliSenseStatus:
updateMessage(Constants.updatingIntelliSenseLabel);
case LocalizedConstants.updatingIntelliSenseStatus:
updateMessage(LocalizedConstants.updatingIntelliSenseLabel);
break;
case Constants.intelliSenseUpdatedStatus:
case LocalizedConstants.intelliSenseUpdatedStatus:
updateMessage('');
break;
default:

Просмотреть файл

@ -4,13 +4,15 @@ var projectRoot = path.resolve(path.dirname(__dirname));
var srcRoot = path.resolve(projectRoot, 'src');
var viewsRoot = path.resolve(srcRoot, 'views');
var htmlcontentRoot = path.resolve(viewsRoot, 'htmlcontent');
var outRoot = path.resolve(projectRoot, 'out')
var htmloutroot = path.resolve(outRoot, 'src/views/htmlcontent')
var outRoot = path.resolve(projectRoot, 'out');
var htmloutroot = path.resolve(outRoot, 'src/views/htmlcontent');
var localization = path.resolve(projectRoot, 'localization');
var config = {
paths: {
project: {
root: projectRoot
root: projectRoot,
localization: localization
},
extension: {
root: srcRoot

124
tasks/localizationtasks.js Normal file
Просмотреть файл

@ -0,0 +1,124 @@
let builder = require('xmlbuilder')
var dom = require('xmldom').DOMParser
var gulp = require('gulp')
var config = require('./config')
var through = require('through2')
var path = require('path')
// converts a json object into xml
function convertDictionaryToXml(dict) {
//TODO: for reverse file sync (if ever needed)
}
// converts a json object into a plain text json
function convertDictionaryToJson(dict) {
return JSON.stringify(dict, null, '\t') + '\n';
}
// converts an xml file into a json object
function convertXmlToDictionary(xmlInput) {
let xmlDom = new dom().parseFromString(xmlInput);
let transUnits = xmlDom.getElementsByTagName('trans-unit');
let dict = {};
for (var i = 0; i < transUnits.length; ++i) {
let unit = transUnits[i];
// Extract ID attribute
let id = unit.getAttribute('id');
// Extract source element if possible
let sourceElement = unit.getElementsByTagName('source');
let source = '';
if (sourceElement.length === 1) {
source = escapeChars(sourceElement[0].textContent);
}
// Extract target element if possible
let targetElement = unit.getElementsByTagName('target');
let target = '';
if(targetElement.length === 1){
target = escapeChars(targetElement[0].textContent);
}
// Return json with {id:{target,source}} format
dict[id] = {'source': source, 'target': target};
}
return dict;
}
// Escapes all characters which need to be escaped (')
function escapeChars(input) {
return input.replace(/'/g, "\\'");
}
// converts plain text json into a json object
function convertJsonToDictionary(jsonInput) {
return JSON.parse(jsonInput);
}
// export json files from *.xlf
// mirrors the file paths and names
gulp.task('ext:localization:xliff-to-json', function () {
return gulp.src([config.paths.project.localization + '/xliff/**/*.xlf', '!' + config.paths.project.localization + '/xliff/enu/**/*.xlf'])
.pipe(through.obj(function (file, enc, callback) {
// convert cliff into json document
let dict = convertXmlToDictionary(String(file.contents));
Object.keys(dict).map(function(key, index) {
dict[key] = dict[key]['target']
});
file.contents = new Buffer(convertDictionaryToJson(dict));
// modify file extensions to follow proper convention
file.basename = file.basename.substr(0, file.basename.indexOf('.')) + '.i18n.json';
// callback to notify we have completed the current file
callback(null, file);
}))
.pipe(gulp.dest(config.paths.project.localization + '/i18n/'));
});
// Generates a localized constants file from the en xliff file
gulp.task('ext:localization:xliff-to-ts', function () {
return gulp.src([config.paths.project.localization + '/xliff/enu/constants/localizedConstants.enu.xlf'])
.pipe(through.obj(function (file, enc, callback) {
// convert xliff into json document
let dict = convertXmlToDictionary(String(file.contents));
var contents = ['/* tslint:disable */',
'// THIS IS A COMPUTER GENERATED FILE. CHANGES IN THIS FILE WILL BE OVERWRITTEN.',
'// TO ADD LOCALIZED CONSTANTS, ADD YOUR CONSTANT TO THE ENU XLIFF FILE UNDER ~/localization/xliff/enu/constants/localizedConstants.enu.xlf AND REBUILD THE PROJECT',
'import * as nls from \'vscode-nls\';'];
for (var key in dict) {
if (dict.hasOwnProperty(key)) {
let instantiation = 'export let ' + key + ' = \'' + dict[key]['source'] + '\';';
contents.push(instantiation);
}
}
// add headers to export localization function
contents.push('export let loadLocalizedConstants = (locale: string) => {');
contents.push('\tlet localize = nls.config({ locale: locale })();');
// Re-export each constant
for (var key in dict) {
if (dict.hasOwnProperty(key)) {
let instantiation = '\t' + key + ' = localize(\'' + key + '\', \'' + dict[key]['source'] + '\');';
contents.push(instantiation);
}
}
// end the function
contents.push('};');
// Join with new lines in between
let fullFileContents = contents.join('\r\n') + '\r\n';
file.contents = new Buffer(fullFileContents);
// Name our file
file.basename = 'localizedConstants.ts';
// callback to notify we have completed the current file
callback(null, file);
}))
.pipe(gulp.dest(config.paths.project.root + '/src/constants/'));
});

Просмотреть файл

@ -3,7 +3,8 @@ import * as TypeMoq from 'typemoq';
import vscode = require('vscode');
import * as utils from '../src/models/utils';
import * as Constants from '../src/models/constants';
import * as Constants from '../src/constants/constants';
import LocalizedConstants = require('../src/constants/localizedConstants');
import * as stubs from './stubs';
import * as interfaces from '../src/models/interfaces';
import { CredentialStore } from '../src/credentialstore/credentialstore';
@ -150,9 +151,9 @@ suite('ConnectionCredentials Tests', () => {
connectionStore.setup(x => x.removeProfile(TypeMoq.It.isAny())).returns((profile1: IConnectionProfile) => (Promise.resolve(true)));
connectionStore.setup(x => x.saveProfile(TypeMoq.It.isAny())).returns((profile1: IConnectionProfile) => (Promise.resolve(profile1)));
prompter.setup(x => x.prompt(TypeMoq.It.isAny())).callback(questions => {
passwordQuestion = questions.filter(question => question.name === Constants.passwordPrompt);
answers[Constants.passwordPrompt] = 'newPassword';
passwordQuestion[0].onAnswered(answers[Constants.passwordPrompt]);
passwordQuestion = questions.filter(question => question.name === LocalizedConstants.passwordPrompt);
answers[LocalizedConstants.passwordPrompt] = 'newPassword';
passwordQuestion[0].onAnswered(answers[LocalizedConstants.passwordPrompt]);
})
.returns((questions: IQuestion[]) => Promise.resolve(answers));
@ -167,7 +168,7 @@ suite('ConnectionCredentials Tests', () => {
assert.ok(success);
// Checking to see password question was prompted
assert.ok(passwordQuestion);
assert.equal(success.password, answers[Constants.passwordPrompt]);
assert.equal(success.password, answers[LocalizedConstants.passwordPrompt]);
connectionStore.verify(x => x.removeProfile(TypeMoq.It.isAny()), TypeMoq.Times.once());
connectionStore.verify(x => x.saveProfile(TypeMoq.It.isAny()), TypeMoq.Times.once());
done();

Просмотреть файл

@ -10,7 +10,7 @@ import { ConnectionStore } from '../src/models/connectionStore';
import ConnectionManager from '../src/controllers/connectionManager';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import Constants = require('../src/models/constants');
import LocalizedConstants = require('../src/constants/localizedConstants');
import assert = require('assert');
import os = require('os');
@ -77,13 +77,13 @@ suite('Connection Profile tests', () => {
// Then expect the following flow:
let questionNames: string[] = [
Constants.serverPrompt, // Server
Constants.databasePrompt, // DB Name
Constants.authTypePrompt, // Authentication Type
Constants.usernamePrompt, // UserName
Constants.passwordPrompt, // Password
Constants.msgSavePassword, // Save Password
Constants.profileNamePrompt // Profile Name
LocalizedConstants.serverPrompt, // Server
LocalizedConstants.databasePrompt, // DB Name
LocalizedConstants.authTypePrompt, // Authentication Type
LocalizedConstants.usernamePrompt, // UserName
LocalizedConstants.passwordPrompt, // Password
LocalizedConstants.msgSavePassword, // Save Password
LocalizedConstants.profileNamePrompt // Profile Name
];
assert.strictEqual(profileQuestions.length, questionNames.length, 'unexpected number of questions');
@ -119,7 +119,7 @@ suite('Connection Profile tests', () => {
// Then expect SqlAuth to be the only default type
let authChoices = <INameValueChoice[]>profileQuestions[authTypeQuestionIndex].choices;
assert.strictEqual(authChoices[0].name, Constants.authTypeSql);
assert.strictEqual(authChoices[0].name, LocalizedConstants.authTypeSql);
done();
});
@ -151,7 +151,7 @@ suite('Connection Profile tests', () => {
let authChoices = <INameValueChoice[]>authQuestion.choices;
if ('win32' === os.platform()) {
assert.strictEqual(authChoices.length, 2);
assert.strictEqual(authChoices[1].name, Constants.authTypeIntegrated);
assert.strictEqual(authChoices[1].name, LocalizedConstants.authTypeIntegrated);
assert.strictEqual(authChoices[1].value, AuthenticationTypes[AuthenticationTypes.Integrated]);
// And on a platform with multiple choices, should prompt for input
@ -220,11 +220,11 @@ suite('Connection Profile tests', () => {
prompter.setup(x => x.prompt(TypeMoq.It.isAny()))
.returns(questions => {
let answers: {[key: string]: string} = {};
answers[Constants.serverPrompt] = 'my-server';
answers[Constants.databasePrompt] = 'my_db';
answers[Constants.usernamePrompt] = 'sa';
answers[Constants.passwordPrompt] = '12345678';
answers[Constants.authTypePrompt] = AuthenticationTypes[AuthenticationTypes.SqlLogin];
answers[LocalizedConstants.serverPrompt] = 'my-server';
answers[LocalizedConstants.databasePrompt] = 'my_db';
answers[LocalizedConstants.usernamePrompt] = 'sa';
answers[LocalizedConstants.passwordPrompt] = '12345678';
answers[LocalizedConstants.authTypePrompt] = AuthenticationTypes[AuthenticationTypes.SqlLogin];
for (let key in answers) {
if (answers.hasOwnProperty(key)) {
questions.map(q => { if (q.name === key) { q.onAnswered(answers[key]); } });
@ -263,11 +263,11 @@ suite('Connection Profile tests', () => {
prompter.setup(x => x.prompt(TypeMoq.It.isAny()))
.returns(questions => {
let answers: {[key: string]: string} = {};
answers[Constants.serverPrompt] = 'my-server';
answers[Constants.databasePrompt] = 'my_db';
answers[Constants.usernamePrompt] = 'sa';
answers[Constants.passwordPrompt] = '12345678';
answers[Constants.authTypePrompt] = AuthenticationTypes[AuthenticationTypes.SqlLogin];
answers[LocalizedConstants.serverPrompt] = 'my-server';
answers[LocalizedConstants.databasePrompt] = 'my_db';
answers[LocalizedConstants.usernamePrompt] = 'sa';
answers[LocalizedConstants.passwordPrompt] = '12345678';
answers[LocalizedConstants.authTypePrompt] = AuthenticationTypes[AuthenticationTypes.SqlLogin];
for (let key in answers) {
if (answers.hasOwnProperty(key)) {
questions.map(q => { if (q.name === key) { q.onAnswered(answers[key]); } });

Просмотреть файл

@ -5,7 +5,7 @@ import vscode = require('vscode');
import fs = require('fs');
import * as utils from '../src/models/utils';
import * as connectionInfo from '../src/models/connectionInfo';
import * as Constants from '../src/models/constants';
import * as Constants from '../src/constants/constants';
import * as stubs from './stubs';
import * as interfaces from '../src/models/interfaces';
import { CredentialStore } from '../src/credentialstore/credentialstore';

Просмотреть файл

@ -2,7 +2,7 @@ import assert = require('assert');
import * as TypeMoq from 'typemoq';
import {IConfig} from '../src/languageservice/interfaces';
import { WorkspaceConfiguration, workspace } from 'vscode';
import * as Constants from '../src/models/constants';
import * as Constants from '../src/constants/constants';
import ExtConfig from '../src/configurations/extConfig';
import Config from '../src/configurations/config';

24
test/localization.test.ts Normal file
Просмотреть файл

@ -0,0 +1,24 @@
'use strict';
import * as LocalizedConstants from '../src/constants/localizedConstants';
import assert = require('assert');
suite('Localization Tests', () => {
test('Default Localization Test' , done => {
assert.equal(LocalizedConstants.testLocalizationConstant, 'test_en');
done();
});
test('EN Localization Test' , done => {
LocalizedConstants.loadLocalizedConstants('en');
assert.equal(LocalizedConstants.testLocalizationConstant, 'test_en');
done();
});
test('ES Localization Test' , done => {
LocalizedConstants.loadLocalizedConstants('es');
assert.equal(LocalizedConstants.testLocalizationConstant, 'test_es');
done();
});
});

Просмотреть файл

@ -6,7 +6,8 @@ import MainController from '../src/controllers/mainController';
import ConnectionManager from '../src/controllers/connectionManager';
import UntitledSqlDocumentService from '../src/controllers/untitledSqlDocumentService';
import * as Extension from '../src/extension';
import Constants = require('../src/models/constants');
import Constants = require('../src/constants/constants');
import LocalizedConstants = require('../src/constants/localizedConstants');
import assert = require('assert');
suite('MainController Tests', () => {
@ -110,7 +111,7 @@ suite('MainController Tests', () => {
// Saved Untitled file event test
test('onDidCloseTextDocument should call untitledDoc function when an untitled file is saved' , done => {
// Scheme of older doc must be untitled
document.uri.scheme = Constants.untitledScheme;
document.uri.scheme = LocalizedConstants.untitledScheme;
// A save untitled doc constitutes an saveDoc event directly followed by a closeDoc event
mainController.onDidSaveTextDocument(newDocument);

Просмотреть файл

@ -17,7 +17,7 @@ import Telemetry from '../src/models/telemetry';
import * as Utils from '../src/models/utils';
import { TestExtensionContext, TestPrompter } from './stubs';
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import Constants = require('../src/models/constants');
import LocalizedConstants = require('../src/constants/localizedConstants');
function createTestConnectionResult(ownerUri?: string): ConnectionContracts.ConnectionCompleteParams {
let result = new ConnectionContracts.ConnectionCompleteParams();
@ -516,15 +516,15 @@ suite('Per File Connection Tests', () => {
// Connect
manager.connect(testFile, createTestCredentials()).then(result => {
assert.equal(result, true);
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), Constants.updatingIntelliSenseStatus), TypeMoq.Times.once());
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), Constants.intelliSenseUpdatedStatus), TypeMoq.Times.never());
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), LocalizedConstants.updatingIntelliSenseStatus), TypeMoq.Times.once());
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), LocalizedConstants.intelliSenseUpdatedStatus), TypeMoq.Times.never());
// Send a mock notification that the language service was updated
let langResult = new LanguageServiceContracts.IntelliSenseReadyParams();
langResult.ownerUri = testFile;
manager.handleLanguageServiceUpdateNotification().call(manager, langResult);
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), Constants.intelliSenseUpdatedStatus), TypeMoq.Times.once());
statusViewMock.verify(x => x.languageServiceStatusChanged(TypeMoq.It.isAny(), LocalizedConstants.intelliSenseUpdatedStatus), TypeMoq.Times.once());
done();
}).catch(err => {

Просмотреть файл

@ -14,7 +14,7 @@ import {
} from './../src/models/contracts/queryExecute';
import VscodeWrapper from './../src/controllers/vscodeWrapper';
import StatusView from './../src/views/statusView';
import * as Constants from '../src/models/constants';
import * as Constants from '../src/constants/constants';
import * as QueryExecuteContracts from '../src/models/contracts/queryExecute';
import {
ISlickRange,

Просмотреть файл

@ -1,6 +1,6 @@
import * as TypeMoq from 'typemoq';
import assert = require('assert');
import Constants = require('../src/models/constants');
import LocalizedConstants = require('../src/constants/localizedConstants');
import Interfaces = require('../src/models/interfaces');
import ResultsSerializer from './../src/models/resultsSerializer';
import { SaveResultsAsCsvRequestParams } from './../src/models/contracts';
@ -35,7 +35,7 @@ suite('save results tests', () => {
let filePathQuestions: IQuestion[];
let answers = {};
answers[Constants.filepathPrompt] = filePath;
answers[LocalizedConstants.filepathPrompt] = filePath;
// setup mock filepath prompt
prompter.setup(x => x.prompt(TypeMoq.It.isAny())).callback(questions => {
@ -57,7 +57,7 @@ suite('save results tests', () => {
let saveResults = new ResultsSerializer(serverClient.object, prompter.object, vscodeWrapper.object);
saveResults.onSaveResults(testFile, 0, 0, 'csv', undefined).then( () => {
assert.equal(filePathQuestions[0].name, Constants.filepathPrompt );
assert.equal(filePathQuestions[0].name, LocalizedConstants.filepathPrompt );
});
});
@ -66,8 +66,8 @@ suite('save results tests', () => {
let filePathQuestions: IQuestion[];
let answers = {};
answers[Constants.filepathPrompt] = filePath;
answers[Constants.overwritePrompt] = true;
answers[LocalizedConstants.filepathPrompt] = filePath;
answers[LocalizedConstants.overwritePrompt] = true;
// setup mock filepath prompt
prompter.setup(x => x.prompt(TypeMoq.It.isAny())).callback(questions => {
@ -90,7 +90,7 @@ suite('save results tests', () => {
let saveResults = new ResultsSerializer(serverClient.object, prompter.object, vscodeWrapper.object);
saveResults.onSaveResults(testFile, 0, 0, 'csv', undefined).then( () => {
assert.equal(filePathQuestions[0].name, Constants.filepathPrompt );
assert.equal(filePathQuestions[0].name, LocalizedConstants.filepathPrompt );
});
});

Просмотреть файл

@ -4,7 +4,7 @@ import { SqlOutputContentProvider } from '../src/models/SqlOutputContentProvider
import VscodeWrapper from '../src/controllers/vscodeWrapper';
import StatusView from '../src/views/statusView';
import * as stubs from './stubs';
import Constants = require('../src/models/constants');
import Constants = require('../src/constants/constants');
import vscode = require('vscode');
import * as TypeMoq from 'typemoq';
import assert = require('assert');

Просмотреть файл

@ -1,7 +1,7 @@
import assert = require('assert');
import StatusView from '../src/views/statusView';
import Constants = require('../src/models/constants');
import LocalizedConstants = require('../src/constants/localizedConstants');
import Telemetry from '../src/models/telemetry';
suite('Status View Tests', () => {
@ -13,13 +13,13 @@ suite('Status View Tests', () => {
test('updateStatusMessage should not immediately update status message for definition request', (done) => {
return new Promise((resolve, reject) => {
let statusView = new StatusView();
let newStatus = Constants.definitionRequestedStatus;
let newStatus = LocalizedConstants.definitionRequestedStatus;
let currentStatus = '';
let getCurrentStatus = () => {
return currentStatus;
};
let actualStatusMessage = '';
let expectedStatusMessage = Constants.gettingDefinitionMessage;
let expectedStatusMessage = LocalizedConstants.gettingDefinitionMessage;
let updateMessage = (message) => {
actualStatusMessage = message;
};
@ -35,8 +35,8 @@ suite('Status View Tests', () => {
test('updateStatusMessage should not update status message for definition request if already completed', (done) => {
return new Promise((resolve, reject) => {
let statusView = new StatusView();
let newStatus = Constants.definitionRequestedStatus;
let currentStatus = Constants.definitionRequestCompletedStatus;
let newStatus = LocalizedConstants.definitionRequestedStatus;
let currentStatus = LocalizedConstants.definitionRequestCompletedStatus;
let getCurrentStatus = () => {
return currentStatus;
};
@ -57,8 +57,8 @@ suite('Status View Tests', () => {
test('updateStatusMessage should update status message for definition request completed', (done) => {
return new Promise((resolve, reject) => {
let statusView = new StatusView();
let newStatus = Constants.definitionRequestCompletedStatus;
let currentStatus = Constants.definitionRequestCompletedStatus;
let newStatus = LocalizedConstants.definitionRequestCompletedStatus;
let currentStatus = LocalizedConstants.definitionRequestCompletedStatus;
let getCurrentStatus = () => {
return currentStatus;
};
@ -76,13 +76,13 @@ suite('Status View Tests', () => {
test('updateStatusMessage should update status message for updating intelliSense', (done) => {
return new Promise((resolve, reject) => {
let statusView = new StatusView();
let newStatus = Constants.updatingIntelliSenseStatus;
let newStatus = LocalizedConstants.updatingIntelliSenseStatus;
let currentStatus = '';
let getCurrentStatus = () => {
return currentStatus;
};
let actualStatusMessage = '';
let expectedStatusMessage = Constants.updatingIntelliSenseLabel;
let expectedStatusMessage = LocalizedConstants.updatingIntelliSenseLabel;
let updateMessage = (message) => {
actualStatusMessage = message;
};
@ -95,7 +95,7 @@ suite('Status View Tests', () => {
test('updateStatusMessage should update status message for intelliSense updated status', (done) => {
return new Promise((resolve, reject) => {
let statusView = new StatusView();
let newStatus = Constants.intelliSenseUpdatedStatus;
let newStatus = LocalizedConstants.intelliSenseUpdatedStatus;
let currentStatus = '';
let getCurrentStatus = () => {
return currentStatus;