private void UpdateFont(TranslationManager parser)
 {
     if (parser != null)
     {
         TranslationManager.FontMap map = parser.CurrentLanguageFont;
         if (map != null)
         {
             UpdateFont(map, fontKey);
         }
     }
 }
Example #2
0
        private string GetTextFromTranslationManager()
        {
            string returnString = null;

            // Check if the TranslationManager is ready
            TranslationManager manager = Singleton.Get <TranslationManager>();

            if ((manager != null) && (manager.IsReady == true))
            {
                returnString = ToString(manager.CurrentLanguage);
            }
            return(returnString);
        }
 private void Setup()
 {
     if (CurrentState == State.NeedSetup)
     {
         CurrentState = State.WaitingForSetup;
         TranslationManager.RunWhenReady(SetupLabelNow);
     }
     else if (CurrentState == State.NeedUpdate)
     {
         CurrentState = State.WaitingForUpdate;
         UpdateLabelNow(Parser);
     }
 }
        private void SetupLabelNow(TranslationManager parser)
        {
            // Confirm the parser is ready
            if ((parser != null) && (parser.IsReady == true))
            {
                // Unbind to the last event
                OnDestroy();

                // Bind to the parser's event
                languageChangedEvent           = new TranslationManager.LanguageChanged(AfterLanguageChanged);
                parser.OnAfterLanguageChanged += languageChangedEvent;
            }

            // Update the label
            UpdateLabelNow(parser);
        }
 public static void RunWhenReady(System.Action <TranslationManager> setupMethod)
 {
     // Make sure there's an actual method to push to the event list
     if (setupMethod != null)
     {
         // First verify that an instance of TranslationManager exists,
         // and it's ready for use.
         TranslationManager singleton = Singleton.Get <TranslationManager>();
         if ((singleton != null) && (singleton.IsReady == true))
         {
             // If the translation manager is ready,
             // run the setup method immediately
             setupMethod(singleton);
         }
         else
         {
             // If not, push the method to the events list
             OnReady += setupMethod;
         }
     }
 }
        private void UpdateLabelNow(TranslationManager parser)
        {
            // Confirm the parser is ready
            if (IsTranslating == true)
            {
                // Check if the original string needs to be updated
                if (string.IsNullOrEmpty(cacheString) == true)
                {
                    // Update the original string
                    cacheString = DisplayString;
                }

                // Set the label's text
                LabelText = cacheString;

                // Set the label's font
                UpdateFont(parser);

                // Indicate the label has been updated
                CurrentState = State.Ready;
            }
        }
 private void AfterLanguageChanged(TranslationManager source, string lastLanguage, string currentLanguage)
 {
     // Repaint the label
     RepaintLabel();
 }