Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3afb365
create l10n-extract script
beyackle Aug 7, 2020
7723743
Merge branch 'main' into beyackle/l10nExtract
beyackle Aug 10, 2020
61c31c3
Merge branch 'main' into beyackle/l10nExtract
beyackle Aug 11, 2020
8aeab8e
Update l10n-extract.js
beyackle Aug 11, 2020
ab0184b
clean up code and move files into own directory
beyackle Aug 11, 2020
0c76d05
rename files
beyackle Aug 11, 2020
d31826d
Update l10n-extract.js
beyackle Aug 11, 2020
4c36195
refactor utils and fix small bug
beyackle Aug 11, 2020
28ecea9
add pseudol10n for client locales file
beyackle Aug 11, 2020
e253dca
add pseudolocalization
beyackle Aug 11, 2020
c4a1545
Update index.tsx
beyackle Aug 11, 2020
22508e8
Update botProject.ts
beyackle Aug 11, 2020
2026e6f
transform other files
beyackle Aug 12, 2020
4d8d896
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 12, 2020
0b87518
move locales into src
beyackle Aug 12, 2020
4cf3b99
unify .json files
beyackle Aug 12, 2020
f6d96a5
move format-message and other fixes
beyackle Aug 13, 2020
77cfaf8
merge in settings dropdown
beyackle Aug 14, 2020
33b32df
almost-working locale serverside locale swap
beyackle Aug 14, 2020
17d71c5
Update App.tsx
beyackle Aug 17, 2020
438f78d
fix server silliness
beyackle Aug 17, 2020
dc0c4d5
move locale-loading to dispatcher
beyackle Aug 17, 2020
d9a903c
Update user.ts
beyackle Aug 17, 2020
1a5a6f1
fix scripts
beyackle Aug 17, 2020
25caeb5
remove stray files
beyackle Aug 17, 2020
b1c707b
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 18, 2020
6a32635
make serverside schemas mostly work
beyackle Aug 18, 2020
d775483
Update dialogUtil.ts
beyackle Aug 24, 2020
da2a5a0
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 24, 2020
a4e3baa
use override files
beyackle Aug 24, 2020
22d0e84
WIP on schema override reading
beyackle Aug 25, 2020
03641e0
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 25, 2020
f6ec874
fix filename typo
beyackle Aug 25, 2020
198d943
Update botProject.ts
beyackle Aug 25, 2020
7cecdd5
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 26, 2020
87a83ee
move loadLocale out and use for init
beyackle Aug 26, 2020
b8084af
fix l10n script
beyackle Aug 26, 2020
b6635b0
fix typo
beyackle Aug 26, 2020
912503b
delay concept labels
beyackle Aug 26, 2020
77f39fb
Update viewUtils.ts
beyackle Aug 26, 2020
60311e2
Update package.json
beyackle Aug 26, 2020
ef20115
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 27, 2020
ba09759
update tests (still WIP)
beyackle Aug 27, 2020
8cc8a08
Update fileUtil.test.js
beyackle Aug 27, 2020
585db80
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 27, 2020
18c675b
fix loadLocale tests
beyackle Aug 27, 2020
8be44c3
Merge branch 'beyackle/l10n-mock' of https://github.com/microsoft/Bot…
beyackle Aug 27, 2020
0f46ff5
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 27, 2020
3928d6c
Update .gitignore
beyackle Aug 27, 2020
915da8b
Merge branch 'beyackle/l10n-mock' of https://github.com/microsoft/Bot…
beyackle Aug 27, 2020
93b8278
remove pseudo files
beyackle Aug 27, 2020
8722606
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 28, 2020
8d13d2a
fix design of settings
beyackle Aug 28, 2020
ac11d43
Update AppSettings.tsx
beyackle Aug 31, 2020
704242c
Update en-US.json
beyackle Aug 31, 2020
28b57cb
Merge branch 'main' into beyackle/l10n-mock
beyackle Aug 31, 2020
c76dea1
fix CR issues and move schema files
beyackle Sep 1, 2020
5399ef6
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 4, 2020
3b54ba7
add l10n to build scripts
beyackle Sep 4, 2020
2950b5c
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 4, 2020
06543d8
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 8, 2020
4761f14
Update botProject.ts
beyackle Sep 8, 2020
9a0ce8a
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 8, 2020
6a07f73
resolve node-forge to 0.10 for security thing
beyackle Sep 8, 2020
c8cc64c
Merge branch 'beyackle/l10n-mock' of https://github.com/microsoft/Bot…
beyackle Sep 8, 2020
b46deea
Update LuisDeploy.spec.ts
beyackle Sep 8, 2020
9248939
fixes from CR
beyackle Sep 8, 2020
312bafa
Update botProject.ts
beyackle Sep 9, 2020
5c72cf4
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 9, 2020
7433856
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 9, 2020
6e2731d
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 10, 2020
1d174da
rebuild files
beyackle Sep 10, 2020
90519d7
Merge branch 'main' into beyackle/l10n-mock
beyackle Sep 11, 2020
68e45ca
post-merge fixes
beyackle Sep 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Composer/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ cypress/results
cypress/videos

TestBots/

l10ntemp/

packages/server/schemas/*.schema
packages/server/schemas/*.uischema
!packages/server/schemas/sdk.schema
!packages/server/schemas/sdk.uischema
2 changes: 1 addition & 1 deletion Composer/cypress/integration/LuisDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ context('Luis Deploy', () => {
status: 200,
response: 'fixture:luPublish/success',
});
cy.findByText('Start Bot').click();
cy.findByText(/^(Start|Restart) Bot$/).click();

// clear its settings before
cy.enterTextAndSubmit('ProjectNameInput', 'MyProject');
Expand Down
13 changes: 10 additions & 3 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"set-value": "^3.0.2",
"kind-of": "^6.0.3",
"elliptic": "^6.5.3",
"bl": "^2.2.1"
"@babel/parser": "^7.11.3",
"bl": "^2.2.1",
"node-forge": "^0.10.0"
},
"engines": {
"node": ">=12"
Expand All @@ -33,7 +35,7 @@
"scripts": {
"build": "node scripts/begin.js && yarn build:prod",
"build:prod": "yarn build:dev && yarn build:server && yarn build:client && yarn build:electron",
"build:dev": "yarn build:test && yarn build:lib && yarn build:tools && yarn build:extensions && yarn build:plugins",
"build:dev": "yarn build:test && yarn build:lib && yarn build:tools && yarn build:extensions && yarn build:plugins && yarn l10n",
"build:test": "yarn workspace @bfc/test-utils build",
"build:lib": "yarn workspace @bfc/libs build:all",
"build:electron": "yarn workspace @bfc/electron-server build",
Expand Down Expand Up @@ -65,7 +67,12 @@
"typecheck": "concurrently --kill-others-on-fail \"npm:typecheck:*\"",
"typecheck:server": "yarn workspace @bfc/server typecheck",
"typecheck:client": "yarn workspace @bfc/client typecheck",
"tableflip": "rimraf node_modules/ **/node_modules && yarn && yarn build"
"tableflip": "rimraf node_modules/ **/node_modules && yarn && yarn build",
"l10n:extract": "cross-env NODE_ENV=production format-message extract -g underscored_crc32 -o packages/server/src/locales/en-US.json l10ntemp/**/*.js",
"l10n:extractJson": "node scripts/l10n-extractJson.js",
"l10n:transform": "node scripts/l10n-transform.js",
"l10n:babel": "babel ./packages --extensions \".ts,.tsx,.jsx,.js\" --out-dir l10ntemp --presets=@babel/react,@babel/typescript --plugins=@babel/plugin-proposal-class-properties --ignore \"packages/**/__tests__\",\"packages/**/node_modules\",\"packages/**/build/**/*.js\"",
"l10n": "yarn l10n:babel && yarn l10n:extract && yarn l10n:transform packages/server/src/locales/en-US.json && yarn l10n:extractJson packages/server/schemas"
},
"husky": {
"hooks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ describe('<CreationFlow/>', () => {
'EchoBot-1',
'',
expect.stringMatching(/(\/|\\)test-folder(\/|\\)Desktop/),
''
'',
'en-US'
);
});
});
6 changes: 3 additions & 3 deletions Composer/packages/client/__tests__/utils/dialogUtil.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getEventTypes,
getActivityTypes,
getFriendlyName,
getbreadcrumbLabel,
getBreadcrumbLabel,
getSelected,
} from '../../src/utils/dialogUtil';

Expand Down Expand Up @@ -234,9 +234,9 @@ describe('getFriendlyName', () => {
});
});

describe('getbreadcrumbLabel', () => {
describe('getBreadcrumbLabel', () => {
it('return breadcrumb label', () => {
const name = getbreadcrumbLabel(dialogs, 'id1', null, null);
const name = getBreadcrumbLabel(dialogs, 'id1', null, null);
expect(name).toBe('MainDialog');
});
});
Expand Down
33 changes: 32 additions & 1 deletion Composer/packages/client/__tests__/utils/fileUtil.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { getExtension, getBaseName, upperCaseName } from '../../src/utils/fileUtil';
import formatMessage from 'format-message';

import { getExtension, getBaseName, upperCaseName, loadLocale } from '../../src/utils/fileUtil';
import httpClient from '../../src/utils/httpUtil';

jest.mock('../../src/utils/httpUtil');

const files = ['a.text', 'a.b.text', 1];

Expand Down Expand Up @@ -37,3 +42,29 @@ describe('upperCaseName', () => {
expect(result3).toEqual(1);
});
});

describe('loadLocale', () => {
const LOCALE = 'en-test';
it("does not set locale if it can't find one", async () => {
jest.spyOn(httpClient, 'get').mockImplementation(() => ({ data: null }));

expect(await loadLocale(LOCALE)).toBeNull();
});
it('does not set locale if the server returns an error page', async () => {
jest.spyOn(httpClient, 'get').mockImplementation(() => ({ data: 'error page' }));

expect(await loadLocale(LOCALE)).toBeNull();
});
it('sets locale if it does find one', async () => {
const RESPONSE = { data: { abc: 'def' } };

jest.spyOn(httpClient, 'get').mockImplementation(() => RESPONSE);

expect(await loadLocale(LOCALE)).toMatchObject({
locale: LOCALE,
generateId: expect.anything(),
missingTranslation: 'ignore',
translations: { [LOCALE]: RESPONSE.data },
});
});
});
4 changes: 2 additions & 2 deletions Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"test": "jest",
"lint": "eslint --quiet --ext .js,.jsx,.ts,.tsx ./src ./__tests__",
"lint:fix": "yarn lint --fix",
"typecheck": "tsc --noEmit",
"extract": "cross-env NODE_ENV=production format-message extract -g underscored_crc32 -o locales/en-US.json src/**/*.ts src/**/*.tsx"
"typecheck": "tsc --noEmit"
},
"proxy": "http://localhost:5000",
"dependencies": {
Expand All @@ -43,6 +42,7 @@
"axios": "^0.19.2",
"babel-plugin-extract-format-message": "^6.2.3",
"format-message": "^6.2.3",
"format-message-generate-id": "^6.2.3",
"immer": "^5.2.0",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.19",
Expand Down
7 changes: 6 additions & 1 deletion Composer/packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ import { useRecoilValue } from 'recoil';
import { Header } from './components/Header';
import { Announcement } from './components/AppComponents/Announcement';
import { MainContainer } from './components/AppComponents/MainContainer';
import { userSettingsState } from './recoilModel';
import { loadLocale } from './utils/fileUtil';
import { dispatcherState } from './recoilModel/DispatcherWrapper';

initializeIcons(undefined, { disableWarnings: true });

export const App: React.FC = () => {
const { appLocale } = useRecoilValue(userSettingsState);
loadLocale(appLocale);

const { fetchPlugins } = useRecoilValue(dispatcherState);
useEffect(() => {
fetchPlugins();
});

return (
<Fragment>
<Fragment key={appLocale}>
<Announcement />
<Header />
<MainContainer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
templateProjectsState,
storagesState,
focusedStorageFolderState,
userSettingsState,
localeState,
} from '../../recoilModel';
import Home from '../../pages/home/Home';
Expand Down Expand Up @@ -51,6 +52,7 @@ const CreationFlow: React.FC<CreationFlowProps> = () => {
const templateProjects = useRecoilValue(templateProjectsState);
const storages = useRecoilValue(storagesState);
const focusedStorageFolder = useRecoilValue(focusedStorageFolderState);
const { appLocale } = useRecoilValue(userSettingsState);
const locale = useRecoilValue(localeState);
const cachedProjectId = useProjectIdCache();
const currentStorageIndex = useRef(0);
Expand Down Expand Up @@ -103,7 +105,14 @@ const CreationFlow: React.FC<CreationFlowProps> = () => {
};

const handleCreateNew = async (formData, templateId: string) => {
await createProject(templateId || '', formData.name, formData.description, formData.location, formData.schemaUrl);
await createProject(
templateId || '',
formData.name,
formData.description,
formData.location,
formData.schemaUrl,
appLocale
);
};

const handleSaveAs = (formData) => {
Expand Down
6 changes: 1 addition & 5 deletions Composer/packages/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@

import React from 'react';
import ReactDOM from 'react-dom';
import formatMessage from 'format-message';
import { CacheProvider } from '@emotion/core';
import createCache from '@emotion/cache';
import { RecoilRoot } from 'recoil';

import './index.css';

import { App } from './App';
import { DispatcherWrapper } from './recoilModel';

const appHostElm = document.getElementById('root');

formatMessage.setup({
missingTranslation: process.env.NODE_ENV === 'development' ? 'warning' : 'ignore',
});

const emotionCache = createCache({
// @ts-ignore
nonce: window.__nonce__,
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/design/DesignPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DialogDeleting } from '../../constants';
import {
createSelectedPath,
deleteTrigger,
getbreadcrumbLabel,
getBreadcrumbLabel,
qnaMatcherKey,
TriggerFormData,
getDialogData,
Expand Down Expand Up @@ -461,7 +461,7 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
dialogs.length > 0
? breadcrumb.reduce((result, item, index) => {
const { dialogId, selected, focused } = item;
const text = getbreadcrumbLabel(dialogs, dialogId, selected, focused);
const text = getBreadcrumbLabel(dialogs, dialogId, selected, focused);
if (text) {
result.push({
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { onboardingState, userSettingsState, dispatcherState } from '../../../re

import { container, section } from './styles';
import { SettingToggle } from './SettingToggle';
import { SettingDropdown } from './SettingDropdown';
import * as images from './images';

const ElectronSettings = lazy(() =>
Expand All @@ -43,8 +44,24 @@ const AppSettings: React.FC<RouteComponentProps> = () => {
updateUserSettings({ codeEditor: { [key]: checked } });
};

const onLocaleChange = (appLocale: string) => {
updateUserSettings({ appLocale });
};

const renderElectronSettings = isElectron();

const languageOptions = [{ key: 'en-US', text: formatMessage('English (US)') }];
if (process.env.NODE_ENV !== 'production') {
languageOptions.push({
key: 'en-US-pseudo',
text: formatMessage('Pseudo'),
});
languageOptions.push({
key: 'en-US-DoesNotExist',
text: formatMessage('Does Not Exist'),
});
}

return (
<div css={container}>
<section css={section}>
Expand Down Expand Up @@ -127,7 +144,17 @@ const AppSettings: React.FC<RouteComponentProps> = () => {
onToggle={onCodeEditorChange('wordWrap')}
/>
</section>

<section css={section}>
<h2>{formatMessage('Application Language')}</h2>
<SettingDropdown
description={formatMessage('This is the language used for Composer’s user interface.')}
image={images.language}
options={languageOptions}
selected={userSettings.appLocale}
title={formatMessage('Application language')}
onChange={onLocaleChange}
/>
</section>
<Suspense fallback={<div />}>{renderElectronSettings && <ElectronSettings />}</Suspense>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/** @jsx jsx */
import { jsx } from '@emotion/core';
import React from 'react';
import { Label } from 'office-ui-fabric-react/lib/Label';
import { useId } from '@uifabric/react-hooks';
import kebabCase from 'lodash/kebabCase';
import { Dropdown } from 'office-ui-fabric-react/lib/Dropdown';

import * as styles from './styles';

interface ISettingToggleProps {
description: React.ReactChild;
id?: string;
image: string;
onChange: (key: string) => void;
title: string;
options: { key: string; text: string }[];
selected?: string;
}

const SettingDropdown: React.FC<ISettingToggleProps> = (props) => {
const { id, title, description, image, onChange, options, selected } = props;
const uniqueId = useId(kebabCase(title));

return (
<div css={styles.settingsContainer}>
<div aria-hidden="true" css={styles.image} role="presentation">
{image && <img aria-hidden alt={''} src={image} />}
</div>
<div css={styles.settingsContent}>
<Label htmlFor={id || uniqueId} styles={{ root: { padding: 0 } }}>
{title}
</Label>
<p css={styles.settingsDescription}>{description}</p>
</div>
<div>
<Dropdown
id={id || uniqueId}
options={options}
selectedKey={selected}
onChange={(_e, option) => onChange(option?.key?.toString() ?? '')}
/>
</div>
</div>
);
};

export { SettingDropdown };
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SettingToggle: React.FC<ISettingToggleProps> = (props) => {
return (
<div css={styles.settingsContainer}>
<div aria-hidden="true" css={styles.image} role="presentation">
{image && <img src={image} />}
{image && <img aria-hidden alt={''} src={image} />}
</div>
<div css={styles.settingsContent}>
<Label htmlFor={id || uniqueId} styles={{ root: { padding: 0 } }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import lineNumbers from './line-numbers.svg';
import wordWrap from './word-wrap.svg';
import autoUpdate from './auto-update.svg';
import earlyAdopters from './early-adopters.svg';
import language from './language.svg';

export { minimap, onboarding, lineNumbers, wordWrap, autoUpdate, earlyAdopters };
export { minimap, onboarding, lineNumbers, wordWrap, autoUpdate, earlyAdopters, language };
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ describe('user dispatcher', () => {
},
propertyEditorWidth: 400,
dialogNavWidth: 555,
appLocale: 'en-US',
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ export const projectDispatcher = () => {
name: string,
description: string,
location: string,
schemaUrl?: string
schemaUrl?: string,
locale?: string
) => {
try {
await setBotOpeningStatus(callbackHelpers);
Expand All @@ -272,6 +273,7 @@ export const projectDispatcher = () => {
description,
location,
schemaUrl,
locale,
});
const projectId = response.data.id;
if (settingStorage.get(projectId)) {
Expand Down
Loading