【发布时间】:2021-09-27 12:18:36
【问题描述】:
我正在尝试将 iframe(Goorgias 实时聊天)翻译成英语以外的其他语言(葡萄牙语、意大利语和西班牙语)。此 iframe 已在网上商店中实现。
有人告诉我准备一个包含 Weglot.translate 函数 (https://developers.weglot.com/javascript/javascript-functions) 值的字典,然后通过覆盖文本值将其传递给聊天。
<script>
var dict = {
"introductionText": "How can we help?",
"offlineIntroductionText": "We'll be back tomorrow",
"actionPostbackError": "An error occurred while processing your action. Please try again.",
"clickToRetry": "Message not delivered. Click to retry.",
"conversationTimestampHeaderFormat": "MMMM D",
"fetchHistory": "Load more",
"fetchingHistory": "Retrieving history...",
"invalidFileError": "Only images are supported. Choose a file with a supported extension (jpg, jpeg, png, gif, or bmp).",
"messageError": "An error occurred while sending your message. Please try again.",
"messageIndicatorTitlePlural": "({count}) New messages",
"messageIndicatorTitleSingular": "({count}) New message",
"messageRelativeTimeDay": "{value}d ago",
"messageRelativeTimeHour": "{value}h ago",
"messageRelativeTimeJustNow": "Just now",
"messageRelativeTimeMinute": "{value}m ago",
"messageTimestampFormat": "h:mm A",
"messageSending": "Sending...",
"messageDelivered": "Delivered",
"tapToRetry": "Message not delivered. Tap to retry.",
"unsupportedMessageType": "Unsupported message type.",
"unsupportedActionType": "Unsupported action type.",
"headerText": "Gorgias Team",
"inputPlaceholder": "Type a message...",
"emailCapturePlaceholder": "your@email.com",
"emailCaptureInputLabel": "Get notified by email",
"emailCaptureOnlineTriggerText": "Leave us your email and we will reply soon.",
"emailCaptureOnlineThanksText": "Thanks! We'll email you at {email} if you leave.",
"emailCaptureOfflineTriggerText": "We're away, leave us your email and we'll respond shortly.",
"emailCaptureOfflineThanksText": "Thanks {email}! We'll get back to you shortly.",
"emailCaptureRequiredEmailPlaceholder": "Leave your email",
"emailCaptureRequiredMessagePlaceholder": "Write your message",
"backLabelBackInAMinute": "Back in 1 minute",
"backLabelBackInMinutes": "Back in {value} minutes",
"backLabelBackInAnHour": "Back in 1 hour",
"backLabelBackInHours": "Back in {value} hours",
"backLabelBackInDays": "Back in {value} days",
"backLabelBackTomorrow": "Back tomorrow",
"campaignClickToReply": "Click to reply",
"poweredByGorgias": "Powered by Gorgias",
"send": "Send"
}
var gorgiasChatInterval = window.setInterval(function() {
if (window.GorgiasChat && GorgiasChat.hasOwnProperty("updateTexts")) {
window.clearInterval(gorgiasChatInterval); // this line breaks out of the loop - make sure it's not deleted.
window.GORGIAS_CHAT_TEXTS = dict
GorgiasChat.updateTexts(dict)
}
}, 100);
</script>
(这是包含聊天文本的字典)
我该怎么写?
谢谢, 卡罗莱纳州
【问题讨论】:
-
有什么问题?看起来你只是改变
"introductionText": "Comment pouvons nous aider?",等等 -
对,但是我需要的是根据网站的子域来改变内容。假设对于 fr.website.com,我们将有“introductionText”:“Comment pouvons nous aider?”对于 pt.website.com,我们会有 "introductionText": "Como posso ajudar?"等等。而且我需要根据我们所在的子域来更改 iframe 的内容。
-
这是您问题中相当重要的缺失信息。
-
为什么不使用built-in languages
-
很遗憾,它不适用于不同的子域,只能用于不同的域。
标签: javascript dictionary iframe language-translation