Skip to content

Commit

Permalink
feat: electron app localization (microsoft#4161)
Browse files Browse the repository at this point in the history
* splash screen

* Fix css

* Fixes logo

* Fix blank window

* Fixes mac

* fix splash screen flashing on linux

* Added comments

* Electron l10n

* check app locale

* Remove unnecessary async

* PR comments

Co-authored-by: Soroush <[email protected]>
  • Loading branch information
hatpick and sorgh authored Sep 16, 2020
1 parent c8799a9 commit 6dbf0d4
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"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",
"build:electron": "yarn workspace @bfc/electron-server build && yarn workspace @bfc/electron-server l10n",
"build:extensions": "wsrun -lt -p @bfc/extension @bfc/intellisense @bfc/extension-client @bfc/adaptive-form @bfc/adaptive-flow @bfc/ui-plugin-* -c build",
"build:server": "yarn workspace @bfc/server build",
"build:client": "yarn workspace @bfc/client build",
Expand Down Expand Up @@ -74,7 +74,7 @@
"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:babel": "babel ./packages --extensions \".ts,.tsx,.jsx,.js\" --out-dir l10ntemp --presets=@babel/react,@babel/typescript --plugins=@babel/plugin-proposal-class-properties --ignore \"packages/electron-server\",\"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": {
Expand Down
7 changes: 7 additions & 0 deletions Composer/packages/client/src/recoilModel/dispatchers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getUserTokenFromCache, loginPopup, refreshToken } from '../../utils/aut
import storage from '../../utils/storage';
import { loadLocale } from '../../utils/fileUtil';
import { UserSettingsPayload } from '../types';
import { isElectron } from '../../utils/electronUtil';

enum ClaimNames {
upn = 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn',
Expand Down Expand Up @@ -89,6 +90,12 @@ export const userDispatcher = () => {
}
}
storage.set('userSettings', newSettings);

if (isElectron()) {
// push the settings to the electron main process
window.ipcRenderer.send('update-user-settings', newSettings);
}

return newSettings;
});
}
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/electron-server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build/
dist/
locales/en-US-pseudo.json
l10ntemp/
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"files": [
"build",
"locales",
"resources/composerIcon_1024x1024.png",
"resources/ms_logo.svg"
],
Expand Down
125 changes: 125 additions & 0 deletions Composer/packages/electron-server/locales/en-US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"about_70c18bba": {
"message": "About"
},
"actual_zoom_211ec99": {
"message": "Actual Zoom"
},
"bring_all_to_front_207a7ad1": {
"message": "Bring All to Front"
},
"check_for_updates_12a70061": {
"message": "Check for Updates"
},
"close_d634289d": {
"message": "Close"
},
"close_window_4bdc79d7": {
"message": "Close Window"
},
"composer_on_github_1e3782ef": {
"message": "Composer on GitHub"
},
"copy_9748f9f": {
"message": "Copy"
},
"cut_c8c92681": {
"message": "Cut"
},
"delete_a6efa79d": {
"message": "Delete"
},
"documentation_d82f6eec": {
"message": "Documentation"
},
"edit_c5fbea07": {
"message": "Edit"
},
"exit_d0c7b013": {
"message": "Exit"
},
"file_c851020d": {
"message": "File"
},
"help_4c4968b1": {
"message": "Help"
},
"hide_bot_framework_composer_eeba3ea8": {
"message": "Hide Bot Framework Composer"
},
"hide_others_4204b552": {
"message": "Hide Others"
},
"initializing_4e34f7d": {
"message": "Initializing..."
},
"learn_more_about_bot_framework_2daca065": {
"message": "Learn More About Bot Framework"
},
"minimize_4f999e30": {
"message": "Minimize"
},
"paste_5963d1c1": {
"message": "Paste"
},
"privacy_statement_58986965": {
"message": "Privacy Statement"
},
"quit_bot_framework_composer_455ceb74": {
"message": "Quit Bot Framework Composer"
},
"redo_363c58b7": {
"message": "Redo"
},
"report_an_issue_f33f3ba5": {
"message": "Report an Issue"
},
"select_all_cf7e0248": {
"message": "Select All"
},
"services_ccd7bca0": {
"message": "Services"
},
"show_all_ae37d610": {
"message": "Show All"
},
"speech_16063aed": {
"message": "Speech"
},
"start_speaking_f8d406ff": {
"message": "Start Speaking"
},
"starting_server_721c37fd": {
"message": "Starting server..."
},
"stop_speaking_7b4b9834": {
"message": "Stop Speaking"
},
"toggle_developer_tools_d2ef8ea7": {
"message": "Toggle Developer Tools"
},
"toggle_full_screen_272a0c5": {
"message": "Toggle Full Screen"
},
"undo_a7be8fef": {
"message": "Undo"
},
"view_ba339f93": {
"message": "View"
},
"view_license_720d341a": {
"message": "View License"
},
"window_171922c7": {
"message": "Window"
},
"zoom_f3e54d69": {
"message": "Zoom"
},
"zoom_in_a781ccc7": {
"message": "Zoom In"
},
"zoom_out_dc7d60d2": {
"message": "Zoom Out"
}
}
11 changes: 9 additions & 2 deletions Composer/packages/electron-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"build": "tsc -p tsconfig.build.json && ncp src/preload.js build/preload.js",
"clean": "rimraf build && rimraf dist",
"clean": "rimraf build && rimraf dist && rimraf l10ntemp",
"copy-plugins": "node scripts/copy-plugins.js",
"copy-runtime": "node scripts/copy-runtime.js",
"dist": "node scripts/electronBuilderDist.js",
Expand All @@ -22,7 +22,12 @@
"start:electron": "./node_modules/.bin/electron --inspect=7777 --remote-debugging-port=7778 .",
"start:electron:dev": "cross-env NODE_ENV=development ELECTRON_TARGET_URL=http://localhost:3000/ npm run start:electron",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"l10n:extract": "cross-env NODE_ENV=production format-message extract -g underscored_crc32 -o locales/en-US.json l10ntemp/**/*.js",
"l10n:extractJson": "node ../../scripts/l10n-extractJson.js",
"l10n:transform": "node ../../scripts/l10n-transform.js",
"l10n:babel": "babel . --extensions \".ts,.tsx,.jsx,.js\" --out-dir l10ntemp --presets=@babel/typescript --plugins=@babel/plugin-proposal-class-properties --ignore \"**/__tests__\",\"**/node_modules\",\"**/build/**/*.js\"",
"l10n": "yarn l10n:babel && yarn l10n:extract && yarn l10n:transform locales/en-US.json && rimraf l10ntemp"
},
"devDependencies": {
"@types/archiver": "^3.1.0",
Expand Down Expand Up @@ -59,6 +64,8 @@
"debug": "4.1.1",
"electron-updater": "4.2.5",
"fix-path": "^3.0.0",
"format-message": "^6.2.3",
"format-message-generate-id": "^6.2.3",
"fs-extra": "^9.0.0",
"lodash": "^4.17.19",
"semver": "7.3.2"
Expand Down
Loading

0 comments on commit 6dbf0d4

Please sign in to comment.