Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Latest commit

 

History

History
50 lines (40 loc) · 1.75 KB

README.md

File metadata and controls

50 lines (40 loc) · 1.75 KB

Kf.Localization

Basic .Net library for supporting resource based localization.

Build status

Download

Resx Example

  1. Download the binaries Kf.Localization and Kf.Localization.Resx, or get all dependencies directly via the nuget package ( https://www.nuget.org/packages/Kf.Localization.Resx/ ).
  2. Create the appropriate .resx files (e.g. Strings.resx, Strings.nl-BE.resx, Strings.en-EN.resx, etc..)
  3. Afterwards you can use the library, and pass around the dependendent object via DI or any other method you prefer.
using System;
using Kf.Localization.Providers;
using Kf.Localization.Resx;
using TestingKfLocalizationResx.Resources;

namespace TestingKfLocalizationResx
{
    class Program
    {
        static void Main(string[] args) {
            IResourceProvider<string> strings = new ResxStringProvider(Strings.ResourceManager, null);
            var p = new Program(strings);
            p.Welcome();
            p.About();
            Console.ReadLine();
        }

        private readonly IResourceProvider<string> _resourceProvider;

        public Program(IResourceProvider<string> resourceProvider) {
            _resourceProvider = resourceProvider;           
        }

        public void Welcome() {
            Console.WriteLine(_resourceProvider.Get("WelcomeWords"));
        }

        public void About() {
            Console.WriteLine($"About: {_resourceProvider.Get("Title")}");
        }
    }
}

.resx file(s) itself