Example #1
0
        public static string Translate(StringID id, Control defaultevent = null) //Csak akkor kell az event, ha látszódik az adott ablak, amikor átállítódik - Tehát csak MainForm és ChatForm
        {                                                                        //2014.08.19.
            if (CurrentLanguage == null)
            {                                                                    //2015.05.22.
                if (Language.Languages.Any(entry => entry.LanguageKey == "en"))
                {
                    MessageBox.Show("Error: The specified language (" + Storage.Settings[SettingType.Lang] + ") is not found.\nThe program will use english that you can change later.");
                    CurrentLanguage = Languages.FirstOrDefault(entry => entry.LanguageKey == "en"); //Single-->FirstOrDefault: 2015.06.06.
                }
                else
                {
                    throw new FileNotFoundException("This is just so it will use English when downloading languages...");
                }
            }
            string strid = id.ToString().ToLower();

            if (CurrentLanguage.Strings.ContainsKey(strid))
            {
                if (defaultevent != null) //2014.12.22.
                {
                    ReloadEvent += delegate { defaultevent.Text = CurrentLanguage.Strings[strid]; }
                }
                ;                                                                                    //2014.12.22.
                return(CurrentLanguage.Strings[strid]);
            }
            else
            {
                MessageBox.Show("Translation string not found: " + strid + "\nIn file: " + CurrentLanguage.FileName); //CurrentLanguage.FileName: 2015.05.22.
                return("Str not found (" + strid + ")");                                                              //id: 2015.04.03.
            }
        }
 private static string SafeGetString(StringID id)
 {
     if (strings.ContainsKey(id))
     {
         return strings[id];
     }
     return id.ToString();
 }
Example #3
0
 private static string SafeGetString(StringID id)
 {
     if (strings.ContainsKey(id))
     {
         return(strings[id]);
     }
     return(id.ToString());
 }
Example #4
0
        // Returns the translated string, or a string representation of the
        // string ID if the translation isn't available.
        public String GetTranslatedString(StringID sid)
        {
            string retval;

            retval = translationFile.getValue(sid.ToString(), "");

            // Check the default translation if string is not found in the loaded translation
            if (String.IsNullOrEmpty(retval))
            {
                retval = defaultFile.getValue(sid.ToString(), "");
            }

            // If it's not found in the default, return a placeholder string
            if (String.IsNullOrEmpty(retval))
            {
                retval = "%" + sid.ToString() + "%";
            }

            return(retval);
        }
Example #5
0
        // Returns true if the loaded translation file contains all expected
        // string IDs, or false if not.
        public bool IsComplete()
        {
            bool retval = true;

            for (StringID sid = (StringID)0; sid < StringID.TOTAL_COUNT; sid++)
            {
                if (translationFile.getValue(sid.ToString(), (String)null) == null)
                {
                    retval = false;
                    break;
                }
            }

            return(retval);
        }
        // Returns the translated string, or a string representation of the
        // string ID if the translation isn't available.
        public String GetTranslatedString(StringID sid)
        {
            string retval;
            retval = translationFile.getValue(sid.ToString(), "");

            // Check the default translation if string is not found in the loaded translation
            if (String.IsNullOrEmpty(retval))
            {
                retval = defaultFile.getValue(sid.ToString(), "");
            }

            // If it's not found in the default, return a placeholder string
            if (String.IsNullOrEmpty(retval))
            {
                retval = "%" + sid.ToString() + "%";
            }

            return retval;
        }