• Avalanche.Core
Search Results for

    Show / Hide Table of Contents
    • Avalanche.Accessor
      • Introduction
      • IAccessor
        • IAccessor
        • IListAccessor
        • IMapAccessor
        • IRecordAccessor
        • IContentAccessor
        • IOneOfAccessor
        • IAnyAccessor
      • .Net
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
      • Protobuf
        • Introduction
      • Articles
        • Dependency Injection
        • AccessorMessages
    • Avalanche.Binding
      • Introduction
    • Avalanche.Core
      • License
    • Avalanche.DataType
      • Introduction
      • DataType
        • IDataType
        • IListType
        • IMapType
        • IRecordType
        • IFieldType
        • IOneOfType
        • IAnyType
        • IStringType
        • IValueType
        • IIntegerType
        • IEnumerationType
        • IRealType
      • .Net
        • Introduction
        • IList<T>
        • IDictionary<K,V>
        • FieldInfo
        • Enum
        • OneOfAttribute
        • StructLayoutAttribute
        • Class
      • Protobuf
        • Introduction
      • Articles
        • DataTypeRequest
        • PrintTree
        • DataTypeMessages
    • Avalanche.Emit
      • Introduction
      • TypeBuilder
      • ConstructorBuilder
      • MethodBuilder
      • PropertyBuilder
      • FieldBuilder
      • Emit
      • Utilities
    • Avalanche.FileSystem
      • Introduction
      • Abstractions
        • IFileSystem
          • IFileSystemBrowse
          • IFileSystemCreateDirectory
          • IFileSystemDelete
          • IFileSystemFileAttribute
          • IFileSystemMount
          • IFileSystemMove
          • IFileSystemObserve
          • IFileSystemOpen
        • IEvent
        • IEntry
        • IOption
        • IToken
      • FileSystem
      • VirtualFileSystem
      • MemoryFileSystem
      • EmbeddedFileSystem
      • HttpFileSystem
      • Decoration
      • IFileProvider
      • Events
      • Utilities
        • Dispose
        • File Scanner
        • Visit Tree
        • File Operation
    • Avalanche.Identity
      • Introduction
      • Identity
      • IdentityParts
      • IdentityInterner
      • IdentityComparer
      • Print Tree
      • IdentityAccessors
        • Introduction
        • TypeName
    • Avalanche.Localization
      • Introduction
      • Localization
      • LocalizationFile
      • LocalizationFiles
      • LocalizationFileSystem
      • LocalizationFileFormat
      • LocalizationLine
      • LocalizationLines
      • TemplateFormat
      • CultureProvider
      • FallbackCultureProvider
      • ResourceManager
      • LocalizationError
      • Microsoft.Extensions
        • Introduction
        • DependencyInjection
        • FileProvider
        • Logging
        • ITextLocalizer
        • IFileLocalizer
        • Localization
      • Asp.Net
        • Introduction
        • Supplying localization
        • Inject to pages
        • Culture Assigned
        • Minimalistic Api
        • Diagnostics
      • Pluralization
        • Introduction
        • Multiple plural parameters
        • Custom PluralRules
        • Invariant Culture
        • Unit Prefix
        • IPluralRule
        • IPluralNumber
        • IPluralRules
        • CLDRs
        • Unicode.CLDR40
        • Unicode.CLDR41
        • Unicode.CLDR42
      • Articles
        • Alphabet localization
        • Benchmarks
        • Caching
        • Class Library
        • Demo
        • Diagnostics
        • Embedded resources
        • Emplacement
        • File localization
        • Text localization
        • Printing templates
    • Avalanche.Message
      • Introduction
      • IMessage
      • IMessageProvider
      • IMessageDescription
      • IMessageDescriptions
      • MessageLevel
      • Message printing
      • Messages and Exceptions
      • Microsoft.Extensions
        • DependencyInjection
      • Articles
        • Aggregate Messages
        • Localization
        • Logging
        • Validation
    • Avalanche.Service
      • Introduction
      • Service
        • Introduction
        • IService
        • IServiceDisposable
        • IServiceDecoration
        • IServiceCast
        • IServiceObservable
        • IServiceContainer
        • Construction
        • Query
        • CancellationToken
        • CachePolicy
        • Scope
      • Handler
        • Introduction
        • IHandler
        • IHandlerCast
        • IHandlerDecoration
        • IHandlerWithOrder
        • CancellationToken
        • Cyclicity
        • Delegates
        • Invokable
        • ExportAttribute
        • OrderAttribute
        • PrintTree
        • Recursion
      • Query
        • Introduction
        • IQuery
        • IQueryCast
        • IQueryDecoration
      • Entry
        • Introduction
        • IEntry
        • IEntryCast
        • IEntryDecoration
        • IEntryObservable
        • IEntryVisitable
        • EntryState
      • Request
        • Introduction
        • IRequest
        • IRequestFor
        • IRequestToBeCached
        • IRequestToBeDisposed
        • RequestAttribute
        • ContextParameterAttribute
        • Print Tree
      • Dependency Injection
        • Introduction
        • Asp.Net
        • ServiceRequest<T>
        • Decorating a service
        • Handler
        • CachePolicy
        • CancellationToken
        • QueryLogger
      • Examples
        • NodeCount
        • Expression
        • Mapper
      • Articles
        • Benchmarks
        • Error Handling
        • ServiceMessages
    • Avalanche.StatusCode
      • Introduction
      • HResult
        • Introduction
        • HResult.Facilities
        • BasicMessages
        • RpcMessages
        • DispatchMessages
        • ItfMessages
        • Win32Messages
        • ClrMessages
      • System
        • Introduction
        • AccessControlMessages
        • AggregateMessages
        • AppDomainMessages
        • ArgumentMessages
        • ArgumentNullMessages
        • ArgumentOutOfRangeMessages
        • ArithmeticMessages
        • ArrayMessages
        • AssemblyMessages
        • BadImageFormatMessages
        • CodeContractMessages
        • CodePageMessages
        • CollectionsMessages
        • CompilerServiceMessages
        • CryptographyMessages
        • CultureMessages
        • DiagnosticsMessages
        • EventSourceMessages
        • ExecutionEngineMessages
        • FormatMessages
        • HostProtectionMessages
        • IOMessages
        • IndexOutOfRangeMessages
        • InteropServiceMessages
        • InvalidCastMessages
        • InvalidOperationMessages
        • IsolatedStorageMessages
        • LazyMessages
        • MarshalerMessages
        • MemoryMessages
        • MiscellaneousMessages
        • NotImplementedMessages
        • NotSupportedMessages
        • ObjectDisposedMessages
        • OperationCanceledMessages
        • OverflowMessages
        • PlatformMessages
        • PolicyMessages
        • PrincipalMessages
        • ProgramMessages
        • ReferenceMessages
        • ReflectionMessages
        • RegionMessages
        • RemotingMessages
        • ResourcesMessages
        • SecurityMessages
        • SerializationMessages
        • StackMessages
        • TaskMessages
        • TextMessages
        • ThreadingMessages
        • TimeZoneMessages
        • TypeMessages
        • XmlMessages
      • HttpStatusCode
      • OpcUaStatusCode
    • Avalanche.Template
      • Introduction
      • TemplateFormats
      • ITemplatePrintable
      • ITemplateFormatPrintable
      • ITemplateText
      • ITemplateBreakdown
      • ITemplateFormat
      • ITemplateFormats
      • Extract Arguments
      • Emplacement
    • Avalanche.Tokenizer
      • Introduction
      • IToken
      • ITokenizer
      • Tokenizers
    • Avalanche.Utilities
      • Introduction
      • Collections
        • Tuples
        • StructList
        • ArrayList
        • BijectionMap
        • LocakableDictionary
        • LockableList
        • MapList
        • Pipe
        • RingQueue
        • EnumerableExtensions
        • TupleUtilities
        • ArrayUtilities
      • Comparers
        • IGraphComparer
        • IGraphComparable
        • AlphaNumericComparer
        • EnumerableComparer
        • EnumerableGraphComparer
        • ReferenceComparer
        • KeyValuePairComparer
        • DefaultComparerProvider
        • RecordComparer
      • Cloners
        • ICloner
        • IGraphCloner
        • IGraphCloneable
        • ListCloner
        • DictionaryCloner
        • FieldCloner
        • PassthroughCloner
        • RecordCloner
        • ClonerProvider
      • Dispose
        • IDisposeAttachable
        • IDisposeBelatable
      • Provider
        • Introduction
        • ProviderBase
        • Delegate
        • Pipe
        • Cache
        • ResultCapture
        • AsReadOnly
        • AsService
        • IProviderEvent
      • Record
        • IRecordDescription
        • IFieldDescription
        • IConstructorDescription
        • IConstructionDescription
        • IParameterDescription
        • IRecordProviders
        • RecordDelegates
          • RecordCreate
          • RecordClone
          • RecordCopy
          • IRecordDelegates
        • FieldDelegates
          • FieldRead
          • FieldWrite
          • RecreateWith
          • IFieldDelegates
      • String
        • IEscaper
        • UnicodeString
      • Miscellaneous
        • IIdGenerator
        • Permutation
        • IReadOnly
        • IUserDataContainer
        • Void
    • Avalanche.Writer
      • Introduction
      • ConstantWriter
      • Context
      • ConvertWriter
      • DefaultConstructor
      • DelegateWriter
      • PassthroughWriter
      • Referer
      • TypeCast
      • Writer
      • WriterPipe
      • WriterMessages

    ResourceManager Provider

    .AddResourceManagerProvider() adds file and line providers that load ResourceManager from the Assemblies in the AppDomain.

    // Create localization and add resource manager provider
    ILocalization localization = new Localization()
        .AddResourceManagerProvider();
    

    .resx file

    For text resources only ResourceManagerLineProvider.AssemblyLoader and ResourceManagerLineProvider.AssemblyLoaderCached load texts from .dlls and ResourceManagers indicated by key.

    // Create localization and add resource manager provider
    ILocalization localization = new Localization()
        .AddLineProvider(ResourceManagerLineProvider.AssemblyLoader, ResourceManagerLineProvider.AssemblyLoaderCached);
    // Get localizable text
    ILocalizedText text = localization.LocalizableTextCached["docs.Resources.Resource1.Apples"];
    // Print to localization
    WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 })); // "You've got 1 apple(s)."
    

    For file resources only ResourceManagerFileProvider.AssemblyLoader and ResourceManagerFileProvider.AssemblyLoaderCached load files from .dlls and ResourceManagers indicated by key.

    // Create localization and add resource manager provider
    ILocalization localization = new Localization()
        .AddFileProvider(ResourceManagerFileProvider.AssemblyLoader, ResourceManagerFileProvider.AssemblyLoaderCached);
    // Get localizable file
    ILocalizable<ILocalizationFile> localizableFile = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
    // Localize to invariant ""
    ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
    // Read file 
    byte[] data = localizationFile!.ReadFully();
    

    .LocalizableTextsQueryCached[null] queries for all lines in in all ResourceManagers in the AppDomain.

    // Create localization and add resource manager provider
    ILocalization localization = new Localization()
        .AddLineProvider(ResourceManagerLineProvider.AssemblyLoader, ResourceManagerLineProvider.AssemblyLoaderCached);
    // Get localizable text
    IEnumerable<ILocalizedText> texts = localization.LocalizableTextsQueryCached[null];
    // Print texts
    foreach(var text in texts)
        WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 })); // "You've got 1 apple(s)."
    

    .LocalizableFilesQueryCached[null] queries for all files in in all ResourceManagers in the AppDomain.

    // Create localization and add resource manager provider
    ILocalization localization = new Localization()
        .AddFileProvider(ResourceManagerFileProvider.AssemblyLoader, ResourceManagerFileProvider.AssemblyLoaderCached);
    // Get localizable file
    IEnumerable<ILocalizable<ILocalizationFile>> localizableFiles = localization.LocalizableFilesQueryCached[null];
    // Visit each file
    foreach (var localizableFile in localizableFiles)
    {
        // Localize to invariant ""
        ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
        // Read file 
        byte[] data = localizationFile!.ReadFully();
    }
    

    If depependency injection is used, the .AddAvalancheLocalizationResourceManagerProvider() adds assembly loading providers.

    // Add service descriptors
    IServiceCollection serviceCollection = new ServiceCollection()
        .AddAvalancheLocalizationService()
        .AddAvalancheLocalizationResourceManagerProvider();
    // Build service
    using ServiceProvider service = serviceCollection.BuildServiceProvider();
    // Get Localization
    ILocalization localization = service.GetService<ILocalization>()!;
    
    // Get text
    ILocalizedText localizedText = localization.LocalizedTextCached[("", "docs.Resources.Resource1.Apples")];
    // Print text
    WriteLine(localizedText.Print(new object[] { 2 }));
    
    // Get localizable file
    ILocalizable<ILocalizationFile> localizableFile = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
    // Localize to invariant ""
    ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
    // Read file 
    byte[] data = localizationFile!.ReadFully();
    
    Warning

    If assemblies are loaded dynamically, this provider may have had falsely cached lines before the dynamically loaded assembly's ResourceManager was loaded into AppDomain. The caller may need to preload respective Assembly beforehand, or invalidate cache after loading. Assembly is loaded by taking a reference to a Type or instantiating an object from the Assembly. See cache tips.

    ResourceManager Instance

    .AddResourceManager(resourceManager) adds a single ResourceManager instance as line and file provider.

    // Get resource manager
    ResourceManager resourcemanager = docs.Resources.Resource1.ResourceManager;
    // Create localization and add resource manager as provider
    ILocalization localization = new Localization().AddResourceManager(resourcemanager);
    

    .resx file

    Resource manager can be added to the localization singleton Localization.Default just as well.

    // Get resource manager
    ResourceManager resourceManager = docs.Resources.Resource1.ResourceManager;
    // Add resource manager to localization singleton
    Localization.Default.AddResourceManager(resourceManager);
    

    Localization provides lines from resources manager. Note however, that Pluralization cannot be supported from resource manager.

    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
    ILocalizedText? text = localization.LocalizableTextCached["docs.Resources.Resource1.Apples"];
    WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 }));
    

    .AddResourceManager(resourceManager, namespace) adds a ResourceManager with a overriding namespace.

    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager, "Namespace");
    ILocalizedText? text = localization.LocalizableTextCached["Namespace.Apples"];
    WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 }));
    

    Files are now accessible from ResourceManager.

    // Create Localization
    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
    // Get file reference
    ILocalizationFile localizationFile = localization.FileQueryCached[("", "docs.Resources.Resource1.logo")].FirstOrDefault()!;
    // Read file
    byte[] data = localizationFile.ReadFully();
    

    All files can be queried.

    // Create Localization
    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
    // Get all files
    ILocalizationFile[] allLocalizationFiles = localization.FileQueryCached[(null, null)].ToArray()!;
    

    Localizable file can localize to different cultures.

    // Create Localization
    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
    // Get localizable file
    ILocalizable<ILocalizationFile> localizable1 = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
    // Localize to invariant ""
    ILocalizationFile? localizationFile = localizable1.Localize("")?.Value;
    // Read file 
    byte[] data = localizationFile!.ReadFully();
    

    Localizing returns file of active culture.

    // Create Localization
    ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
    // Create localizing file
    ILocalizing<ILocalizationFile> localizing = localization.LocalizingFileCached[(CultureProvider.CurrentCulture.Instance, "docs.Resources.Resource1.logo")];
    // Localize to CultureProvider.CurrentCulture
    ILocalizationFile? localizationFile = localizing.Value?.Value;
    // Read file
    byte[] data = localizationFile!.ReadFully();
    

    If depependency injection is used, ServiceDescriptors of ResourceManager instances can be added to service collection.

    // Get ResourceManager
    ResourceManager resourceManager = docs.Resources.Resource1.ResourceManager;
    // Add service descriptors
    IServiceCollection serviceCollection = new ServiceCollection()
        .AddSingleton(typeof(ResourceManager), resourceManager)
        .AddAvalancheLocalizationService();
    // Build service
    using ServiceProvider service = serviceCollection.BuildServiceProvider();
    // Get Localization
    ILocalization localization = service.GetService<ILocalization>()!;
    // Get text
    ILocalizedText localizedText = localization.LocalizedTextCached[("", "docs.Resources.Resource1.Apples")];
    // Print text
    WriteLine(localizedText.Print(new object[] { 2 }));
    
    Warning

    A ILocalized<T> that originates from a ResourceManager may indicate wrong source culture. The culture property may display the requested culture instead of the actual source culture. This is due to a bug in ResourceManager.GetResourceSet(tryParents: false) which returns parent resources despite 'false' argument. The issue cannot be workarounded currently.

    Full Example

    Full example
    using System.Globalization;
    using System.Resources;
    using Avalanche.Localization;
    using Avalanche.Utilities;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.FileProviders;
    using static System.Console;
    
    class resourcemanager
    {
        public static void Run()
        {
            {
                // <11>
                // Create localization and add resource manager provider
                ILocalization localization = new Localization()
                    .AddResourceManagerProvider();
                // </11>
            }
            {
                // <13>
                // Create localization and add resource manager provider
                ILocalization localization = new Localization()
                    .AddLineProvider(ResourceManagerLineProvider.AssemblyLoader, ResourceManagerLineProvider.AssemblyLoaderCached);
                // Get localizable text
                ILocalizedText text = localization.LocalizableTextCached["docs.Resources.Resource1.Apples"];
                // Print to localization
                WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 })); // "You've got 1 apple(s)."
                // </13>
            }
            {
                // <14>
                // Create localization and add resource manager provider
                ILocalization localization = new Localization()
                    .AddFileProvider(ResourceManagerFileProvider.AssemblyLoader, ResourceManagerFileProvider.AssemblyLoaderCached);
                // Get localizable file
                ILocalizable<ILocalizationFile> localizableFile = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
                // Localize to invariant ""
                ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
                // Read file 
                byte[] data = localizationFile!.ReadFully();
                // </14>
            }        
            {
                // <15>
                // Create localization and add resource manager provider
                ILocalization localization = new Localization()
                    .AddLineProvider(ResourceManagerLineProvider.AssemblyLoader, ResourceManagerLineProvider.AssemblyLoaderCached);
                // Get localizable text
                IEnumerable<ILocalizedText> texts = localization.LocalizableTextsQueryCached[null];
                // Print texts
                foreach(var text in texts)
                    WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 })); // "You've got 1 apple(s)."
                // </15>
            }
            {
                // <16>
                // Create localization and add resource manager provider
                ILocalization localization = new Localization()
                    .AddFileProvider(ResourceManagerFileProvider.AssemblyLoader, ResourceManagerFileProvider.AssemblyLoaderCached);
                // Get localizable file
                IEnumerable<ILocalizable<ILocalizationFile>> localizableFiles = localization.LocalizableFilesQueryCached[null];
                // Visit each file
                foreach (var localizableFile in localizableFiles)
                {
                    // Localize to invariant ""
                    ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
                    // Read file 
                    byte[] data = localizationFile!.ReadFully();
                }
                // </16>
            }
            {
                // <19>
                // Add service descriptors
                IServiceCollection serviceCollection = new ServiceCollection()
                    .AddAvalancheLocalizationService()
                    .AddAvalancheLocalizationResourceManagerProvider();
                // Build service
                using ServiceProvider service = serviceCollection.BuildServiceProvider();
                // Get Localization
                ILocalization localization = service.GetService<ILocalization>()!;
    
                // Get text
                ILocalizedText localizedText = localization.LocalizedTextCached[("", "docs.Resources.Resource1.Apples")];
                // Print text
                WriteLine(localizedText.Print(new object[] { 2 }));
    
                // Get localizable file
                ILocalizable<ILocalizationFile> localizableFile = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
                // Localize to invariant ""
                ILocalizationFile? localizationFile = localizableFile.Localize("")?.Value;
                // Read file 
                byte[] data = localizationFile!.ReadFully();
                // </19>
            }
    
            {
                // <21>
                // Get resource manager
                ResourceManager resourcemanager = docs.Resources.Resource1.ResourceManager;
                // Create localization and add resource manager as provider
                ILocalization localization = new Localization().AddResourceManager(resourcemanager);
                // </21>
            }
            {
                // <22>
                // Get resource manager
                ResourceManager resourceManager = docs.Resources.Resource1.ResourceManager;
                // Add resource manager to localization singleton
                Localization.Default.AddResourceManager(resourceManager);
                // </22>
            }
            {
                // <23>            
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
                ILocalizedText? text = localization.LocalizableTextCached["docs.Resources.Resource1.Apples"];
                WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 }));
                // </23>
            }
            {
                // <24>
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager, "Namespace");
                ILocalizedText? text = localization.LocalizableTextCached["Namespace.Apples"];
                WriteLine(text.Print(CultureInfo.InvariantCulture, new object[] { 1 }));
                // </24>
            }
            {
                // <25>
                // Create Localization
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
                // Get file reference
                ILocalizationFile localizationFile = localization.FileQueryCached[("", "docs.Resources.Resource1.logo")].FirstOrDefault()!;
                // Read file
                byte[] data = localizationFile.ReadFully();
                // </25>
            }
            {
                // <26>
                // Create Localization
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
                // Get all files
                ILocalizationFile[] allLocalizationFiles = localization.FileQueryCached[(null, null)].ToArray()!;
                // </26>
            }
            {
                // <27>
                // Create Localization
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
                // Get localizable file
                ILocalizable<ILocalizationFile> localizable1 = localization.LocalizableFileCached["docs.Resources.Resource1.logo"];
                // Localize to invariant ""
                ILocalizationFile? localizationFile = localizable1.Localize("")?.Value;
                // Read file 
                byte[] data = localizationFile!.ReadFully();
                // </27>
            }
            {
                // <28>
                // Create Localization
                ILocalization localization = new Localization().AddResourceManager(docs.Resources.Resource1.ResourceManager);
                // Create localizing file
                ILocalizing<ILocalizationFile> localizing = localization.LocalizingFileCached[(CultureProvider.CurrentCulture.Instance, "docs.Resources.Resource1.logo")];
                // Localize to CultureProvider.CurrentCulture
                ILocalizationFile? localizationFile = localizing.Value?.Value;
                // Read file
                byte[] data = localizationFile!.ReadFully();
                // </28>
            }
            {
                // <29>
                // Get ResourceManager
                ResourceManager resourceManager = docs.Resources.Resource1.ResourceManager;
                // Add service descriptors
                IServiceCollection serviceCollection = new ServiceCollection()
                    .AddSingleton(typeof(ResourceManager), resourceManager)
                    .AddAvalancheLocalizationService();
                // Build service
                using ServiceProvider service = serviceCollection.BuildServiceProvider();
                // Get Localization
                ILocalization localization = service.GetService<ILocalization>()!;
                // Get text
                ILocalizedText localizedText = localization.LocalizedTextCached[("", "docs.Resources.Resource1.Apples")];
                // Print text
                WriteLine(localizedText.Print(new object[] { 2 }));
                // </29>
            }
        }
    }
    
    In This Article
    Back to top Copyright © Toni Kalajainen