internal static Dictionary <string, string> Load(LocalizationConfig config, string language, Dictionary <string, string> parameters = null) { if (parameters == null) { parameters = new Dictionary <string, string>(); } AddMissingParameter(KeyLanguage, language, parameters); return(Load(config, parameters)); }
internal static Dictionary <string, string> Load(LocalizationConfig config, Dictionary <string, string> parameters) { AddMissingParameter(KeyFallbackLanguage, LanguageSettings.Instance.DefaultLanguage, parameters); Dictionary <string, string> result = new Dictionary <string, string>(); foreach (LocalizationConfig.LocalizationSource source in config.Sources) { AddOrReplace(result, LoadSource(source, parameters)); } return(result); }
/// <summary> /// Finds all available languages for the given config, any additional parameters for the paths /// have to be provided. Keep in mind that only sources which are flagged as DefinesAvailableLanguages are /// used and the result will be a union of all of them. /// </summary> /// <remarks>Note: Only sources based on streaming assets work for now.</remarks> public static List <string> FindAvailableLanguagesForConfig(LocalizationConfig config, Dictionary <string, string> parameters) { List <string> result = null; if (parameters.ContainsKey(LocalizationReader.KeyLanguage)) { parameters[LocalizationReader.KeyLanguage] = "*"; } else { parameters.Add(LocalizationReader.KeyLanguage, "*"); } IEnumerable <LocalizationConfig.LocalizationSource> sources = config.Sources.Where(source => source.DefinesAvailableLanguages); foreach (LocalizationConfig.LocalizationSource source in sources) { string path = LocalizationReader.ResolvePath(source.Path, parameters); if (source.ResourceType == LocalizationConfig.ResourceType.StreamingAssets) { List <string> foundLanguages = FindLanguagesFileInStreamingAssets(path); if (result == null) { result = foundLanguages; } else { result = result.Union(foundLanguages).ToList(); } } } string fallbackLanguage = LanguageSettings.Instance.DefaultLanguage.ToLower(); if (result == null) { return(new List <string> { fallbackLanguage }); } if (result.Contains(fallbackLanguage) == false) { result.Add(fallbackLanguage); } return(result.Distinct().ToList()); }
/// <summary> /// Loads the given config into the localization, will overwrite in there. /// </summary> /// <param name="config">Localization config which should be used.</param> /// <param name="parameters">Additional parameters used for resolving the path.</param> public static void LoadLocalization(LocalizationConfig config, Dictionary <string, string> parameters) { entries = LocalizationReader.Load(config, parameters); }
/// <summary> /// Loads the given config into the localization database, will overwrite everything. /// </summary> /// <param name="config">Localization config which should be used.</param> /// <param name="language">Language which should be loaded.</param> /// <param name="course">Name of the course which is ran.</param> public static void LoadLocalization(LocalizationConfig config, string language, string course) { entries = LocalizationReader.Load(config, language, course); }