Skip to content

Commit

Permalink
v10.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Jun 14, 2023
1 parent 672e807 commit 4d78a41
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 67 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "10.1.0",
"version": "10.5.0",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
5 changes: 1 addition & 4 deletions src/GleapConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ export default class GleapConfigManager {
GleapNetworkIntercepter.getInstance().setBlacklist(flowConfig.networkLogBlacklist);
}

if (flowConfig.customTranslations) {
GleapTranslationManager.getInstance().setCustomTranslation(flowConfig.customTranslations);
GleapTranslationManager.getInstance().updateRTLSupport();
}
GleapTranslationManager.getInstance().updateRTLSupport();

Gleap.enableShortcuts(flowConfig.enableShortcuts ? true : false);
} catch (e) { }
Expand Down
4 changes: 1 addition & 3 deletions src/GleapFeedbackButtonManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ export default class GleapFeedbackButtonManager {
}${flowConfig.feedbackButtonPosition === GleapFeedbackButtonManager.FEEDBACK_BUTTON_CLASSIC_BOTTOM
? "bb-feedback-button-classic--bottom"
: ""
}">${GleapTranslationManager.translateText(
flowConfig.widgetButtonText
)}</div>`;
}">${flowConfig.widgetButtonText}</div>`;
} else {
if (buttonIcon !== this.lastButtonIcon) {
this.feedbackButton.innerHTML = `<div class="bb-feedback-button-icon">${buttonIcon}${loadIcon(
Expand Down
24 changes: 12 additions & 12 deletions src/GleapMarkerManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ export default class GleapMarkerManager {
<div class="bb-capture-toolbar-item bb-capture-toolbar-drawingitem" data-type="colorpicker">
<div class="bb-capture-toolbar-item-selectedcolor"></div>
<span class="bb-tooltip">${GleapTranslationManager.translateText(
`Pick a color`
`pickAColor`
)}</span>
</div>
<div class="bb-capture-toolbar-item bb-capture-toolbar-drawingitem bb-capture-toolbar-item-tool" data-type="undo">
${loadIcon("undo")}
<span class="bb-tooltip">${GleapTranslationManager.translateText(
`Undo`
`undo`
)}</span>
</div>
${this.type !== "capture"
? `<div class="bb-capture-button-next">${GleapTranslationManager.translateText(
`Next`
`next`
)}</div>`
: ""
}
Expand All @@ -238,10 +238,10 @@ export default class GleapMarkerManager {
<video controls muted autoplay></video>
<div class="bb-capture-preview-buttons">
<div class="bb-capture-preview-retrybutton">${GleapTranslationManager.translateText(
`Retry`
`retry`
)}</div>
<div class="bb-capture-preview-sendbutton">${GleapTranslationManager.translateText(
`Next`
`next`
)}</div>
</div>
</div>
Expand Down Expand Up @@ -569,21 +569,21 @@ export default class GleapMarkerManager {
"bb-capture-toolbar-item--inactivecross"
);
audioRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Mute"
"mute"
);
} else {
toolbarItem.classList.add(
"bb-capture-toolbar-item--inactivecross"
);
audioRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Unmute"
"unmute"
);
}
} else {
toolbarItem.classList.add(itemInactiveClass);
toolbarItem.classList.add("bb-capture-toolbar-item--inactivecross");
audioRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Browser not supported"
"browserNotSupported"
);
}
break;
Expand All @@ -594,21 +594,21 @@ export default class GleapMarkerManager {
if (this.screenRecorder.isRecording) {
toolbarItem.setAttribute("data-active", "true");
screenRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Stop recording"
"stopRecording"
);
timerLabel.style.display = "block";
} else {
toolbarItem.setAttribute("data-active", "false");
screenRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Start recording"
"stopRecording"
);
timerLabel.style.display = "none";
}
} else {
// Recording is not available.
toolbarItem.classList.add(itemInactiveClass);
screenRecordingTooltip.innerHTML = GleapTranslationManager.translateText(
"Browser not supported"
"browserNotSupported"
);
}
break;
Expand Down Expand Up @@ -643,7 +643,7 @@ export default class GleapMarkerManager {
this.screenRecorder = new GleapScreenRecorder(
this.captureRenderer.bind(this),
GleapTranslationManager.translateText(
"You denied access to screen sharing. Please turn it on in your browser settings."
"accessToScreenSharingDenied"
)
);
}
Expand Down
60 changes: 13 additions & 47 deletions src/GleapTranslationManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { GleapFrameManager, GleapFeedbackButtonManager, GleapSession } from "./Gleap";
import { GleapFrameManager, GleapFeedbackButtonManager, GleapSession, GleapConfigManager } from "./Gleap";

export default class GleapTranslationManager {
customTranslation = {};
overrideLanguage = "";
isRTLLayout = false;

Expand All @@ -28,26 +27,21 @@ export default class GleapTranslationManager {
*/
setOverrideLanguage(language) {
this.overrideLanguage = language;

//GleapFrameManager.getInstance().sendConfigUpdate();
//this.updateRTLSupport();
}

updateRTLSupport() {
// Update RTL support.
this.isRTLLayout = GleapTranslationManager.translateText("rtlLang") === "true";
const flowConfig = GleapConfigManager.getInstance().getFlowConfig();

this.isRTLLayout = false;
if (flowConfig && flowConfig.localizationOptions && flowConfig.localizationOptions.rtl) {
this.isRTLLayout = true;
}

GleapFeedbackButtonManager.getInstance().updateFeedbackButtonState();
GleapFrameManager.getInstance().updateFrameStyle();
}

/**
* Sets the custom translations.
* @param {*} customTranslation
*/
setCustomTranslation(customTranslation) {
this.customTranslation = customTranslation;
}


getActiveLanguage() {
var language = "en";
if (typeof navigator !== "undefined") {
Expand All @@ -61,43 +55,15 @@ export default class GleapTranslationManager {
}

static translateText(key) {
return key;

if (!key) {
return "";
}

const instance = GleapTranslationManager.getInstance();

var language = instance.getActiveLanguage();

const searchForTranslationTable = (langKey) => {
var customTranslation = null;
const translationKeys = Object.keys(instance.customTranslation);
for (var i = 0; i < translationKeys.length; i++) {
const translationKey = translationKeys[i];
if (langKey && translationKey && langKey === translationKey.toLowerCase()) {
if (instance.customTranslation[translationKey]) {
customTranslation = instance.customTranslation[translationKey];
}
}
}

return customTranslation;
}

var customTranslation = searchForTranslationTable(language);

// Extended search for language match only.
if (!customTranslation && language) {
const langKeys = language.split("-");
if (langKeys && langKeys.length > 1) {
customTranslation = searchForTranslationTable(langKeys[0]);
}
}
const flowConfig = GleapConfigManager.getInstance().getFlowConfig();
const staticTranslation = flowConfig.staticTranslations;

if (customTranslation && customTranslation[key]) {
return customTranslation[key];
if (staticTranslation && staticTranslation[key]) {
return staticTranslation[key];
}

return key;
Expand Down

0 comments on commit 4d78a41

Please sign in to comment.