123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /*
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- * All rights reserved.
- *
- * This source code is licensed under the license found in the
- * LICENSE file in the root directory of this source tree.
- */
- using UnityEngine;
- namespace Meta.WitAi
- {
- public static class WitTexts
- {
- // Localized text
- public static WitText Texts;
- [System.Serializable]
- public struct WitText
- {
- [Header("Shared Settings Texts")]
- public string LanguageID;
- public string WitAppsUrl;
- public string WitAppSettingsEndpoint;
- public string WitAppUnderstandingEndpoint;
- public string WitOpenButtonLabel;
- public string WitDocsTitle;
- public string WitDocsUrl;
- public string VLogLevelLabel;
- public string ConfigurationFileManagerLabel;
- public string ConfigurationFileNameLabel;
- public string ConfigurationSelectLabel;
- public string ConfigurationSelectMissingLabel;
- [Header("Setup Settings Texts")]
- public string SetupTitleLabel;
- public string SetupSubheaderLabel;
- public string SetupServerTokenLabel;
- public string SetupServerTokenVerifyLabel;
- public string SetupServerTokenVerifyWarning;
- public string SetupClientTokenWarningLabel;
- public string SetupSubmitButtonLabel;
- public string SetupSubmitFailLabel;
- [Header("Understanding Viewer Texts")]
- public string UnderstandingViewerLabel;
- public string UnderstandingViewerMissingConfigLabel;
- public string UnderstandingViewerMissingClientTokenLabel;
- public string UnderstandingViewerServicesLabel;
- public string UnderstandingViewerMissingServicesLabel;
- public string UnderstandingViewerSettingsButtonLabel;
- public string UnderstandingViewerUtteranceLabel;
- public string UnderstandingViewerPromptLabel;
- public string UnderstandingViewerSubmitButtonLabel;
- public string UnderstandingViewerActivateButtonLabel;
- public string UnderstandingViewerDeactivateButtonLabel;
- public string UnderstandingViewerAbortButtonLabel;
- public string UnderstandingViewerListeningLabel;
- public string UnderstandingViewerLoadingLabel;
- public string UnderstandingViewerSelectLabel;
- [Header("Settings Texts")]
- public string SettingsTitleLabel;
- public string SettingsServerTokenLabel;
- public string SettingsServerTokenTooltip;
- public string SettingsRelinkButtonLabel;
- public string SettingsAddButtonLabel;
- public string SettingsAddMainButtonLabel;
- [Header("Configuration Texts")]
- public string ConfigurationHeaderLabel;
- public string ConfigurationRefreshButtonLabel;
- public string ConfigurationRefreshingButtonLabel;
- public string ConfigurationServerTokenLabel;
- public string ConfigurationClientTokenLabel;
- public string ConfigurationRequestTimeoutLabel;
- [Header("Configuration Endpoint Texts")]
- public string ConfigurationEndpointTitleLabel;
- public string ConfigurationEndpointUriLabel;
- public string ConfigurationEndpointAuthLabel;
- public string ConfigurationEndpointPortLabel;
- public string ConfigurationEndpointApiLabel;
- public string ConfigurationEndpointSpeechLabel;
- public string ConfigurationEndpointMessageLabel;
- public string ConfigurationEndpointDictationLabel;
- public string ConfigurationEndpointSynthesizeLabel;
- public string ConfigurationEndpointComposerEventLabel;
- public string ConfigurationEndpointComposerConverseLabel;
- [Header("Configuration Application Texts")]
- public string ConfigurationApplicationTabLabel;
- public string ConfigurationApplicationMissingLabel;
- public string ConfigurationApplicationNameLabel;
- public string ConfigurationApplicationIdLabel;
- public string ConfigurationApplicationLanguageLabel;
- public string ConfigurationApplicationPrivateLabel;
- public string ConfigurationApplicationCreatedLabel;
- [Header("Configuration Application Training Texts")]
- public string ConfigurationApplicationTrainingStatus;
- public string ConfigurationApplicationTrainingLast;
- public string ConfigurationApplicationTrainingLastDuration;
- public string ConfigurationApplicationTrainingNext;
- [Header("Configuration Conduit Texts")]
- public string ConfigurationConduitMissingTokenLabel;
- [Header("Configuration Intent Texts")]
- public string ConfigurationIntentsTabLabel;
- public string ConfigurationIntentsMissingLabel;
- public string ConfigurationIntentsIdLabel;
- public string ConfigurationIntentsEntitiesLabel;
- [Header("Configuration Entity Texts")]
- public string ConfigurationEntitiesTabLabel;
- public string ConfigurationEntitiesMissingLabel;
- public string ConfigurationEntitiesIdLabel;
- public string ConfigurationEntitiesLookupsLabel;
- public string ConfigurationEntitiesRolesLabel;
- public string ConfigurationEntitiesKeywordsLabel;
- [Header("Configuration Trait Texts")]
- public string ConfigurationTraitsTabLabel;
- public string ConfigurationTraitsMissingLabel;
- public string ConfigurationTraitsIdLabel;
- public string ConfigurationTraitsValuesLabel;
- [Header("Configuration Voice Texts")]
- public string ConfigurationVoicesTabLabel;
- public string ConfigurationVoicesMissingLabel;
- [Header("Configuration Composer Texts")]
- public string ConfigurationComposerTabLabel;
- public string ConfigurationComposerMissingLabel;
- [Header("Tooltip Texts")]
- public string ShowTooltipsLabel;
- }
- // Wit
- public const string WitUrl = "https://wit.ai";
- // Endpoint
- public enum WitAppEndpointType
- {
- Settings,
- Understanding
- }
- // Title Contents
- public static Texture2D HeaderIcon;
- public static Texture2D TitleIcon;
- public static GUIContent SetupTitleContent;
- public static GUIContent UnderstandingTitleContent;
- public static GUIContent SettingsTitleContent;
- public static GUIContent SettingsServerTokenContent;
- public static GUIContent ConfigurationServerTokenContent;
- public static GUIContent ConfigurationClientTokenContent;
- public static GUIContent ConfigurationRequestTimeoutContent;
- // Init
- static WitTexts()
- {
- // Get text
- string languageID = "en-us";
- string textFilePath = $"witai_texts_{languageID}";
- TextAsset textAsset = Resources.Load<TextAsset>(textFilePath);
- if (textAsset == null)
- {
- VLog.E($"WitStyles - Add localization to Resources/{textFilePath}\nLanguage: {languageID}");
- return;
- }
- Texts = JsonUtility.FromJson<WitText>(textAsset.text);
- // Setup titles
- HeaderIcon = (Texture2D) Resources.Load("wit-ai-title");
- TitleIcon = (Texture2D) Resources.Load("witai");
- SetupTitleContent = new GUIContent(WitTexts.Texts.SetupTitleLabel, TitleIcon);
- SettingsTitleContent = new GUIContent(WitTexts.Texts.SettingsTitleLabel, TitleIcon);
- SettingsServerTokenContent = new GUIContent(WitTexts.Texts.SettingsServerTokenLabel, WitTexts.Texts.SettingsServerTokenTooltip);
- UnderstandingTitleContent = new GUIContent(WitTexts.Texts.UnderstandingViewerLabel, TitleIcon);
- ConfigurationServerTokenContent = new GUIContent(WitTexts.Texts.ConfigurationServerTokenLabel);
- ConfigurationClientTokenContent = new GUIContent(WitTexts.Texts.ConfigurationClientTokenLabel);
- ConfigurationRequestTimeoutContent = new GUIContent(WitTexts.Texts.ConfigurationRequestTimeoutLabel);
- }
- // Get urls
- public static string GetAppURL(string appId, WitAppEndpointType endpointType)
- {
- // Return apps url without id
- string url = WitUrl + Texts.WitAppsUrl;
- if (string.IsNullOrEmpty(appId))
- {
- return url;
- }
- // Determine endpoint
- string endpoint;
- switch (endpointType)
- {
- case WitAppEndpointType.Understanding:
- endpoint = Texts.WitAppUnderstandingEndpoint;
- break;
- case WitAppEndpointType.Settings:
- endpoint = Texts.WitAppSettingsEndpoint;
- break;
- default:
- endpoint = Texts.WitAppSettingsEndpoint;
- break;
- }
- // Ensure endpoint is set
- if (string.IsNullOrEmpty(endpoint))
- {
- return url;
- }
- // Replace app id key with desired app id
- endpoint = endpoint.Replace("[APP_ID]", appId);
- // Return full url
- return url + endpoint;
- }
- }
- }
|