profileShare

rasmusjy / splitapp-backend-modular-monolith

Read-only snapshot

No repository description.

main default branch 418 files Expires Sep 13, 2026, 9:06 AM
PassthroughStringLocalizer.cs 1,252 bytes
1 using System.Globalization;
2 using Microsoft.Extensions.Localization;
3
4 namespace SplitApp.WebApp.Hosting;
5
6 /// <summary>
7 /// No-op localizer factory: every requested key is returned unchanged. Phase 2 used
8 /// resource files; in modular monolith we simply pass the key through so all the
9 /// `IStringLocalizer<App.Resources.Views.Shared>` references continue to compile and
10 /// produce sensible English strings.
11 /// </summary>
12 public class PassthroughStringLocalizerFactory : IStringLocalizerFactory
13 {
14 public IStringLocalizer Create(Type resourceSource) => new PassthroughStringLocalizer();
15 public IStringLocalizer Create(string baseName, string location) => new PassthroughStringLocalizer();
16 }
17
18 public class PassthroughStringLocalizer : IStringLocalizer
19 {
20 public LocalizedString this[string name] => new(name, name, resourceNotFound: false);
21
22 public LocalizedString this[string name, params object[] arguments]
23 => new(name, string.Format(CultureInfo.CurrentCulture, name, arguments), resourceNotFound: false);
24
25 public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) => Array.Empty<LocalizedString>();
26 }
27
28 public class PassthroughStringLocalizer<T> : PassthroughStringLocalizer, IStringLocalizer<T> { }
29