Most of SDK modules depend on localization. This API needs to be exposed to be able to control localization inside the SDK modules
setLocale(langName) : Promise
Changes locale for all SDK components which depend on localization bundle (f.e. Channeling, Feedback)
langName: String |
String containing language (Default: 'en' . Example values are 'en', 'iw', 'ru' ) |
<div id="setLocale-example" style="margin-bottom: 10px;"></div> <button onclick="demoSetLocale()">Init feedback with custom localization</button>
function demoSetLocale() { // host name must be specified nanorep.sdk.init({ host: 'nanorep.nanorep.co' }); // change default locale to Hebrew nanorep.api.i18n.setLocale('he').then(function() { new nanorep.sdk.FeedbackThumbs({}, document.getElementById('setLocale-example')); }); }
defineDictionary(langName, dict) : Promise
This method allows to define new or update existing dictionary. It is not necessary to provide all keys for the dictionary - existing keys will be overridden and new keys will be added to the dictionary
langName: String |
string containing language. Same as here |
dict: Object |
key/value object containing localization strings for specific dictionary. All available keys you can see here |
<div id="defineDictionary-example" style="margin-bottom: 10px;"></div> <button onclick="demoDefineDictionary()">Init feedback with custom like/dislike</button>
function demoDefineDictionary() { // host name must be specified nanorep.sdk.init({ host: 'nanorep.nanorep.co' }); // change default locale to Hebrew nanorep.api.i18n.defineDictionary('he').then(function() { nanorep.api.i18n.defineDictionary('he', { 'thumbs.like': ':)', 'thumbs.dislike': 'Custom "Dislike" button text!' }).then(function() { // create thumbs instance to view the changes new nanorep.sdk.FeedbackThumbs({}, document.getElementById('defineDictionary-example')); }); }); }
getText(key, langName) : String
Get localization value for specific key in dictionary
key: String |
Check here |
langName: Object |
get value for specific value (Optional. If not specified then current locale will be used) |
function switchLocaleAndGetText() { // host name must be specified nanorep.sdk.init({ host: 'nanorep.nanorep.co' }); nanorep.api.i18n.setLocale('he').then(function() { alert(nanorep.api.i18n.getText('sharing.title', 'he')); }); }
<button onclick="switchLocaleAndGetText()">Get sharing title text on Hebrew</button>
{ "search": { "noResults": "No results for \"{QUERY}\". Try a different phrasing or ask an agent.", "noResultsContext": "No answer found for \"{CONTEXT}\". Contact us today and let us know", "resultBasedOn": "Result based on:", "pressEnterToSearch": "Press Enter to search", "clearSearchQuery": "Clear search query", "searchByVoice": "Search by voice", "noSuggestions": "No suggestions are available", "suggestionsAvailable": "Suggestions are available, use up and down arrow keys to navigate", "resultsAvailable": "Search results available, use TAB key to navigate", "start": "Search" }, "thumbs": { "like": "Good answer!", "likeActive": "You like this", "dislike": "Needs improvement", "dislikeActive": "You dislike this", "dialogTitle": "What's wrong with this answer?" }, "sharing": { "title": "Share this answer", "clipboard": "Copy to clipboard", "email": "Share via Email", "facebook": "Share via Facebook", "twitter": "Share via Twitter" }, "survey": { "title": "Was this article helpful?", "thanks": "Thanks!", "yes": "Yes", "no": "No", "submit": "Submit", "dialogTitle": "How can we improve this article?" }, "poweredBy": "Powered by Bold360ai", "ok": "Ok", "cancel": "Cancel", "showMore": "Read more", "showLess": "Show less", "prevSection": "Previous section", "nextSection": "Next section", "feedback": { "missingOrIncorrectInfo": "Content is inaccurate or missing", "irrelevantAnswer": "Answer irrelevant to the page", "missingImportantInfo": "Missing important information", "dismiss": "Close feedback section", "incorrectSearchResult": "Didn't get relevant results", "received": "Thanks for the feedback! Let's continue the conversation", "actionPrompt": "Please describe what is wrong with this answer or continue the conversation", "actionButton": "Give Feedback", "actionClarify": "Please describe the problem with the answer:" }, "ticket": { "chooseFile": "Choose file...", "filesDeleted": "Due to a connection error, your files has been deleted. please upload the files again", "fileBlockedFileSize": "Attachment failed. Max file size is {SIZE} MB.", "fileExtensionBlocked": "File extension {EXTENSION} is not permitted", "fileMaxReached": "You cannot add anymore files", "fileBlocked": "You can't add attachments at this time, please try again later", "submitFailed": "Oops... something went wrong. Please try again later", "postConfirmationText": "Thank you! Your submission has been received.", "dismiss": "Close ticket section", "fileUploading": "Please wait until files are uploaded" }, "translateTo": "Translate to", "backLink": "Back", "widget": { "close": "Close widget", "minimize": "Minimize widget", "expand": "Increase widget size", "reduce": "Decrease widget size", "closePrompt": "Close now?", "confirmClose": "Close", "cancelClose": "Continue" }, "context": { "pleaseSelect": "Please Select", "dialogTitle": "Multiple answers are available. Choose context:", "clear": "Clear" }, "chat": { "end": "End chat", "waiting": "Please wait for an agent...", "agent": "Agent", "bot": "Bot", "visitor": "Visitor", "typing": "is typing...", "unavailable": "Chat is not available", "active": "Chatting with", "starting": "Starting chat session...", "started": "Chat started", "ended": "Chat ended", "log": "Conversation log:", "userQuery": "User query", "sendMessage": "Send message", "incomingMessage": "Incoming message", "messageFrom": "Message from %1", "quickAnswer": "Suggested answer" }, "date": { "today": "Today" }, "call": { "dismiss": "Close call section" } }