public LocaleLookup(LocaleMapping mapping)
 {
     if (mapping == null || !mapping.lookup.HasItems())
     {
         return;
     }
     foreach (var map in mapping.lookup)
     {
         if (!map.HasItems() || map.Length < 2)
         {
             continue;
         }
         if (Enum.TryParse(map[0], out LocaleTextType key))
         {
             if (!this.lookup.ContainsKey(key))
             {
                 this.lookup.Add(key, map[1]);
             }
         }
     }
 }
Пример #2
0
    private async Task <LocaleLookup> LoadLocale(SystemLanguage language)
    {
        if (language == SystemLanguage.English)
        {
            return(new EnglishLocale());
        }

        try
        {
            var localePath = LocaleMapping.GetLocalePath(language);
            if (String.IsNullOrEmpty(localePath))
            {
                return(null);
            }
            var mapping = await this.File.GetStreamedFile <LocaleMapping>(localePath);

            return(new LocaleLookup(mapping));
        }
        catch (Exception e)
        {
            Debug.LogError(e);
        }
        return(null);
    }