Example #1
0
    public void SetSettingsTitleText(LocalisedText key)
    {
        LocalisedText lt = titleText.GetComponent <LocalisedText>();

        lt.key = key.key;
        lt.SetText();
    }
        public void AfterTest()
        {
            _localisableUIText = null;
            _localisedText     = null;

            LocalisationManager.CurrentLocalisationInterface = null;
            _localisationInterface = null;
        }
Example #3
0
        public void LocalisedText_NoEntryForKey_ReturnsTextConstant()
        {
            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.German, "TEST")
            };

            var localisedText = new LocalisedText(new LocalisedTextEntries(entries));

            Assert.IsTrue(localisedText.ToString().Equals(LocalisedTextConstants.DefaultLocalisedTextEntry));
        }
    void Awake()
    {
        title = GetComponent <LocalisedText>();

        if (App.activeFile != null)
        {
            OnShowContent(App.activeFile);
        }

        Signals.Get <ShowContentSignal>().AddListener(OnShowContent);
    }
Example #5
0
        public void LocalisedText_DefaultLanguageIsEnglishUK()
        {
            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.German, "TEST"),
                new LocalisedTextEntry(ELanguageOptions.EnglishUK, "OTHERTEST")
            };

            var localisedText = new LocalisedText(new LocalisedTextEntries(entries));

            Assert.AreEqual(ELanguageOptions.EnglishUK, localisedText.CurrentLanguage);
        }
Example #6
0
    public void ReturnToTitleWithSkipText()
    {
        LocalisedText childText = gameObject.transform.Find("Text").gameObject.GetComponent <LocalisedText>();

        if (childText.IsCurrentlyAnimating == true)
        {
            childText.SkipAnimation();
        }
        else
        {
            SceneManager.LoadScene("InitialLoad");
        }
    }
Example #7
0
        public void LocalisedText_ToString_UsesCurrentLanguage()
        {
            var expectedEntry = new LocalisedTextEntry(ELanguageOptions.EnglishUK, "OTHERTEST");

            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.German, "TEST"),
                expectedEntry
            };

            var localisedText = new LocalisedText(new LocalisedTextEntries(entries));

            Assert.IsTrue(localisedText.ToString().Equals(expectedEntry.TranslatedText));
        }
Example #8
0
        public void LocalisedTextWithListOfLocalisedTextEntries_ConvertsToExpectedDictionary()
        {
            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.German, "TEST"),
                new LocalisedTextEntry(ELanguageOptions.EnglishUK, "OTHERTEST")
            };

            var localisedText = new LocalisedText(new LocalisedTextEntries(entries));

            foreach (var entry in entries)
            {
                Assert.IsTrue(localisedText.LocalisedTexts.ContainsKey(entry.LanguageOption));
                Assert.IsTrue(localisedText.LocalisedTexts[entry.LanguageOption].Equals(entry.TranslatedText));
            }
        }
        public void LocalisationComponent_GetTextForLocalisationKey_ReturnsTextWithExpectedSettings()
        {
            _localisationComponent.TestAwake();

            const ELanguageOptions expectedLanguage = ELanguageOptions.German;

            _localisationComponent.SetCurrentLanguage(expectedLanguage);

            var generatedText = _localisationComponent.GetTextForLocalisationKey(_localisedText.LocalisedDatabase[0].TextKey);

            var expectedText = new LocalisedText(_localisedText.LocalisedDatabase[0].LocalisedTexts);

            expectedText.CurrentLanguage = expectedLanguage;

            Assert.IsTrue(expectedText.ToString().Equals(generatedText.ToString()));
        }
        public void BeforeTest()
        {
            _localisationInterface = new MockLocalisationInterface();
            LocalisationManager.CurrentLocalisationInterface = _localisationInterface;

            _localisedText = new LocalisedText(new LocalisedTextEntries {
                Entries = new List <LocalisedTextEntry>
                {
                    new LocalisedTextEntry(ELanguageOptions.EnglishUK, "TEXTYTEXT"),
                    new LocalisedTextEntry(ELanguageOptions.German, "OtherTextyText")
                }
            });

            _localisationInterface.GetTextForLocalisationKeyResult = _localisedText;

            _localisableUIText = new GameObject().AddComponent <TestLocalisableUIText>();
        }
    /// <summary> Checks for all localised objects on the scene and updates them to the current language. </summary>
    private void UpdateLocalisedObjects()
    {
        if (!CheckAssets())
        {
            return;
        }

        if (OnGUIupdate != null)
        {
            OnGUIupdate.Invoke();
        }

        foreach (ILocalisedObject localisedObject in localisedObjectsInScene)
        {
            if (string.IsNullOrEmpty(localisedObject.Key))
            {
                Debug.LogWarningFormat("Localised Object '{0}' has no key.", localisedObject.gameObject.name);
                continue;
            }

            if (localisedObject.Type == EntryType.Text)
            {
                LocalisedText localisedText = (LocalisedText)localisedObject;
                localisedText.Set(GetLocalisedText(localisedObject.Key));
            }
            else if (localisedObject.Type == EntryType.Image)
            {
                LocalisedImage localisedImage = (LocalisedImage)localisedObject;
                localisedImage.Set(GetLocalisedImage(localisedObject.Key));
            }
            else if (localisedObject.Type == EntryType.Audio)
            {
                LocalisedAudio localisedAudio = (LocalisedAudio)localisedObject;
                localisedAudio.Set(GetLocalisedAudio(localisedObject.Key));
            }
            else
            {
                Debug.LogWarningFormat("No required component found on '{0}'. Check if components are being removed.", localisedObject.gameObject.name);
                continue;
            }
        }
    }
 private void OnEnable()
 {
     _text             = target as LocalisedText;
     _propertyKey      = serializedObject.FindProperty("_key");
     _propertyLanugage = serializedObject.FindProperty("_previewLanguage");
 }