Beispiel #1
0
        public static Dictionary <string, string> GetTexts(MyLanguagesEnum language, Dictionary <MyLanguagesEnum, Dictionary <string, string> > translations, Logging log = null)
        {
            var texts = new Dictionary <string, string>();

            var fallbackTranslation = translations[MyLanguagesEnum.English]; //Should be a complete set (all possible entries)
            Dictionary <string, string> requestedTranslation;

            if (language == MyLanguagesEnum.English || !translations.TryGetValue(language, out requestedTranslation))
            {
                requestedTranslation = null;
            }

            foreach (var kv in fallbackTranslation)
            {
                string translation;
                if (requestedTranslation == null || !requestedTranslation.TryGetValue(kv.Key, out translation))
                {
                    if (language != MyLanguagesEnum.English && log != null && log.ShouldLog(Logging.Level.Error))
                    {
                        log.Write(Logging.Level.Error, "Missing translation in language={0} for key={1}", language, kv.Key);
                    }
                    translation = kv.Value;
                }
                texts.Add(kv.Key, translation);
            }
            return(texts);
        }
Beispiel #2
0
        private static void AddLanguage(MyLanguagesEnum id, string cultureName, string subcultureName = null, string displayName = null, float guiTextScale = 1f, bool isCommunityLocalized = true)
        {
            var language = new LanguageDescription(id, displayName, cultureName, subcultureName, guiTextScale, isCommunityLocalized);

            m_languageIdToLanguage.Add((int)id, language);
            m_cultureToLanguageId.Add(language.FullCultureName, (int)id);
        }
 private static void LoadLanguage(MyLanguagesEnum value)
 {
     var language = MyTexts.Languages[(int)value];
     MyTexts.Clear();
     MyTexts.LoadTexts(GetLocalizationPath(), language.CultureName, language.SubcultureName);
     MyGuiManager.LanguageTextScale = language.GuiTextScale;
     m_actualLanguage = value;
 }
Beispiel #4
0
        private static void LoadLanguage(MyLanguagesEnum value)
        {
            var language = MyTexts.Languages[(int)value];

            MyTexts.Clear();
            MyTexts.LoadTexts(GetLocalizationPath(), language.CultureName, language.SubcultureName);
            MyGuiManager.LanguageTextScale = language.GuiTextScale;
            m_actualLanguage = value;
        }
Beispiel #5
0
 internal LanguageDescription(MyLanguagesEnum id, string displayName, string cultureName, string subcultureName, float guiTextScale, bool isCommunityLocalized)
 {
     Id = id;
     Name = displayName;
     CultureName = cultureName;
     SubcultureName = subcultureName;
     if (string.IsNullOrWhiteSpace(subcultureName))
         FullCultureName = cultureName;
     else
         FullCultureName = string.Format("{0}-{1}", cultureName, subcultureName);
     IsCommunityLocalized = isCommunityLocalized;
     GuiTextScale = guiTextScale;
 }
Beispiel #6
0
 internal LanguageDescription(MyLanguagesEnum id, string displayName, string cultureName, string subcultureName, float guiTextScale, bool isCommunityLocalized)
 {
     Id = id;
     Name = displayName;
     CultureName = cultureName;
     SubcultureName = subcultureName;
     if (string.IsNullOrWhiteSpace(subcultureName))
         FullCultureName = cultureName;
     else
         FullCultureName = string.Format("{0}-{1}", cultureName, subcultureName);
     IsCommunityLocalized = isCommunityLocalized;
     GuiTextScale = guiTextScale;
 }
        // Reflection copy of MyTexts.AddLanguage
        private static void AddLanguage(MyLanguagesEnum id, string cultureName, string subcultureName = null, string displayName = null, float guiTextScale = 1f, bool isCommunityLocalized = true)
        {
            // Create an empty instance of LanguageDescription.
            MyTexts.MyLanguageDescription languageDescription = ReflectionUtil.ConstructPrivateClass <MyTexts.MyLanguageDescription>(
                new Type[] { typeof(MyLanguagesEnum), typeof(string), typeof(string), typeof(string), typeof(float), typeof(bool) },
                new object[] { id, displayName, cultureName, subcultureName, guiTextScale, isCommunityLocalized });

            Dictionary <MyLanguagesEnum, MyTexts.MyLanguageDescription> m_languageIdToLanguage = typeof(MyTexts).GetStaticField <Dictionary <MyLanguagesEnum, MyTexts.MyLanguageDescription> >("m_languageIdToLanguage");
            Dictionary <string, MyLanguagesEnum> m_cultureToLanguageId = typeof(MyTexts).GetStaticField <Dictionary <string, MyLanguagesEnum> >("m_cultureToLanguageId");

            if (!m_languageIdToLanguage.ContainsKey(id))
            {
                m_languageIdToLanguage.Add(id, languageDescription);
                m_cultureToLanguageId.Add(languageDescription.FullCultureName, id);
            }
        }
Beispiel #8
0
        // Reflection copy of MyTexts.AddLanguage
        private static void AddLanguage(MyLanguagesEnum id, string cultureName, string subcultureName = null, string displayName = null, float guiTextScale = 1f, bool isCommunityLocalized = true)
        {
            // Create an empty instance of LanguageDescription.
            ConstructorInfo constructorInfo = typeof(MyTexts.LanguageDescription).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null,
                                                                                                 new Type[] { typeof(MyLanguagesEnum), typeof(string), typeof(string), typeof(string), typeof(float), typeof(bool) }, null);

            MyTexts.LanguageDescription languageDescription = (MyTexts.LanguageDescription)constructorInfo.Invoke(new object[] { id, displayName, cultureName, subcultureName, guiTextScale, isCommunityLocalized });

            Dictionary <MyLanguagesEnum, MyTexts.LanguageDescription> m_languageIdToLanguage = typeof(MyTexts).GetStaticField <Dictionary <MyLanguagesEnum, MyTexts.LanguageDescription> >("m_languageIdToLanguage");
            Dictionary <string, MyLanguagesEnum> m_cultureToLanguageId = typeof(MyTexts).GetStaticField <Dictionary <string, MyLanguagesEnum> >("m_cultureToLanguageId");

            if (!m_languageIdToLanguage.ContainsKey(id))
            {
                m_languageIdToLanguage.Add(id, languageDescription);
                m_cultureToLanguageId.Add(languageDescription.FullCultureName, id);
            }
        }
Beispiel #9
0
 private static void AddLanguage(MyLanguagesEnum id, string cultureName, string subcultureName = null, string displayName = null, float guiTextScale = 1f, bool isCommunityLocalized = true)
 {
     var language = new LanguageDescription(id, displayName, cultureName, subcultureName, guiTextScale, isCommunityLocalized);
     m_languageIdToLanguage.Add((int)id, language);
     m_cultureToLanguageId.Add(language.FullCultureName, (int)id);
 }
 public static string LanguageToString(MyLanguagesEnum lang)
 {
     return MyEnumsToStrings.LanguageEnums[(int)lang];
 }
Beispiel #11
0
        public static string Localize(int message)
        {
            MyLanguagesEnum language = MyAPIGateway.Session.Config.Language;

            switch (message)
            {
            case (0):     // This is an unused test to show how the formatting goes
                switch (language)
                {
                case (MyLanguagesEnum.Portuguese_Brazil):
                    return("Olá!");

                    break;

                case (MyLanguagesEnum.Dutch):
                    return("Hallo!");

                    break;

                case (MyLanguagesEnum.Spanish_HispanicAmerica):
                case (MyLanguagesEnum.Spanish_Spain):         // Both versions of Spanish will return "¡Hola!"
                    return("¡Hola!");

                    break;

                case (MyLanguagesEnum.French):
                    return("Bonjour!");

                    break;

                default:         // English will always be "default" if the user's language hasn't been added yet
                    return("Hello!");
                }
                break;

            case (1):
                switch (language)
                {
                default:
                    return("This is likely due to a list being modified during enumeration in a parallel thread, which is probably harmless and can be ignored.");
                }
                break;

            case (2):
                switch (language)
                {
                default:
                    return("This section includes some debugging variables that can help the devs solve problems. Please use this command when reporting errors and include the output in your bug report.");
                }

            case (3):
                switch (language)
                {
                default:
                    return("All target processing moved to parallel for better performance");
                }

            case (4):
                switch (language)
                {
                default:
                    return("Code optimized and made more stable for dedicated servers");
                }

            case (5):
                switch (language)
                {
                default:
                    return("New models! Old models have a rusty look. They can be torn down to retrieve parts");
                }

            case (6):
                switch (language)
                {
                default:
                    return("New mining logic and ore detector block. Install a Nanite Ore Detector near a Nanite Control Facility that is near some voxels");
                }

            case (7):
                switch (language)
                {
                default:
                    return("Version 2.0! Jan. 6, 2019");
                }

            case (8):
                switch (language)
                {
                default:
                    return("Nearby, friendly facilities now automatically share upgrades and grid inventories");
                }

            case (9):
                switch (language)
                {
                default:
                    return("New help documentation. Type in chat:");
                }

            case (10):
                switch (language)
                {
                default:
                    return("Projector upgrade removed. Construction upgrades now also affect projection nanites");
                }

            case (11):
                switch (language)
                {
                default:
                    return("Many mods/scripts, especially those that modify ore detectors, ship welders, power usage and inventory management, can cause undesired results given the enormous scope of this mod.");
                }

            case (12):
                switch (language)
                {
                default:
                    return("Before submitting a bug report, PLEASE try to recreate the bug in a world where Nanite Construction Facility is the only mod.");
                }

            case (13):
                switch (language)
                {
                default:
                    return("There are thousands of unpredictable mods for Space Engineers that simply cannot be accounted for.");
                }

            case (14):
                switch (language)
                {
                default:
                    return("To submit a bug report, go to the Github page at");
                }

            case (15):
                switch (language)
                {
                default:
                    return("Click on the 'Issues' tab. Please search for an existing issue before creating a new issue.");
                }

            case (16):
                switch (language)
                {
                default:
                    return("You may comment your information on an existing issue and include screenshots.");
                }

            case (17):
                switch (language)
                {
                default:
                    return("If the issue does not exist, you may create a new one. You must include the following items or your issue will be deleted:");
                }

            case (18):     // This is a bulleted list item
                switch (language)
                {
                default:
                    return("Your Space Engineers log, located at %appdata%/roaming/SpaceEngineers/SpaceEngineers.log");
                }

            case (19):     // This is a bulleted list item
                switch (language)
                {
                default:
                    return("Your Nanite log and config file (if Singpleplayer or hosting) at %appdata%/roaming/SpaceEngineers/Saves/[steamid]/[savename]/storage/[mod name and number]/");
                }

            case (20):     // This is a bulleted list item
                switch (language)
                {
                default:
                    return("The output of");        // a debugging help command, /nanite debug
                }

            case (21):
                switch (language)
                {
                default:
                    return("Thank you in advance. Taking these measures allows the developers to address issues faster.");
                }

            case (22):     // This is a help section header
                switch (language)
                {
                default:
                    return("Troubleshooting");
                }

            case (23):     // This is a help section header
                switch (language)
                {
                default:
                    return("Commands");
                }

            case (24):     // This is a help section header
                switch (language)
                {
                default:
                    return("Debugging Information");
                }

            case (25):     // This is a help section header
                switch (language)
                {
                default:
                    return("Improving Performance");
                }

            case (26):     // This is a help section header
                switch (language)
                {
                default:
                    return("Nanite Control Facility Upgrades");
                }

            case (27):     // This is a help section header
                switch (language)
                {
                default:
                    return("Nanite Ore Detector Upgrades");
                }

            case (28):     // This is a help section header
                switch (language)
                {
                default:
                    return("Meet the Developers");
                }

            case (29):     // This is a help section header
                switch (language)
                {
                default:
                    return("Localization contributors");
                }

            case (30):     // This is a help section header
                switch (language)
                {
                default:
                    return("Testing Server");
                }

            case (31):     // This is a help section header
                switch (language)
                {
                default:
                    return("A Sincere Thanks");
                }

            case (32):     // This is a help section header
                switch (language)
                {
                default:
                    return("Working Together");
                }

            case (33):     // This is a help section header
                switch (language)
                {
                default:
                    return("Shared Resources");
                }

            case (34):     // This is a help section header
                switch (language)
                {
                default:
                    return("Mining Nanites");
                }

            case (35):     // This is a help section header
                switch (language)
                {
                default:
                    return("Medical Nanites");
                }

            default:
                return("");
            }
        }
 public static string LanguageToString(MyLanguagesEnum lang)
 {
     return(MyEnumsToStrings.LanguageEnums[(int)lang]);
 }