{
"path": "/ml-dest",
"target": {
"type": "destination",
"name": "ML_API"
},
"description": "SAP Leonardo Machine Learning API's"
}
],
"sendWelcomeFileRedirect": true,
"headerWhiteList": [
"APIKey"
]
}
{
"url_featureextraction": "/ml-dest/feature-extraction",
"url_similarityscoring": "/ml-dest/similarity-scoring",
"method": "POST",
"accept": "application/json",
"fileType": "zip,tar",
"mimeType": "application/x-zip-compressed,application/zip,application/octet-stream",
"APIKey":"<Provide here Unique API Key>"
}
{
"Languages": [
{
"Code": "en",
"Name": "English"
},
{
"Code": "pt",
"Name": "Portuguese"
},
{
"Code": "fr",
"Name": "French"
},
{
"Code": "es",
"Name": "Spanish"
},
{
"Code": "hi",
"Name": "Hindi"
},
{
"Code": "zh",
"Name": "Chinese"
}
]
}
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "ML.PRACTICE.i18n.i18n"
}
},
"ml_apikey": {
"type": "sap.ui.model.json.JSONModel",
"preload": true,
"uri": "model/ml_apikey.json"
},
"Languages": {
"type": "sap.ui.model.json.JSONModel",
"preload": true,
"uri": "model/Languages.json"
},
<Page showHeader="false">
<content>
<tnt:ToolHeader>
<!--<Button icon="sap-icon://nav-back" type="Transparent" press="onNavBack"/>-->
<Label text="ML Translation" design="Bold" wrapping="false"/>
<ToolbarSpacer/>
<Label text="Languages"/>
<Select id="selectLanguages" change="OnSelect" items="{ path: 'Languages>/Languages',sorter: { path: ' Languages>Name' } }">
<core:Item key="{Languages>Code}" text="{Languages>Name}"/>
</Select>
</tnt:ToolHeader>
<f:SimpleForm id="idSimpleFormChange" editable="true" layout="ResponsiveGridLayout" title="{i18n>address}" labelSpanXL="4"
labelSpanL="3" labelSpanM="4" labelSpanS="12" adjustLabelSpan="false" emptySpanXL="0" emptySpanL="4" emptySpanM="0" emptySpanS="0"
columnsXL="2" columnsL="1" columnsM="1" singleContainerFullSize="false">
<f:content>
<Label id="idFullname" text="{i18n>Fullname}"/>
<Input id="name" value=""/>
<Label id="idAdd" text="{i18n>Address}"/>
<Input value=""></Input>
<Input value="">
<layoutData>
<l:GridData span="XL1 L2 M2 S4"/>
</layoutData>
</Input>
<Label id="idZipcode" text="{i18n>ZIPCodeCity}"/>
<Input value="">
<layoutData>
<l:GridData span="XL1 L2 M2 S4"/>
</layoutData>
</Input>
<Input value=""/>
</f:content>
</f:SimpleForm>
</content>
<footer>
<Bar id="idFooterBar">
<contentLeft>
<Button icon="sap-icon://hint" type="Ghost" press="onInfopress"/>
<ToggleButton id="idBHeaderToggle" icon="sap-icon://expand" tooltip="Show/Hide Header" type="Transparent" enabled="true" pressed="true"
press="onHeaderPress"/>
</contentLeft>
<contentRight>
<Button id="idContinue" text="{i18n>continue}" icon="sap-icon://step" press="onPressSearch" type="Emphasized"/>
<Button id="idBClear" text="{i18n>exit}" icon="sap-icon://system-exit-2" press="onPressClear" type="Transparent"/>
</contentRight>
</Bar>
</footer>
</Page>
title=Title
Fullname=Full name of the contact
Address=Street and number where the contact is located
ZIPCodeCity=ZIP Code and City
continue=Continue
exit=Exit
address= Address
OnSelect: function () {
var that = this;
var i18nModel01 = that.getOwnerComponent().getModel("i18n").getResourceBundle();
var SourceText1 = i18nModel01.getText("Fullname");
var SourceText2 = i18nModel01.getText("Address");
var SourceText3 = i18nModel01.getText("ZIPCodeCity");
var SourceText4 = i18nModel01.getText("continue");
var SourceText5 = i18nModel01.getText("exit");
var SourceText6 = i18nModel01.getText("address");
var SourceID1 = "idFullname";
var SourceID2 = "idAdd";
var SourceID3 = "idZipcode";
var SourceID4 = "idContinue";
var SourceID5 = "idBClear";
var SourceID6 = "idSimpleFormChange";
var Array = [
[SourceText1, SourceID1],
[SourceText2, SourceID2],
[SourceText3, SourceID3],
[SourceText4, SourceID4],
[SourceText5, SourceID5],
[SourceText6, SourceID6]
];
if (this.getView().byId("selectLanguages").getSelectedItem().getKey() !== "en") {
if (Array) {
for (var i = 0; i < Array.length; i++) {
that._translateText(Array[i][1], Array[i][0]);}}}
else {
for (var i = 0; i < Array.length; i++) {
that.getView().byId(Array[i][1]).setText(Array[i][0]);
}
}
},
_translateText: function (FieldID, Value) {
var that = this;
var apiKey = this.getView().getModel("ml-apikey").getProperty("/APIKey");
var sLanguage = this.getView().byId("selectLanguages").getSelectedItem().getKey();
var data = JSON.stringify({
"sourceLanguage": "en",
"targetLanguages": [
sLanguage
],
"units": [{
"value": Value,
"key": "TEXT"
}]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
var sTranslatedText = JSON.parse(this.responseText).units[0].translations[0].value;
that.getView().byId(FieldID).setText(sTranslatedText);
}
});
xhr.open("POST", "/ml-dest/translation/translation");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("APIKey", apiKey);
xhr.send(data);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |