Ozcorps.Localization 9.0.0

dotnet add package Ozcorps.Localization --version 9.0.0
                    
NuGet\Install-Package Ozcorps.Localization -Version 9.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ozcorps.Localization" Version="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ozcorps.Localization" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Ozcorps.Localization" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ozcorps.Localization --version 9.0.0
                    
#r "nuget: Ozcorps.Localization, 9.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ozcorps.Localization@9.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ozcorps.Localization&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Ozcorps.Localization&version=9.0.0
                    
Install as a Cake Tool

Ozcorps.Localization

NuGet License: MIT .NET

A lightweight, database-driven localization library for .NET 8. Manages multilingual translations stored in PostgreSQL, with built-in in-memory caching, platform-based word filtering, and full CRUD services for languages and translations.


Features

  • Database-driven translations (no JSON/RESX files needed)
  • Supports PostgreSQL (Npgsql)
  • In-memory caching with configurable expiration (default: 30 minutes)
  • Platform-based word filtering via PlatformId
  • Full CRUD services: ILanguageService, ILanguageWordService, ILanguageWordTypeService
  • Simple DI setup with a single extension method call

Installation

dotnet add package Ozcorps.Localization

Database Setup

The library expects three tables: language, language_word, and language_word_type.

PostgreSQL example:

CREATE TABLE language (
    id          UUID PRIMARY KEY,
    key         VARCHAR(200),
    name        VARCHAR(300),
    is_active   BOOLEAN DEFAULT true,
    is_deleted  BOOLEAN DEFAULT false,
    created_at  TIMESTAMP WITHOUT TIME ZONE,
    created_by_id UUID,
    updated_at  TIMESTAMP WITHOUT TIME ZONE,
    updated_by_id UUID
);

CREATE TABLE language_word_type (
    id          UUID PRIMARY KEY,
    name        VARCHAR(300),
    is_active   BOOLEAN DEFAULT true,
    is_deleted  BOOLEAN DEFAULT false,
    created_at  TIMESTAMP WITHOUT TIME ZONE,
    created_by_id UUID,
    updated_at  TIMESTAMP WITHOUT TIME ZONE,
    updated_by_id UUID
);

CREATE TABLE language_word (
    id                   UUID PRIMARY KEY,
    language_id          UUID,
    language_word_type_id UUID,
    platform_id          BIGINT NOT NULL DEFAULT 1,
    key                  VARCHAR(200),
    value                VARCHAR(300),
    is_active            BOOLEAN DEFAULT true,
    is_deleted           BOOLEAN DEFAULT false,
    created_at           TIMESTAMP WITHOUT TIME ZONE,
    created_by_id        UUID,
    updated_at           TIMESTAMP WITHOUT TIME ZONE,
    updated_by_id        UUID
);

Sample data:

INSERT INTO language (id, key, name, is_active, is_deleted, created_at, created_by_id)
VALUES (gen_random_uuid(), 'tr', 'Türkçe', true, false, now(), gen_random_uuid());

INSERT INTO language (id, key, name, is_active, is_deleted, created_at, created_by_id)
VALUES (gen_random_uuid(), 'en', 'English', true, false, now(), gen_random_uuid());

Registration

builder.Services.AddLocalization("Host=localhost;Database=mydb;Username=user;Password=pass");

Accepts an optional shouldAddLanguageServices parameter (default: true). Set it to false if you only need LocalizationTool without the CRUD services.

// Only LocalizationTool, no CRUD services
builder.Services.AddLocalization(connectionString, shouldAddLanguageServices: false);

Usage

Inject LocalizationTool

public class ProductController : ControllerBase
{
    private readonly LocalizationTool _localization;

    public ProductController(LocalizationTool localization)
    {
        _localization = localization;
    }

    [HttpGet]
    public IActionResult Get([FromQuery] string lang = "tr")
    {
        var message = _localization.Get(lang, "welcome_message");
        return Ok(message);
    }
}

Get all words for a language (dictionary)

// Get all words
var words = _localization.GetWords("en");

// Get words filtered by platform
var words = _localization.GetWords("en", platformId: 2);

Clear the cache

_localization.Refresh();

CRUD Services

When shouldAddLanguageServices: true (default), three services are registered:

Interface Description
ILanguageService Manage languages (add, update, remove, paginate)
ILanguageWordService Manage translation entries
ILanguageWordTypeService Manage word type categories

Each service provides: Get, GetAll, Add, Update, Remove, Paginate, Any.


Configuration Summary

Extension Method Database Cache CRUD Services
AddLocalization PostgreSQL IMemoryCache (30 min) Optional

License

MIT © ozcorps

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.0 0 4/12/2026
8.0.0 1,965 12/3/2024
1.1.2 528 7/11/2024
1.1.1 143 7/10/2024
1.1.0 150 7/9/2024
1.0.0 169 7/4/2024