/// <summary>
        /// Main activity method
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            var textToTranslate    = Text.Get(context);
            var targetLanguageCode = TargetLanguageCode.Get(context);
            var apiKey             = ApiKey.Get(context);

            if (apiKey != null)
            {
                // Sets to the user's apiKey, if supplied; if not, defaults to a free key
                MicrosoftTranslationClient.ApiKey = apiKey;
            }

            try
            {
                var translatedText         = MicrosoftTranslationClient.TranslateText(textToTranslate, targetLanguageCode);
                var detectedSourceLanguage = MicrosoftTranslationClient.Detect(textToTranslate);

                TranslatedText.Set(context, translatedText);
                DetectedSourceLanguage.Set(context, detectedSourceLanguage);
            }
            catch (System.Exception ex)
            {
                throw new System.Exception($"Actual Error: {ex.Message}\n{MicrosoftTranslationClient.InvalidApiKeyResolution}");
            }
        }
Beispiel #2
0
 void SetLabelTextTo(TranslatedText label, string templateKey)
 {
     if ((label != null) && (string.IsNullOrEmpty(templateKey) == false))
     {
         SetLabelTextTo(label, templateKey, TransitionManager.CurrentScene);
     }
 }
Beispiel #3
0
 public void SetLabelTextToReturnToMenu(TranslatedText label)
 {
     if ((label != null) && (string.IsNullOrEmpty(returnToTextTemplateTranslationKey) == false))
     {
         label.SetTranslationKey(returnToTextTemplateTranslationKey, TransitionManager.MainMenu.DisplayName);
     }
 }
        public static void beginGenericTransaction()
        {
            TranslatedText translatedText = new TranslatedText(new TranslationReference("SDG", "Devkit.Transactions.Generic"));

            translatedText.format();
            DevkitTransactionManager.beginTransaction(translatedText);
        }
Beispiel #5
0
    public override void TStart()
    {
        base.TStart();

        PotionsString = Resources.Load("Translations/Common/Potions", typeof(TranslatedText)) as TranslatedText;
        RingsString   = Resources.Load("Translations/Common/Rings", typeof(TranslatedText)) as TranslatedText;
    }
Beispiel #6
0
    public static void createTranslationAsset(ref TranslatedText translation, string path, string directory, string defaultString)
    {
        //create the directory where the prefab will exists if not created
        if (!Directory.Exists(directory))
        {
            Directory.CreateDirectory(directory);
        }

        //create an empty gameobject but make it inactive
        GameObject go = new GameObject();

        go.AddComponent <TranslatedText>();
        go.active = false;

        //create an empty prefab in the specified path and copy the quest component to the prefab
        Object     p      = PrefabUtility.CreateEmptyPrefab(path);
        GameObject prefab = EditorUtility.ReplacePrefab(go, p, ReplacePrefabOptions.ConnectToPrefab);

        //destroy the gameobject
        GameObject.DestroyImmediate(go);

        //link translation dialog to translation
        translation = prefab.GetComponent <TranslatedText>();
        translation.setText(TranslatedText.LANGUAGES.ENGLISH, defaultString);
        EditorUtility.SetDirty(prefab);
    }
Beispiel #7
0
 void SetLabelTextTo(TranslatedText label, string templateKey, SceneInfo scene)
 {
     if ((label != null) && (string.IsNullOrEmpty(templateKey) == false) && (scene != null))
     {
         label.SetTranslationKey(templateKey, scene.DisplayName);
     }
 }
 // Token: 0x06001043 RID: 4163 RVA: 0x0006B2A2 File Offset: 0x000696A2
 protected virtual void handleTranslationChanged(TranslatedText translation, string text)
 {
     if (this.textComponent == null)
     {
         return;
     }
     this.textComponent.text = text;
 }
 public static void beginTransaction(TranslatedText name)
 {
     if (DevkitTransactionManager.transactionDepth == 0)
     {
         DevkitTransactionManager.clearRedo();
         DevkitTransactionManager.pendingGroup = new DevkitTransactionGroup(name);
     }
     DevkitTransactionManager.transactionDepth++;
 }
Beispiel #10
0
 public void CopyFrom(DialogMessage other)
 {
     teller       = other.teller;
     leftIcon     = other.leftIcon;
     rightIcon    = other.rightIcon;
     text         = other.text;
     translation  = other.translation;
     storyTelling = other.storyTelling;
     alignment    = other.alignment;
 }
Beispiel #11
0
    private void UpdateText(TranslatedText translatedText)
    {
        if (!loadedWords.ContainsKey(translatedText.textTranslationTag))
        {
            translatedText.associatedText.text = translatedText.textTranslationTag;
            return;
        }

        translatedText.associatedText.text = loadedWords[translatedText.textTranslationTag];
    }
Beispiel #12
0
    public override void TStart()
    {
        // Create audio
        BuyString  = Resources.Load("Translations/Common/Buy", typeof(TranslatedText)) as TranslatedText;
        SellString = Resources.Load("Translations/Common/Sell", typeof(TranslatedText)) as TranslatedText;

        go       = Resources.Load("Audio/HudAudio") as GameObject;
        audioHud = go.GetComponent <AudioPool>();

        base.TStart();
        itemsForSelling = new Dictionary <Item, int>();

        inizializeItems();
    }
        private void TextblockGestureRecognizer()
        {
            var recognizer = new GestureRecognizer()
            {
                GestureSettings = GestureSettings.ManipulationScale
            };

            recognizer.ManipulationStarted += (_, __) => ViewModel.TranslatedTextFontSizePitchStart.OnNext(Unit.Default);

            recognizer.ManipulationCompleted += (_, __) => ViewModel.TranslatedTextFontSizePitchCompleted.OnNext(Unit.Default);

            recognizer.ManipulationUpdated += (_, e) =>
            {
                ViewModel.TranslatedTextFontSizePitch.OnNext(e.Cumulative.Scale);
            };

            // Panel has override router event, so we must use AddHandler
            // to add our handler

            TranslatedTextViewer.AddHandler(PointerPressedEvent,
                                            new PointerEventHandler((_, e) =>
            {
                TranslatedText.CapturePointer(e.Pointer);
                recognizer.ProcessDownEvent(e.GetCurrentPoint(TranslatedTextPanel));
            }),
                                            true);

            TranslatedTextViewer.AddHandler(PointerMovedEvent,
                                            new PointerEventHandler((_, e) =>
            {
                recognizer.ProcessMoveEvents(e.GetIntermediatePoints(TranslatedTextPanel));
            }),
                                            true);

            TranslatedTextViewer.AddHandler(PointerReleasedEvent,
                                            new PointerEventHandler((_, e) =>
            {
                recognizer.ProcessUpEvent(e.GetCurrentPoint(TranslatedTextPanel));
                TranslatedText.ReleasePointerCapture(e.Pointer);
            }),
                                            true);

            TranslatedTextViewer.AddHandler(PointerCanceledEvent,
                                            new PointerEventHandler((_, e) =>
            {
                recognizer.CompleteGesture();
                TranslatedText.ReleasePointerCapture(e.Pointer);
            }),
                                            true);
        }
Beispiel #14
0
    public override void TStart()
    {
        TexturePool pool = (Resources.Load("TexturePools/Tutorial") as GameObject).GetComponent <TexturePool>();

        window_texture  = pool.getFromList("tutorial_window");
        hand_texture    = new Texture2D[4];
        hand_texture[0] = pool.getFromList("Hand_tutorial_1");
        hand_texture[1] = pool.getFromList("Hand_tutorial_2");
        hand_texture[2] = pool.getFromList("Hand_tutorial_3");
        hand_texture[3] = pool.getFromList("Hand_tutorial_4");

        openInventoryString           = Resources.Load("Translations/Tutorials/TutEquipment/openInventory", typeof(TranslatedText)) as TranslatedText;
        selectEquipString             = Resources.Load("Translations/Tutorials/TutEquipment/selectEquip", typeof(TranslatedText)) as TranslatedText;
        useEquipString                = Resources.Load("Translations/Tutorials/TutEquipment/useEquip", typeof(TranslatedText)) as TranslatedText;
        waitingToCloseInventoryString = Resources.Load("Translations/Tutorials/TutEquipment/waitingToCloseInventory", typeof(TranslatedText)) as TranslatedText;
    }
Beispiel #15
0
        string GetBuyAllText(int amount)
        {
            if (buyAllTranslation == null)
            {
                buyAllTranslation = buyAllText.GetComponent <TranslatedText>();
            }

            try
            {
                return(buyAllTranslation.GetValue());
            }
            catch
            {
                return("Buy All");
            }
        }
Beispiel #16
0
    public override void OnInspectorGUI()
    {
        TranslatedText text = (TranslatedText)target;

        GUILayout.Label("Languages", EditorStyles.boldLabel);

        for (int i = 0; i < TranslatedText.LANGUAGES_str.Length; i++)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(TranslatedText.LANGUAGES_str[i]);
            text.setText((TranslatedText.LANGUAGES)i, EditorGUILayout.TextArea(text.getText((TranslatedText.LANGUAGES)i), GUILayout.Height(64)));
            if (GUI.changed)
            {
                EditorUtility.SetDirty(text);
            }
            GUILayout.EndHorizontal();
        }
    }
    public override void TStart()
    {
        TexturePool pool = (Resources.Load("TexturePools/Tutorial") as GameObject).GetComponent <TexturePool>();

        window_texture  = pool.getFromList("tutorial_window");
        hand_texture    = new Texture2D[4];
        hand_texture[0] = pool.getFromList("Hand_tutorial_1");
        hand_texture[1] = pool.getFromList("Hand_tutorial_2");
        hand_texture[2] = pool.getFromList("Hand_tutorial_3");
        hand_texture[3] = pool.getFromList("Hand_tutorial_4");

        messagesStrings[0]    = Resources.Load("Translations/Tutorials/TutQuickInventoryPotions/message1", typeof(TranslatedText)) as TranslatedText;
        messagesStrings[1]    = Resources.Load("Translations/Tutorials/TutQuickInventoryPotions/message2", typeof(TranslatedText)) as TranslatedText;
        messagesStrings[2]    = Resources.Load("Translations/Tutorials/TutQuickInventoryPotions/message3", typeof(TranslatedText)) as TranslatedText;
        touchToContinueString = Resources.Load("Translations/Tutorials/TutQuickInventoryPotions/TouchToContinue", typeof(TranslatedText)) as TranslatedText;

        base.TStart();
    }
    static void ImportTranslations()
    {
        string path   = EditorUtility.OpenFilePanel("Load Translation file(csv)", "", "csv");
        int    amount = 0;

        using (StreamReader sr = new StreamReader(path))
        {
            string[] headers = ParseCSVLine(sr.ReadLine());
            while (sr.Peek() != -1)
            {
                string[] values = ParseCSVLine(sr.ReadLine());

                string resName = values[0];

                resName = resName.Substring("Assets/Resources/".Length);
                resName = resName.Substring(0, resName.Length - ".prefab".Length);

                TranslatedText text = Resources.Load(resName, typeof(TranslatedText)) as TranslatedText;

                if (!text)
                {
                    Debug.Log("could not find:" + values[0] + ":" + resName);
                    continue;
                }

                string textToReplace = values[2];

                textToReplace = textToReplace.Replace("\\n", "\n");

                if (text.getText(TranslatedText.LANGUAGES.ENGLISH) != textToReplace)
                {
                    Debug.Log("replacing " + resName);
                    Debug.Log("from:" + text.getText(TranslatedText.LANGUAGES.ENGLISH));
                    Debug.Log("for:" + textToReplace);
                    text.setText(TranslatedText.LANGUAGES.ENGLISH, textToReplace);
                    EditorUtility.SetDirty(text);
                    amount++;
                }
            }
        }

        Debug.Log("imported " + amount + " new strings");
    }
        public static void instantiate(ObjectAsset asset, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (asset == null)
            {
                return;
            }
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(asset.objectName);
            DevkitTransactionManager.beginTransaction(translatedText);
            DevkitHierarchyWorldObject devkitHierarchyWorldObject = LevelObjects.addDevkitObject(asset.GUID, position, rotation, scale, ELevelObjectPlacementOrigin.MANUAL);

            DevkitTransactionUtility.recordInstantiation(devkitHierarchyWorldObject.gameObject);
            DevkitTransactionManager.endTransaction();
        }
        string GetRepairText(int price)
        {
            if (repairTranslation == null)
            {
                repairTranslation = repairText.GetComponent <TranslatedText>();
            }

            string translated;

            try
            {
                translated = repairTranslation.GetValue();
            }
            catch
            {
                translated = "Repair {0}";
            }

            return(string.Format(translated, MoneyFormatter.FormatMoney(price)));
        }
        string GetBuyText(int price)
        {
            if (buyTranslation == null)
            {
                buyTranslation = buyText.GetComponent <TranslatedText>();
            }

            string translated;

            try
            {
                translated = buyTranslation.GetValue();
            }
            catch
            {
                translated = "Buy {0}";
            }

            return(string.Format(translated, MoneyFormatter.FormatMoney(price)));
        }
Beispiel #22
0
        /// <summary>
        /// Get translated text for buying button
        /// </summary>
        /// <param name="amount">how many </param>
        /// <returns>
        /// Example result: "Buy x14"
        /// </returns>
        string GetBuyText(int amount)
        {
            if (buyTranslation == null)
            {
                buyTranslation = buyText.GetComponent <TranslatedText>();
            }

            string translated;

            try
            {
                translated = buyTranslation.GetValue();
            }
            catch
            {
                return(string.Format("Buy x{0}", amount));
            }

            return(string.Format(translated, amount));
        }
Beispiel #23
0
 private void Form1_Load(object sender, EventArgs e)
 {
     if (Properties.Settings.Default.Translate_from == "")
     {
         Properties.Settings.Default.Translate_from = "en";
         Properties.Settings.Default.Translate_to   = "ru";
         Properties.Settings.Default.Save();
     }
     TrayIcon.Icon = Properties.Resources.BookIcon;
     WindowState   = FormWindowState.Minimized;
     Icon          = Properties.Resources.BookIcon;
     ClipboardMonitor.OnClipboardChange += Clip;
     ClipboardMonitor.Start();
     Trans.OnTranslateChange += () => { TranslatedText.BeginInvoke((MethodInvoker)(() => TranslatedText.Text = Trans.TranslatedText)); };
     Trans.OnTranslateChange += () =>
     {
         TrayIcon.BalloonTipTitle = "Перевод скопированного текста";
         TrayIcon.BalloonTipText  = Trans.TranslatedText;
         TrayIcon.ShowBalloonTip(100);
     };
 }
        public static void instantiate(Type type, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(type.Name);
            DevkitTransactionManager.beginTransaction(translatedText);
            IDevkitHierarchySpawnable devkitHierarchySpawnable;

            if (typeof(MonoBehaviour).IsAssignableFrom(type))
            {
                GameObject gameObject = new GameObject();
                gameObject.name = type.Name;
                gameObject.transform.position   = position;
                gameObject.transform.rotation   = rotation;
                gameObject.transform.localScale = scale;
                DevkitTransactionUtility.recordInstantiation(gameObject);
                devkitHierarchySpawnable = (gameObject.AddComponent(type) as IDevkitHierarchySpawnable);
            }
            else
            {
                devkitHierarchySpawnable = (Activator.CreateInstance(type) as IDevkitHierarchySpawnable);
            }
            if (devkitHierarchySpawnable != null)
            {
                devkitHierarchySpawnable.devkitHierarchySpawn();
            }
            IDevkitHierarchyItem devkitHierarchyItem = devkitHierarchySpawnable as IDevkitHierarchyItem;

            if (devkitHierarchyItem != null)
            {
                LevelHierarchy.initItem(devkitHierarchyItem);
            }
            DevkitTransactionManager.endTransaction();
        }
        public List <TranslatedText> getTranslationForText(string sourceText)
        {
            GlobalPayitEntities   entities = new GlobalPayitEntities();
            List <TranslatedText> list     = new List <TranslatedText>();
            List <Translation>    list2    = (from tbl in entities.Translations
                                              where tbl.EnglishText.ToLower().Equals(sourceText.ToLower()) && (tbl.Status == true)
                                              select tbl).ToList <Translation>();

            if (list2 != null)
            {
                foreach (Translation translation in list2)
                {
                    TranslatedText item = new TranslatedText
                    {
                        langCode       = translation.LanguageCode,
                        sourceText     = translation.EnglishText,
                        translatedText = translation.TranslatedText
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #26
0
        public async Task <Domain.Pokemon> TranslateDescription(Domain.Pokemon pokemon)
        {
            if (pokemon == null || pokemon.Description == null || string.IsNullOrWhiteSpace(pokemon.Description.Text))
            {
                return(pokemon);
            }

            TranslationType translationType = _translationTypeDecider.DecideTranslationType(pokemon);
            IReader <TranslationRequest, TranslationResult> translator = _translatorFactory?.Invoke(translationType);
            TranslationRequest translationRequest = new TranslationRequest(translationType, pokemon.Description.Text);

            try
            {
                TranslationResult translatedResult = await translator.Read(translationRequest);

                TranslatedText translatedText = new TranslatedText(translatedResult.Contents.Translated, translationType);
                return(new Domain.Pokemon(pokemon.Name, translatedText, pokemon.Habitat, pokemon.IsLegendary));
            }
            catch
            {
                return(pokemon);
            }
        }
Beispiel #27
0
        public async Task <string> GetToShakespeareTranslationAsync(string text)
        {
            string translationOutput = "";

            if (_httpClient.BaseAddress == null)
            {
                _httpClient.BaseAddress = new Uri("https://api.funtranslations.com/translate/");
            }

            //HTTP Post
            var content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("text", text)
            });

            var responseTask = _httpClient.PostAsync("shakespeare.json/", content);

            responseTask.Wait();

            var result = responseTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = await result.Content.ReadAsStringAsync();

                TranslatedText translation = JsonSerializer.Deserialize <TranslatedText>(readTask);
                if (translation.contents.translation.ToLower() == "shakespeare")
                {
                    translationOutput = translation.contents.translated;
                }
            }
            else if (result.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
            {
                translationOutput = System.Net.HttpStatusCode.TooManyRequests.GetHashCode().ToString();
            }
            return(translationOutput);
        }
Beispiel #28
0
 public void SetLabelTextToNextScene(TranslatedText label)
 {
     SetLabelTextTo(label, nextTextTemplateTranslationKey, TransitionManager.NextScene);
 }
Beispiel #29
0
 public void SetLabelTextToFailedCurrentScene(TranslatedText label)
 {
     SetLabelTextTo(label, failedTextTemplateTranslationKey);
 }
Beispiel #30
0
 public void SetLabelTextToCompletedCurrentScene(TranslatedText label)
 {
     SetLabelTextTo(label, completeTextTemplateTranslationKey);
 }