From ee6271eb8b88e01e28d544c51d4ab099e88060a3 Mon Sep 17 00:00:00 2001 From: Khoa Nguyen Date: Thu, 8 Feb 2024 21:47:38 +0000 Subject: [PATCH] added language pack support (#96) * added language pack * added build process in readme --- LookdownComponent/.vscode/settings.json | 2 +- .../Lookdown/ControlManifest.Input.xml | 7 +- .../Lookdown/components/LookdownControl.tsx | 41 ++-- LookdownComponent/Lookdown/index.ts | 14 +- .../Lookdown/services/DataverseService.ts | 45 ++++- .../Lookdown/strings/Lookdown.1033.resx | 140 ++++++++++++++ .../Lookdown/types/languagePack.ts | 7 + .../PolyLookup/ControlManifest.Input.xml | 5 +- .../components/PolyLookupControl.tsx | 53 ++++-- PolyLookupComponent/PolyLookup/index.ts | 22 ++- .../PolyLookup/services/DataverseService.ts | 38 ++++ .../PolyLookup/strings/PolyLookup.1033.resx | 176 ++++++++++++++++++ .../PolyLookup/types/languagePack.ts | 16 ++ PolyLookupComponent/package-lock.json | 26 ++- PolyLookupComponent/package.json | 4 +- README.md | 32 ++++ solution/src/Other/Solution.xml | 4 +- 17 files changed, 583 insertions(+), 49 deletions(-) create mode 100644 LookdownComponent/Lookdown/strings/Lookdown.1033.resx create mode 100644 LookdownComponent/Lookdown/types/languagePack.ts create mode 100644 PolyLookupComponent/PolyLookup/strings/PolyLookup.1033.resx create mode 100644 PolyLookupComponent/PolyLookup/types/languagePack.ts diff --git a/LookdownComponent/.vscode/settings.json b/LookdownComponent/.vscode/settings.json index e4ec09c..59bacff 100644 --- a/LookdownComponent/.vscode/settings.json +++ b/LookdownComponent/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.formatOnSave": true, "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" } } \ No newline at end of file diff --git a/LookdownComponent/Lookdown/ControlManifest.Input.xml b/LookdownComponent/Lookdown/ControlManifest.Input.xml index 80ad061..dbf383a 100644 --- a/LookdownComponent/Lookdown/ControlManifest.Input.xml +++ b/LookdownComponent/Lookdown/ControlManifest.Input.xml @@ -1,6 +1,6 @@ - + - + @@ -35,6 +35,7 @@ 0 1 + SingleLine.Text SingleLine.TextArea @@ -46,8 +47,8 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + (Blank) + Label shown when group value is null or empty + + + No options found + Message shown when option list is empty + + + Open record + Label for open record button + + + Quick create + Label for quick create button + + + Lookup panel + Label for open lookup panel button + + \ No newline at end of file diff --git a/LookdownComponent/Lookdown/types/languagePack.ts b/LookdownComponent/Lookdown/types/languagePack.ts new file mode 100644 index 0000000..5bbd193 --- /dev/null +++ b/LookdownComponent/Lookdown/types/languagePack.ts @@ -0,0 +1,7 @@ +export interface LanguagePack { + BlankValueLabel: string; + EmptyListMessage: string; + OpenRecordLabel: string; + QuickCreateLabel: string; + LookupPanelLabel: string; +} diff --git a/PolyLookupComponent/PolyLookup/ControlManifest.Input.xml b/PolyLookupComponent/PolyLookup/ControlManifest.Input.xml index 7bd8f61..93cc510 100644 --- a/PolyLookupComponent/PolyLookup/ControlManifest.Input.xml +++ b/PolyLookupComponent/PolyLookup/ControlManifest.Input.xml @@ -1,6 +1,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Select an option + Used when Table Plural Name is not available + + + Select %s + Select { Table Plural Name } + + + No options found + Message shown when suggestion list is empty + + + No %s found + No { Table Plural Name } found + + + Suggested options + Suggestion list header + + + Suggested %s + Suggested { Table Plural Name } + + + Loading + Message shown when data is loading + + + Quick Create + Label for quick create button + + + Load More + Label for load more button + + + Please save the form first + Message shown when create form + + + The control is not available in this form + Message shown when control is not available + + + Relationship not supported + Label shown when relationship not supported + + + No more options + Message shown when there is no more record to load + + + Refine search term for more + Message shown when there are more records but the suggestion list already full + + \ No newline at end of file diff --git a/PolyLookupComponent/PolyLookup/types/languagePack.ts b/PolyLookupComponent/PolyLookup/types/languagePack.ts new file mode 100644 index 0000000..b446f5a --- /dev/null +++ b/PolyLookupComponent/PolyLookup/types/languagePack.ts @@ -0,0 +1,16 @@ +export interface LanguagePack { + PlaceholderDefault: string; + Placeholder: string; + EmptyListDefaultMessage: string; + EmptyListMessage: string; + SuggestionListHeaderDefaultLabel: string; + SuggestionListHeaderLabel: string; + LoadingMessage: string; + AddNewLabel: string; + LoadMoreLabel: string; + CreateFormNotSupportedMessage: string; + ControlIsNotAvailableMessage: string; + RelationshipNotSupportedMessage: string; + NoMoreRecordsMessage: string; + SuggestionListFullMessage: string; +} diff --git a/PolyLookupComponent/package-lock.json b/PolyLookupComponent/package-lock.json index a70f368..d8e3115 100644 --- a/PolyLookupComponent/package-lock.json +++ b/PolyLookupComponent/package-lock.json @@ -13,12 +13,14 @@ "axios": "^1.3.4", "handlebars": "^4.7.8", "react": "16.8.6", - "react-dom": "16.8.6" + "react-dom": "16.8.6", + "sprintf-js": "^1.1.3" }, "devDependencies": { "@microsoft/eslint-plugin-power-apps": "^0.2.6", "@types/node": "^18.8.2", "@types/powerapps-component-framework": "^1.3.4", + "@types/sprintf-js": "^1.1.4", "@types/xrm": "^9.0.70", "@typescript-eslint/eslint-plugin": "^5.39.0", "@typescript-eslint/parser": "^5.39.0", @@ -2726,6 +2728,12 @@ "integrity": "sha512-dKkr1bTxbEsFlh2ARpKzcaAmsYixqt9UyCdoEZk8rHyE4iQYcDCyvSjDSf7JUWJHlJiTtbIoQjxKh6ViywqDAg==", "dev": true }, + "node_modules/@types/sprintf-js": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/sprintf-js/-/sprintf-js-1.1.4.tgz", + "integrity": "sha512-aWK1reDYWxcjgcIIPmQi3u+OQDuYa9b+lr6eIsGWrekJ9vr1NSjr4Eab8oQ1iKuH1ltFHpXGyerAv1a3FMKxzQ==", + "dev": true + }, "node_modules/@types/xrm": { "version": "9.0.70", "resolved": "https://registry.npmjs.org/@types/xrm/-/xrm-9.0.70.tgz", @@ -8260,6 +8268,11 @@ "source-map": "^0.6.0" } }, + "node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==" + }, "node_modules/stack-chain": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", @@ -11175,6 +11188,12 @@ "integrity": "sha512-dKkr1bTxbEsFlh2ARpKzcaAmsYixqt9UyCdoEZk8rHyE4iQYcDCyvSjDSf7JUWJHlJiTtbIoQjxKh6ViywqDAg==", "dev": true }, + "@types/sprintf-js": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/sprintf-js/-/sprintf-js-1.1.4.tgz", + "integrity": "sha512-aWK1reDYWxcjgcIIPmQi3u+OQDuYa9b+lr6eIsGWrekJ9vr1NSjr4Eab8oQ1iKuH1ltFHpXGyerAv1a3FMKxzQ==", + "dev": true + }, "@types/xrm": { "version": "9.0.70", "resolved": "https://registry.npmjs.org/@types/xrm/-/xrm-9.0.70.tgz", @@ -15337,6 +15356,11 @@ "source-map": "^0.6.0" } }, + "sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==" + }, "stack-chain": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", diff --git a/PolyLookupComponent/package.json b/PolyLookupComponent/package.json index edda883..8566154 100644 --- a/PolyLookupComponent/package.json +++ b/PolyLookupComponent/package.json @@ -17,12 +17,14 @@ "axios": "^1.3.4", "handlebars": "^4.7.8", "react": "16.8.6", - "react-dom": "16.8.6" + "react-dom": "16.8.6", + "sprintf-js": "^1.1.3" }, "devDependencies": { "@microsoft/eslint-plugin-power-apps": "^0.2.6", "@types/node": "^18.8.2", "@types/powerapps-component-framework": "^1.3.4", + "@types/sprintf-js": "^1.1.4", "@types/xrm": "^9.0.70", "@typescript-eslint/eslint-plugin": "^5.39.0", "@typescript-eslint/parser": "^5.39.0", diff --git a/README.md b/README.md index 27e955f..c5b0230 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,35 @@ I'll review your changes and work with you to merge them into the main repositor ### Git branches - **main**: This branch contains the latest features of the components. Please see [tags](https://github.com/khoait/DCE.PCF/tags) for version specific code + +### Build and test individual component in dev + +1. open the repo in VS Code +2. in Terminal, navigate to a component folder `cd PolyLookupComponent` for example +3. run `npm install` to install all required packages +4. run `npm run build` to build the component +5. to test the component, because the component needs to load metadata from Dataverse, we can't use the test harness by running `npm run start`. + + Instead, we need to deploy the component to an environment by running + ``` + pac pcf push --publisher-prefix dce + ``` + + you'll need PowerApps CLI to run `pac` commands, please install it [here](https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction) + +### Build the component package for production + +when you're ready, you can build a solution package that contains all components in the repo to deploy to a production environment. + +1. in Terminal, navigate to folder `cd DCEPCF/solution` +2. for dotnet build, run + ``` + dotnet build --configuration Release + ``` + + for msbuild, run + + ``` + msbuild /t:build /restore /p:configuration=Release + ``` +3. you can find an managed solution and an unmanaged solution will be created in the output folder under `solution/bin/Release` \ No newline at end of file diff --git a/solution/src/Other/Solution.xml b/solution/src/Other/Solution.xml index 9d82bab..2ebe6e4 100644 --- a/solution/src/Other/Solution.xml +++ b/solution/src/Other/Solution.xml @@ -8,7 +8,7 @@ - 1.0.4.1 + 1.0.5.0 2 @@ -20,7 +20,7 @@ - +