@pnp/spfx-controls-react 3.21.0-beta.1344790 → 4.0.0-beta.1344828
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +4 -10
- package/.husky/pre-commit +1 -0
- package/CHANGELOG.json +1 -3
- package/CHANGELOG.md +1 -2
- package/dist/e9a37567-6524-4902-938d-4b143a50e466.manifest.json +19 -0
- package/dist/spfx-controls-library.js +58 -0
- package/dist/spfx-controls-library.js.map +1 -0
- package/lib/common/Interfaces.d.ts +1 -1
- package/lib/common/Interfaces.d.ts.map +1 -1
- package/lib/common/telemetry/version.d.ts.map +1 -1
- package/lib/common/telemetry/version.js +1 -1
- package/lib/common/telemetry/version.js.map +1 -1
- package/lib/common/utilities/FormulaEvaluation.d.ts.map +1 -1
- package/lib/common/utilities/FormulaEvaluation.js +3 -0
- package/lib/common/utilities/FormulaEvaluation.js.map +1 -1
- package/lib/common/utilities/GeneralHelper.d.ts.map +1 -1
- package/lib/common/utilities/GeneralHelper.js +60 -29
- package/lib/common/utilities/GeneralHelper.js.map +1 -1
- package/lib/controls/MyTeams/MyTeams.d.ts +2 -2
- package/lib/controls/MyTeams/MyTeams.d.ts.map +1 -1
- package/lib/controls/MyTeams/MyTeams.js +30 -24
- package/lib/controls/MyTeams/MyTeams.js.map +1 -1
- package/lib/controls/MyTeams/MyTeamsReducer.d.ts.map +1 -1
- package/lib/controls/MyTeams/MyTeamsReducer.js +1 -0
- package/lib/controls/MyTeams/MyTeamsReducer.js.map +1 -1
- package/lib/controls/MyTeams/MyTeamsStyles.d.ts +6 -7
- package/lib/controls/MyTeams/MyTeamsStyles.d.ts.map +1 -1
- package/lib/controls/MyTeams/MyTeamsStyles.js +25 -25
- package/lib/controls/MyTeams/MyTeamsStyles.js.map +1 -1
- package/lib/controls/MyTeams/components/Team/TeamReducer.d.ts.map +1 -1
- package/lib/controls/MyTeams/components/Team/TeamReducer.js +1 -0
- package/lib/controls/MyTeams/components/Team/TeamReducer.js.map +1 -1
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicator.js +1 -1
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicator.js.map +1 -1
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicatorStyles.d.ts +7 -50
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicatorStyles.d.ts.map +1 -1
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicatorStyles.js +32 -26
- package/lib/controls/ProgressStepsIndicator/ProgressStepsIndicatorStyles.js.map +1 -1
- package/lib/controls/TeamChannelPicker/TeamChannelPickerStyles.d.ts +5 -6
- package/lib/controls/TeamChannelPicker/TeamChannelPickerStyles.d.ts.map +1 -1
- package/lib/controls/TeamChannelPicker/TeamChannelPickerStyles.js +39 -39
- package/lib/controls/TeamChannelPicker/TeamChannelPickerStyles.js.map +1 -1
- package/lib/controls/TeamPicker/TeamPickerStyles.d.ts +5 -6
- package/lib/controls/TeamPicker/TeamPickerStyles.d.ts.map +1 -1
- package/lib/controls/TeamPicker/TeamPickerStyles.js +31 -31
- package/lib/controls/TeamPicker/TeamPickerStyles.js.map +1 -1
- package/lib/controls/TermSetNavigation/assets/menu-rafiki.svg +1 -0
- package/lib/controls/TermSetNavigation/utils/useUtils.d.ts.map +1 -1
- package/lib/controls/TermSetNavigation/utils/useUtils.js +9 -2
- package/lib/controls/TermSetNavigation/utils/useUtils.js.map +1 -1
- package/lib/controls/accordion/Accordion.module.css +1 -1
- package/lib/controls/animatedDialog/AnimatedDialog.d.ts +1 -1
- package/lib/controls/animatedDialog/AnimatedDialog.d.ts.map +1 -1
- package/lib/controls/animatedDialog/AnimatedDialog.js +39 -39
- package/lib/controls/animatedDialog/AnimatedDialog.js.map +1 -1
- package/lib/controls/animatedDialog/AnimatedDialog.module.css +1 -1
- package/lib/controls/carousel/Carousel.module.css +1 -1
- package/lib/controls/chartControl/AccessibleChartTable.test.js +334 -0
- package/lib/controls/chartControl/AccessibleChartTable.test.js.map +1 -0
- package/lib/controls/chartControl/ChartControl.d.ts +12 -12
- package/lib/controls/chartControl/ChartControl.d.ts.map +1 -1
- package/lib/controls/chartControl/ChartControl.js +46 -39
- package/lib/controls/chartControl/ChartControl.js.map +1 -1
- package/lib/controls/chartControl/ChartControl.module.css +1 -1
- package/lib/controls/chartControl/ChartControl.test.js +87 -0
- package/lib/controls/chartControl/ChartControl.test.js.map +1 -0
- package/lib/controls/chartControl/PaletteGenerator.test.js +61 -0
- package/lib/controls/chartControl/PaletteGenerator.test.js.map +1 -0
- package/lib/controls/dashboard/Dashboard.module.css +1 -1
- package/lib/controls/dateTimePicker/DateTimePicker.module.css +1 -1
- package/lib/controls/dragDropFiles/DragDropFiles.d.ts +1 -1
- package/lib/controls/dragDropFiles/DragDropFiles.d.ts.map +1 -1
- package/lib/controls/dragDropFiles/DragDropFiles.js.map +1 -1
- package/lib/controls/dragDropFiles/DragDropFiles.module.css +1 -1
- package/lib/controls/dynamicForm/DynamicForm.module.css +1 -1
- package/lib/controls/errorMessage/ErrorMessage.module.css +1 -1
- package/lib/controls/fieldCollectionData/FieldCollectionData.module.css +1 -1
- package/lib/controls/fieldCollectionData/index.d.ts +1 -0
- package/lib/controls/fieldCollectionData/index.d.ts.map +1 -1
- package/lib/controls/fieldCollectionData/index.js +1 -0
- package/lib/controls/fieldCollectionData/index.js.map +1 -1
- package/lib/controls/fields/fieldAttachmentsRenderer/FieldAttachmentsRenderer.module.css +1 -1
- package/lib/controls/fields/fieldBaseTextRenderer/FieldBaseTextRenderer.module.css +1 -1
- package/lib/controls/fields/fieldCommon/FieldRenderer.module.css +1 -1
- package/lib/controls/fields/fieldFileTypeRenderer/FieldFileTypeRenderer.module.css +1 -1
- package/lib/controls/fields/fieldLookupRenderer/FieldLookupRenderer.module.css +1 -1
- package/lib/controls/fields/fieldNameRenderer/FieldNameRenderer.js +1 -1
- package/lib/controls/fields/fieldNameRenderer/FieldNameRenderer.js.map +1 -1
- package/lib/controls/fields/fieldNameRenderer/FieldNameRenderer.module.css +1 -1
- package/lib/controls/fields/fieldTaxonomyRenderer/FieldTaxonomyRenderer.module.css +1 -1
- package/lib/controls/fields/fieldTextRenderer/FieldTextRenderer.module.css +1 -1
- package/lib/controls/fields/fieldUrlRenderer/FieldUrlRenderer.module.css +1 -1
- package/lib/controls/fields/fieldUserRenderer/FieldUserRenderer.module.css +1 -1
- package/lib/controls/filePicker/FilePicker.module.css +1 -1
- package/lib/controls/filePicker/LinkFilePickerTab/LinkFilePickerTab.d.ts.map +1 -1
- package/lib/controls/filePicker/LinkFilePickerTab/LinkFilePickerTab.js +18 -10
- package/lib/controls/filePicker/LinkFilePickerTab/LinkFilePickerTab.js.map +1 -1
- package/lib/controls/filePicker/LinkFilePickerTab/LinkFilePickerTab.module.css +1 -1
- package/lib/controls/filePicker/MultipleUploadFilePickerTab/MultipleUploadFilePickerTab.module.css +1 -1
- package/lib/controls/filePicker/OneDriveFilesTab/OneDriveFilesTab.module.css +1 -1
- package/lib/controls/filePicker/RecentFilesTab/RecentFilesTab.module.css +1 -1
- package/lib/controls/filePicker/SiteFilePickerTab/SiteFilePickerTab.module.css +1 -1
- package/lib/controls/filePicker/StockImagesTab/StockImages.module.css +1 -1
- package/lib/controls/filePicker/UploadFilePickerTab/UploadFilePickerTab.module.css +1 -1
- package/lib/controls/filePicker/WebSearchTab/WebSearchTab.module.css +1 -1
- package/lib/controls/filePicker/controls/DocumentLibraryBrowser/DocumentLibraryBrowser.module.css +1 -1
- package/lib/controls/filePicker/controls/DocumentTile/DocumentTile.module.css +1 -1
- package/lib/controls/filePicker/controls/FileBrowser/FileBrowser.module.css +1 -1
- package/lib/controls/filePicker/controls/FolderTile/FolderTile.module.css +1 -1
- package/lib/controls/filePicker/controls/TilesList/TilesList.module.css +1 -1
- package/lib/controls/fileTypeIcon/FileTypeIcon.module.css +1 -1
- package/lib/controls/fileTypeIcon/FileTypeIcon.test.js +184 -0
- package/lib/controls/fileTypeIcon/FileTypeIcon.test.js.map +1 -0
- package/lib/controls/folderExplorer/FolderExplorer/FolderExplorer.module.css +1 -1
- package/lib/controls/folderExplorer/NewFolder/NewFolder.module.css +1 -1
- package/lib/controls/folderPicker/FolderPicker.module.css +1 -1
- package/lib/controls/gridLayout/GridLayout.module.css +1 -1
- package/lib/controls/gridLayout/GridLayout.test.js +86 -0
- package/lib/controls/gridLayout/GridLayout.test.js.map +1 -0
- package/lib/controls/iFrameDialog/IFrameDialogContent.module.css +1 -1
- package/lib/controls/iFramePanel/IFramePanelContent.module.css +1 -1
- package/lib/controls/iconPicker/IconPicker.module.css +1 -1
- package/lib/controls/listItemAttachments/ListItemAttachments.module.css +1 -1
- package/lib/controls/listItemComments/components/AddComment/AddComment.d.ts +1 -1
- package/lib/controls/listItemComments/components/AddComment/AddComment.d.ts.map +1 -1
- package/lib/controls/listItemComments/components/AddComment/AddComment.js +52 -28
- package/lib/controls/listItemComments/components/AddComment/AddComment.js.map +1 -1
- package/lib/controls/listItemComments/components/AddComment/useAddCommentStyles.d.ts +7 -46
- package/lib/controls/listItemComments/components/AddComment/useAddCommentStyles.d.ts.map +1 -1
- package/lib/controls/listItemComments/components/AddComment/useAddCommentStyles.js +44 -38
- package/lib/controls/listItemComments/components/AddComment/useAddCommentStyles.js.map +1 -1
- package/lib/controls/listItemPicker/ComboBoxListItemPicker.module.css +1 -1
- package/lib/controls/listItemPicker/ComboBoxListItemPicker.test.js +106 -0
- package/lib/controls/listItemPicker/ComboBoxListItemPicker.test.js.map +1 -0
- package/lib/controls/listPicker/ListPicker.module.css +1 -1
- package/lib/controls/listView/ListView.test.js +154 -0
- package/lib/controls/listView/ListView.test.js.map +1 -0
- package/lib/controls/locationPicker/LocationPicker.module.css +1 -1
- package/lib/controls/map/Maps.module.css +1 -1
- package/lib/controls/modernAudio/ModernAudio.module.css +1 -1
- package/lib/controls/modernTaxonomyPicker/ModernTaxonomyPicker.module.css +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.module.css +1 -1
- package/lib/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.module.css +1 -1
- package/lib/controls/modernTaxonomyPicker/termItem/TermItemSuggestions.module.css +1 -1
- package/lib/controls/pagination/Pagination.module.css +1 -1
- package/lib/controls/peoplepicker/PeoplePickerComponent.module.css +1 -1
- package/lib/controls/placeholder/PlaceholderComponent.test.js +73 -0
- package/lib/controls/placeholder/PlaceholderComponent.test.js.map +1 -0
- package/lib/controls/progress/Progress.module.css +1 -1
- package/lib/controls/richText/RichText.module.css +1 -1
- package/lib/controls/richText/RichTextPropertyPane.module.css +1 -1
- package/lib/controls/richText/RteColorPicker.module.css +1 -1
- package/lib/controls/securityTrimmedControl/SecurityTrimmedControl.d.ts +1 -1
- package/lib/controls/securityTrimmedControl/SecurityTrimmedControl.d.ts.map +1 -1
- package/lib/controls/securityTrimmedControl/SecurityTrimmedControl.js.map +1 -1
- package/lib/controls/siteBreadcrumb/SiteBreadcrumb.module.css +1 -1
- package/lib/controls/siteBreadcrumb/SiteBreadcrumb.test.js +30 -0
- package/lib/controls/siteBreadcrumb/SiteBreadcrumb.test.js.map +1 -0
- package/lib/controls/taxonomyPicker/TaxonomyPicker.module.css +1 -1
- package/lib/controls/toolbar/Toolbar.module.css +1 -1
- package/lib/controls/treeView/TreeView.module.css +1 -1
- package/lib/controls/uploadFiles/assets/welcome-dark.png +0 -0
- package/lib/controls/uploadFiles/assets/welcome-light.png +0 -0
- package/lib/controls/uploadFiles/components/DocumentList/useDocumentListStyles.d.ts +5 -11
- package/lib/controls/uploadFiles/components/DocumentList/useDocumentListStyles.d.ts.map +1 -1
- package/lib/controls/uploadFiles/components/DocumentList/useDocumentListStyles.js +41 -35
- package/lib/controls/uploadFiles/components/DocumentList/useDocumentListStyles.js.map +1 -1
- package/lib/controls/uploadFiles/components/File/useFileStyles.d.ts +6 -11
- package/lib/controls/uploadFiles/components/File/useFileStyles.d.ts.map +1 -1
- package/lib/controls/uploadFiles/components/File/useFileStyles.js +32 -26
- package/lib/controls/uploadFiles/components/File/useFileStyles.js.map +1 -1
- package/lib/controls/uploadFiles/components/FileCommandBar/useFileCommandBarStyles.d.ts +6 -12
- package/lib/controls/uploadFiles/components/FileCommandBar/useFileCommandBarStyles.d.ts.map +1 -1
- package/lib/controls/uploadFiles/components/FileCommandBar/useFileCommandBarStyles.js +31 -30
- package/lib/controls/uploadFiles/components/FileCommandBar/useFileCommandBarStyles.js.map +1 -1
- package/lib/controls/uploadFiles/components/NoDocuments/useNoDocumentsStyles.d.ts +3 -3
- package/lib/controls/uploadFiles/components/NoDocuments/useNoDocumentsStyles.d.ts.map +1 -1
- package/lib/controls/uploadFiles/components/NoDocuments/useNoDocumentsStyles.js +7 -7
- package/lib/controls/uploadFiles/components/NoDocuments/useNoDocumentsStyles.js.map +1 -1
- package/lib/controls/uploadFiles/components/UploadFiles/useUploadFilesStyles.d.ts +3 -2
- package/lib/controls/uploadFiles/components/UploadFiles/useUploadFilesStyles.d.ts.map +1 -1
- package/lib/controls/uploadFiles/components/UploadFiles/useUploadFilesStyles.js +4 -5
- package/lib/controls/uploadFiles/components/UploadFiles/useUploadFilesStyles.js.map +1 -1
- package/lib/controls/viewPicker/ViewPicker.module.css +1 -1
- package/lib/controls/webPartTitle/WebPartTitle.module.css +1 -1
- package/lib/controls/webPartTitle/WebPartTitle.test.js +79 -0
- package/lib/controls/webPartTitle/WebPartTitle.test.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -1
- package/lib/libraries/spfxControls/SpfxControlsLibrary.d.ts +4 -0
- package/lib/libraries/spfxControls/SpfxControlsLibrary.d.ts.map +1 -0
- package/lib/libraries/spfxControls/SpfxControlsLibrary.js +10 -0
- package/lib/libraries/spfxControls/SpfxControlsLibrary.js.map +1 -0
- package/lib/libraries/spfxControls/SpfxControlsLibrary.manifest.json +9 -0
- package/lib/libraries/spfxControls/loc/en-us.js +7 -0
- package/lib/services/PeopleSearchService.d.ts +4 -4
- package/lib/services/PeopleSearchService.d.ts.map +1 -1
- package/lib/services/PeopleSearchService.js +70 -40
- package/lib/services/PeopleSearchService.js.map +1 -1
- package/lib/services/SPTaxonomyService.d.ts.map +1 -1
- package/lib/services/SPTaxonomyService.js +31 -10
- package/lib/services/SPTaxonomyService.js.map +1 -1
- package/lib/services/SPTermStorePickerService.d.ts +4 -4
- package/lib/services/SPTermStorePickerService.d.ts.map +1 -1
- package/lib/services/SPTermStorePickerService.js +84 -45
- package/lib/services/SPTermStorePickerService.js.map +1 -1
- package/package.json +47 -23
- package/scripts/create-changelog.js +45 -0
- package/scripts/execute-translation.js +243 -0
- package/scripts/export-localization.js +49 -0
- package/scripts/sonarcloud.js +20 -0
- package/scripts/sync-changelogs.js +4 -0
- package/scripts/update-package-version.js +6 -0
- package/sharepoint/assets/ClientSideInstance.xml +9 -0
- package/sharepoint/assets/elements.xml +9 -0
- package/typings/@ms/odsp.d.ts +11 -0
- package/typings/tsd.d.ts +1 -0
- package/.hintrc +0 -15
- package/.nvmrc +0 -0
- package/README.md +0 -40
- package/release/component-dependency-audit/sp-dev-fx-controls-react.json +0 -591
- package/release/manifests/45165954-80f9-44c1-9967-cd38ae92a33b.manifest.json +0 -193
- package/release/manifests/57ebd944-98ed-43f9-b722-e959d6dac6ad.manifest.json +0 -87
- package/release/manifests/ca9eac70-7343-4972-88d6-672d50e9cf38.manifest.json +0 -41
- package/release/manifests/f9c6b930-8d5d-4550-bfd9-ed5f6ca443a8.manifest.json +0 -92
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script executes the translation of the localization keys for the provided languages (config/supported.localization.json) with the usage of the Azure Cognitive services.
|
|
3
|
+
* In case the language localization file doesn't exist, it is going to be created.
|
|
4
|
+
* Only languages supported by Azure Cognitive services are supported.
|
|
5
|
+
*
|
|
6
|
+
* English is used as a main language. The translation is executed for the keys which are the same as in English or are missing.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
const _ = require('lodash');
|
|
13
|
+
// Cognitive services
|
|
14
|
+
const request = require('request-promise');
|
|
15
|
+
const uuidv4 = require('uuid');
|
|
16
|
+
|
|
17
|
+
// Replace with process.env.subscriptionKey to get an access to Azure Cognitive services
|
|
18
|
+
const subscriptionKey = process.env.SUBSCRIPTION_KEY;
|
|
19
|
+
const endpoint = "https://api.cognitive.microsofttranslator.com";
|
|
20
|
+
|
|
21
|
+
const locHelper = require('./export-localization');
|
|
22
|
+
// Load configuration for supported languages
|
|
23
|
+
const languagesConfiguration = require('../config/supported.localization.json');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Obtain auth token for the global cognitive services endpoint from region (WestEurope)
|
|
27
|
+
*/
|
|
28
|
+
let authToken = null;
|
|
29
|
+
async function getAuthToken() {
|
|
30
|
+
try {
|
|
31
|
+
// Cache AuthToken
|
|
32
|
+
if (authToken) {
|
|
33
|
+
return authToken;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const options = {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
url: 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken',
|
|
39
|
+
headers: {
|
|
40
|
+
'Ocp-Apim-Subscription-Key': subscriptionKey,
|
|
41
|
+
'Content-type': 'application/x-www-form-urlencoded',
|
|
42
|
+
'Content-length': 0
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const token = await request(options);
|
|
47
|
+
if (!token || token.length < 0) {
|
|
48
|
+
throw new Error("Somethig went wrong when obtaining Auth token!");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Cache Auth token
|
|
52
|
+
authToken = token;
|
|
53
|
+
return token;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(`[Exception]: Cannot obtain Auth token. Err=${err}`)
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Function executes the translation using cognitive services.
|
|
63
|
+
*/
|
|
64
|
+
async function executeTranslation(lang, inputObj) {
|
|
65
|
+
try {
|
|
66
|
+
const authToken = await getAuthToken();
|
|
67
|
+
let options = {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
baseUrl: endpoint,
|
|
70
|
+
url: 'translate',
|
|
71
|
+
qs: {
|
|
72
|
+
'api-version': '3.0',
|
|
73
|
+
'to': [`${lang}`]
|
|
74
|
+
},
|
|
75
|
+
headers: {
|
|
76
|
+
'Authorization': `Bearer ${authToken}`,
|
|
77
|
+
'Content-type': 'application/json',
|
|
78
|
+
'X-ClientTraceId': uuidv4().toString()
|
|
79
|
+
},
|
|
80
|
+
body: inputObj,
|
|
81
|
+
json: true,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const response = await request(options);
|
|
85
|
+
if (!response || response.length < 0) {
|
|
86
|
+
throw new Error("Somethig went wrong when obtaining translated text!");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Go through all the results
|
|
90
|
+
const translations = response.map((item) => {
|
|
91
|
+
// Every translation is in a separate 1-element array -> make it flat
|
|
92
|
+
return item.translations[0];
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return translations;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
console.error(`[Exception]: Cannot execute translation for lang - ${lang}. Err=${err}`)
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function compareTranslationKeys(srcObj, dstObj) {
|
|
103
|
+
// Extract all the keys and set them in alpabetyical order
|
|
104
|
+
let dstKeys = Object.keys(dstObj);
|
|
105
|
+
|
|
106
|
+
let toTranslate = [];
|
|
107
|
+
// Array<string>
|
|
108
|
+
try {
|
|
109
|
+
dstKeys.forEach((locKey) => {
|
|
110
|
+
if (typeof srcObj[locKey] !== "string") {
|
|
111
|
+
// In case we have nested translation objects
|
|
112
|
+
toTranslate = toTranslate.concat(compareTranslationKeys(srcObj[locKey], dstObj[locKey]));
|
|
113
|
+
} else if (srcObj[locKey] === dstObj[locKey]) {
|
|
114
|
+
// In case the english value is the same as localized one, add it to translate
|
|
115
|
+
toTranslate.push(srcObj[locKey]);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.log(error.message);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
return toTranslate;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let currentTranslationIndex = 0;
|
|
127
|
+
function injectTranslatedKeys(srcObj, dstObj, translatedValues) {
|
|
128
|
+
const srcKeys = Object.keys(srcObj);
|
|
129
|
+
srcKeys.forEach((locKey) => {
|
|
130
|
+
if (typeof srcObj[locKey] !== "string") {
|
|
131
|
+
dstObj[locKey] = injectTranslatedKeys(srcObj[locKey], dstObj[locKey], translatedValues);
|
|
132
|
+
} else if (srcObj[locKey] === dstObj[locKey]) {
|
|
133
|
+
const translatedKey = translatedValues[currentTranslationIndex++];
|
|
134
|
+
dstObj[locKey] = translatedKey ? translatedKey : dstObj[locKey];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return dstObj;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function prepareTranslationRequestMsg(wordsToTranslate) {
|
|
142
|
+
// Execute translation for every 50 words in batch
|
|
143
|
+
const result = [];
|
|
144
|
+
const chunk = 50;
|
|
145
|
+
for (let i = 0; i < wordsToTranslate.length; i += chunk) {
|
|
146
|
+
const slicedWords = wordsToTranslate.slice(i, i + chunk);
|
|
147
|
+
const slicedMessages = [];
|
|
148
|
+
// do whatever
|
|
149
|
+
slicedWords.forEach((word) => {
|
|
150
|
+
slicedMessages.push({
|
|
151
|
+
//'text': encodeURI(word)
|
|
152
|
+
'text': word
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
result.push(slicedMessages);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function extranctTranslatedKeys(translatedMsgs) {
|
|
162
|
+
// Flatten the result to retrieve original structure of the keys array
|
|
163
|
+
const translatedKeys = [];
|
|
164
|
+
translatedMsgs.forEach((keys) => {
|
|
165
|
+
keys.forEach((translationMsg) => {
|
|
166
|
+
// There is often a replacement of '||' to ' | | ' during the translation
|
|
167
|
+
// Replace ' | | ' to '||'
|
|
168
|
+
const translationResult = translationMsg.text ? translationMsg.text.replace(" | | ", "||") : translationMsg.text;
|
|
169
|
+
translatedKeys.push(translationResult);
|
|
170
|
+
})
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return translatedKeys;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function executeLocalizationTranslation(srcObj, langObj, lang) {
|
|
177
|
+
try {
|
|
178
|
+
// Initialize result object with all english keys and localized keys
|
|
179
|
+
const dstLoc = Object.assign({}, srcObj, langObj);
|
|
180
|
+
|
|
181
|
+
// Prepare keys to translate
|
|
182
|
+
const keysToTranslate = compareTranslationKeys(srcObj, dstLoc);
|
|
183
|
+
|
|
184
|
+
if (keysToTranslate && keysToTranslate.length <= 0) {
|
|
185
|
+
console.log(`There are no keys to translate`);
|
|
186
|
+
dstLoc;
|
|
187
|
+
}
|
|
188
|
+
console.log(`There are ${keysToTranslate.length} keys to translate.`)
|
|
189
|
+
|
|
190
|
+
// Split the array to separate calls in case max limit of carachters (5000) is reached and execute translation
|
|
191
|
+
const requestMessges = prepareTranslationRequestMsg(keysToTranslate);
|
|
192
|
+
const promises = [];
|
|
193
|
+
requestMessges.forEach((msgBody) => {
|
|
194
|
+
promises.push(executeTranslation(lang, msgBody));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const translatedMsgs = await Promise.all(promises);
|
|
198
|
+
const translatedKeys = extranctTranslatedKeys(translatedMsgs);
|
|
199
|
+
|
|
200
|
+
// Inject translated keys into dstLoc object
|
|
201
|
+
// Reset the global rec counter
|
|
202
|
+
currentTranslationIndex = 0;
|
|
203
|
+
const result = injectTranslatedKeys(srcObj, dstLoc, translatedKeys);
|
|
204
|
+
|
|
205
|
+
return result;
|
|
206
|
+
} catch (err) {
|
|
207
|
+
console.log(`[Exception]: executeLocalizationTranslation : ${err.message}`);
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const run = async () => {
|
|
213
|
+
// Load files in the localization directory
|
|
214
|
+
const locDirPath = path.join(__dirname, '../src/loc');
|
|
215
|
+
let locFiles = fs.readdirSync(locDirPath);
|
|
216
|
+
locFiles = locFiles.filter(f => f !== "mystrings.d.ts" && f != "en-us.ts");
|
|
217
|
+
|
|
218
|
+
// Load main localization file
|
|
219
|
+
const mainLoc = locHelper.getSPLocalizationFileAsJSON('en-us');
|
|
220
|
+
|
|
221
|
+
// Iterate over all supported languages and prepare translation request
|
|
222
|
+
for (const lang of languagesConfiguration.langs) {
|
|
223
|
+
console.log(`Processing ${lang}.`);
|
|
224
|
+
|
|
225
|
+
// If current loc file doesn't exist - copy the original one
|
|
226
|
+
let currentLoc = locHelper.getSPLocalizationFileAsJSON(lang);
|
|
227
|
+
if (!currentLoc) {
|
|
228
|
+
currentLoc = _.cloneDeep(mainLoc);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const translatedObj = await executeLocalizationTranslation(mainLoc, currentLoc, lang);
|
|
232
|
+
// Replace translated part in .ts file
|
|
233
|
+
if (translatedObj) {
|
|
234
|
+
locHelper.replaceTranslatedKeysInJSON(translatedObj, lang)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Set delay to wait for Azure to execute the transation
|
|
238
|
+
console.log(`Finished processing ${lang}`);
|
|
239
|
+
console.log();
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
run();
|
|
243
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scripts exports english localization keys to the .csv file
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const ts = require("typescript");
|
|
8
|
+
require('amd-loader');
|
|
9
|
+
|
|
10
|
+
const jsPlaceholder =
|
|
11
|
+
`declare var define: any;
|
|
12
|
+
|
|
13
|
+
define([], () => {
|
|
14
|
+
return {0};
|
|
15
|
+
});`;
|
|
16
|
+
|
|
17
|
+
const getSPLocalizationFileAsJSON = (locale) => {
|
|
18
|
+
const locFilePath = path.join(__dirname, `../src/loc/${locale}.ts`);
|
|
19
|
+
const tmpLocJSFilePath = path.join(__dirname, `${locale}-tmp.js`);
|
|
20
|
+
|
|
21
|
+
// Localization file doesn't exist
|
|
22
|
+
if (!fs.existsSync(locFilePath)) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Read en-us localization file and transpile if to JS
|
|
27
|
+
// Add named module to avoid amdefine excpetion
|
|
28
|
+
const enLocFileContent = fs.readFileSync(locFilePath, 'utf-8');
|
|
29
|
+
let result = ts.transpileModule(enLocFileContent, { compilerOptions: { module: ts.ModuleKind.CommonJS }});
|
|
30
|
+
|
|
31
|
+
// Create temp JS file
|
|
32
|
+
fs.writeFileSync(tmpLocJSFilePath, result.outputText);
|
|
33
|
+
|
|
34
|
+
var locResources = require(`./${locale}-tmp`);
|
|
35
|
+
|
|
36
|
+
// Remove tmp file
|
|
37
|
+
fs.unlinkSync(tmpLocJSFilePath);
|
|
38
|
+
return locResources;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const replaceTranslatedKeysInJSON = (translatedObj, locale) => {
|
|
42
|
+
const locFilePath = path.join(__dirname, `../src/loc/${locale}.ts`);
|
|
43
|
+
const fileContent = jsPlaceholder.replace('{0}', JSON.stringify(translatedObj, null, 2));
|
|
44
|
+
|
|
45
|
+
// Save file content
|
|
46
|
+
fs.writeFileSync(locFilePath, fileContent);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = { getSPLocalizationFileAsJSON , replaceTranslatedKeysInJSON }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const params = process.argv;
|
|
5
|
+
let token = "";
|
|
6
|
+
let branchName = "";
|
|
7
|
+
if (params && params.length > 0) {
|
|
8
|
+
branchName = params.pop();
|
|
9
|
+
token = params.pop();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const package = fs.readFileSync(path.join(__dirname, "../package.json"), "UTF8");
|
|
13
|
+
let sonarProps = fs.readFileSync(path.join(__dirname, "../sonar-project.properties"), "UTF8");
|
|
14
|
+
if (package && sonarProps) {
|
|
15
|
+
const pkg = JSON.parse(package);
|
|
16
|
+
sonarProps += `sonar.login=${token}\n`;
|
|
17
|
+
sonarProps += `sonar.projectVersion=${pkg.version}\n`;
|
|
18
|
+
sonarProps += `sonar.branch.name=${branchName}\n`;
|
|
19
|
+
fs.writeFileSync(path.join(__dirname, "../sonar-project.properties"), sonarProps, { encoding: "UTF8" })
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const packageJson = require('../package.json');
|
|
4
|
+
packageJson.version += `-beta.${process.argv[process.argv.length-1].substr(0, 7)}`;
|
|
5
|
+
console.log(packageJson.version);
|
|
6
|
+
fs.writeFileSync(path.join(path.resolve('.'), 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
|
|
3
|
+
<ClientSideComponentInstance
|
|
4
|
+
Title="testApp"
|
|
5
|
+
Location="ClientSideExtension.ApplicationCustomizer"
|
|
6
|
+
ComponentId="ca9eac70-7343-4972-88d6-672d50e9cf38"
|
|
7
|
+
Properties="{"testMessage":"Test message"}">
|
|
8
|
+
</ClientSideComponentInstance>
|
|
9
|
+
</Elements>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
|
|
3
|
+
<CustomAction
|
|
4
|
+
Title="testApp"
|
|
5
|
+
Location="ClientSideExtension.ApplicationCustomizer"
|
|
6
|
+
ClientSideComponentId="ca9eac70-7343-4972-88d6-672d50e9cf38"
|
|
7
|
+
ClientSideComponentProperties="{"testMessage":"Test message"}">
|
|
8
|
+
</CustomAction>
|
|
9
|
+
</Elements>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Type definitions for Microsoft ODSP projects
|
|
2
|
+
// Project: ODSP
|
|
3
|
+
|
|
4
|
+
/* Global definition for UNIT_TEST builds
|
|
5
|
+
Code that is wrapped inside an if(UNIT_TEST) {...}
|
|
6
|
+
block will not be included in the final bundle when the
|
|
7
|
+
--ship flag is specified */
|
|
8
|
+
declare const UNIT_TEST: boolean;
|
|
9
|
+
|
|
10
|
+
/* Global defintion for SPO builds */
|
|
11
|
+
declare const DATACENTER: boolean;
|
package/typings/tsd.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="@ms/odsp.d.ts" />
|
package/.hintrc
DELETED
package/.nvmrc
DELETED
|
Binary file
|
package/README.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# SharePoint Framework React Controls
|
|
2
|
-
|
|
3
|
-
This is a open source library that shares a set of reusable React control that can be used in your SharePoint Framework solutions.
|
|
4
|
-
|
|
5
|
-
> If you are looking for web part property controls, please check following repository for those - [https://github.com/pnp/sp-dev-fx-property-controls](https://github.com/pnp/sp-dev-fx-property-controls)
|
|
6
|
-
|
|
7
|
-
## Get Started
|
|
8
|
-
|
|
9
|
-
More information to get started can be found documentation of this repository: [documentation](https://pnp.github.io/sp-dev-fx-controls-react/).
|
|
10
|
-
|
|
11
|
-
# Have issues or questions?
|
|
12
|
-
|
|
13
|
-
Please use following logic on submitting your questions or issues to right location to ensure that they are noticed and addressed as soon as possible.
|
|
14
|
-
|
|
15
|
-
* You have general question or challenge with SPFx - use [sp-dev-docs repository issue list](https://github.com/sharepoint/sp-dev-docs/issues).
|
|
16
|
-
* You have issue on specific controls in this package - use [issue list in this repository](https://github.com/pnp/sp-dev-fx-controls-react/issues).
|
|
17
|
-
|
|
18
|
-
## Contributing
|
|
19
|
-
|
|
20
|
-
We'd love your help! If you have ideas for new features or feedback, let us know by creating an issue in the [issues list](https://github.com/pnp/sp-dev-fx-controls-react/issues). Before you submit a PR with your improvements, please review our [project guides](https://pnp.github.io/sp-dev-fx-controls-react/guides).
|
|
21
|
-
|
|
22
|
-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
23
|
-
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
24
|
-
the rights to use your contribution. For details, visit https://cla.microsoft.com.
|
|
25
|
-
|
|
26
|
-
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
|
|
27
|
-
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
|
|
28
|
-
provided by the bot. You will only need to do this once across all repos using our CLA.
|
|
29
|
-
|
|
30
|
-
## Code of Conduct
|
|
31
|
-
|
|
32
|
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
|
|
33
|
-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
|
|
34
|
-
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
35
|
-
|
|
36
|
-
## "Sharing is Caring"
|
|
37
|
-
|
|
38
|
-
## Disclaimer
|
|
39
|
-
|
|
40
|
-
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|