Exemplo n.º 1
0
        public ShortCodeLoader(ILog log, IReadonlyRuntimeSettings settings, IAppSetting appSetting)
        {
            _log          = log;
            _settings     = settings;
            _tranlsations = settings.Configuration.Translations;
            _appSetting   = appSetting;

            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new TypeCatalog(typeof(ILog),
                                                 typeof(IReadonlyRuntimeSettings),
                                                 typeof(IAppSetting)));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(ShortCodeLoader).Assembly));
            Imports    = new List <ITemplateShortCode>();
            _container = new CompositionContainer(catalog);
        }
Exemplo n.º 2
0
        public static string DoTranslateForKey(IReadOnlyTranslations translations, string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(string.Empty);
            }

            if (!TranslateCheck.IsMatch(key))
            {
                return($"Invalid tranlation key: {key}");
            }
            else if (translations.ContainsKey(key))
            {
                return(translations[key]);
            }
            else
            {
                return($"translation not found: '{key}'");
            }
        }
Exemplo n.º 3
0
 public Translate(IReadOnlyTranslations translations)
 {
     _translations = translations;
 }