예제 #1
0
        /// <summary>
        /// Set the localization internally (does not update items)
        /// </summary>
        /// <param name="code">Valid locale</param>
        public static void SetLocale(string code)
        {
            if (SupportedLocales.Contains(code))
            {
                I18N.Current.Locale = code;
                LocalizationCache.Update();
            }

            if (SupportedLocalesDescription.Contains(code))
            {
                I18N.Current.Locale = SupportedLocales[Array.FindIndex(SupportedLocalesDescription, (obj) => obj == code)];
                LocalizationCache.Update();
            }

            //I18N.Current.Locale = SupportedLocales[0];
        }
예제 #2
0
        /// <summary>
        /// Initialize
        /// </summary>
        public static void Init()
        {
#if DEBUG
            I18N.Current
            .AddLocaleReader(new LocalizationReader(), ".stub") // Tells our system to use the txt stubs
            .SetNotFoundSymbol("$")                             // Optional: when a key is not found, it will appear as $key$ (defaults to "$")
            .SetFallbackLocale("en-CA")                         // Optional but recommended: locale to load in case the system locale is not supported
            .SetThrowWhenKeyNotFound(true)                      // Optional: Throw an exception when keys are not found (recommended only for debugging)
            .SetResourcesFolder("Locales")                      // Optional: The directory containing the resource files (defaults to "Locales")
            .Init(Assembly.GetExecutingAssembly());
#else
            I18N.Current
            .AddLocaleReader(new LocalizationReader(), ".stub") // Tells our system to use the txt stubs
            .SetNotFoundSymbol("$")                             // Optional: when a key is not found, it will appear as $key$ (defaults to "$")
            .SetFallbackLocale("en-CA")                         // Optional but recommended: locale to load in case the system locale is not supported
            .SetThrowWhenKeyNotFound(false)                     // Optional: Throw an exception when keys are not found (recommended only for debugging)
            .SetResourcesFolder("Locales")                      // Optional: The directory containing the resource files (defaults to "Locales")
            .Init(Assembly.GetExecutingAssembly());
#endif
            LocalizationCache.Update();
        }