From 2dafba0216606609a094f0b2f6aa2fa2d972c3f4 Mon Sep 17 00:00:00 2001 From: Sergey Kostin Date: Mon, 25 Mar 2024 19:29:12 +0300 Subject: [PATCH] [v2.2.2] Update (~) Updated: nullable ResolveString() (+) Added: ResolveStringOrFallback() (~) Updated: License --- LICENSE | 2 +- Model/DefaultLocalizator.cs | 18 ++++++++++++++++-- Prototype/ILocalizator.cs | 12 +++++++++++- README.md | 4 ++-- SKitLs.Utils.Localizations.csproj | 11 ++++++----- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/LICENSE b/LICENSE index 122edae..41eb83a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Sargeras02 +Copyright (c) 2023-2024, SKitLs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Model/DefaultLocalizator.cs b/Model/DefaultLocalizator.cs index 5097f6f..2135923 100644 --- a/Model/DefaultLocalizator.cs +++ b/Model/DefaultLocalizator.cs @@ -68,8 +68,21 @@ public DefaultLocalizator(string localsPath) /// The localized string based on the specified language key and key identifier, or a fallback string /// if the requested string is not defined in the specified language. /// - public string ResolveString(LangKey lang, string key, params string?[] format) - => InternalResolveString(lang, key, format) ?? FallbackString(lang, key, format); + public string? ResolveString(LangKey lang, string key, params string?[] format) => InternalResolveString(lang, key, format); + + /// + /// Resolves the localized string for the specified language key and key identifier, with optional format parameters. + /// + /// The language key for localization. + /// The unique identifier for the localized string. + /// Optional. An array of strings to be formatted into the resolved localized string. + /// + /// The localized string based on the specified language key and key identifier, or a fallback string + /// if the requested string is not defined in the specified language. + /// + public string ResolveStringOrFallback(LangKey lang, string key, params string?[] format) => InternalResolveString(lang, key, format) + ?? FallbackString(lang, key, format); + private string? InternalResolveString(LangKey lang, string key, params string?[] format) { if (!(Localizations.ContainsKey(lang) && Localizations[lang].ContainsKey(key))) @@ -79,6 +92,7 @@ public string ResolveString(LangKey lang, string key, params string?[] format) return string.Format(Localizations[lang][key], format); } + private string FallbackString(LangKey lang, string key, params string?[] format) { var reply = InternalResolveString(LangKey.EN, NotDefinedKey, Enum.GetName(lang), key, LocalsPath) diff --git a/Prototype/ILocalizator.cs b/Prototype/ILocalizator.cs index 8af11f7..3d2ae5c 100644 --- a/Prototype/ILocalizator.cs +++ b/Prototype/ILocalizator.cs @@ -10,6 +10,7 @@ public interface ILocalizator /// Represents the key indicating that the requested string is not defined in the specified language. /// public string NotDefinedKey { get; } + /// /// Represents the path to the localization resource files. /// @@ -22,6 +23,15 @@ public interface ILocalizator /// The unique identifier for the localized string. /// Optional. An array of strings to be formatted into the resolved localized string. /// The localized string based on the specified language key and key identifier. - public string ResolveString(LangKey lang, string key, params string?[] format); + public string? ResolveString(LangKey lang, string key, params string?[] format); + + /// + /// Resolves the localized string for the specified language key and key identifier, with optional format parameters. + /// + /// The language key for localization. + /// The unique identifier for the localized string. + /// Optional. An array of strings to be formatted into the resolved localized string. + /// The localized string based on the specified language key and key identifier. + public string ResolveStringOrFallback(LangKey lang, string key, params string?[] format); } } \ No newline at end of file diff --git a/README.md b/README.md index fbc4791..4b68fb5 100644 --- a/README.md +++ b/README.md @@ -165,14 +165,14 @@ Thank you for considering contributing to our project. This project is distributed under the terms of the MIT License. -Copyright (C) Sargeras02 2023 +Copyright (C) 2023-2024, Sargeras02 ## Developer contact For any issues related to the project, please feel free to reach out to us through the project's GitHub page. We welcome bug reports, feedback, and any other inquiries that can help us improve the project. -You can also contact the project owner directly via their GitHub profile at the following [link](https://github.com/Sargeras02). +You can also contact the project owner directly via their GitHub profile at the [following link](https://github.com/Sargeras02) or email: skitlsdev@gmail.com Your collaboration and support are highly appreciated, and we will do our best to address any concerns or questions promptly and professionally. Thank you for your interest in our project. diff --git a/SKitLs.Utils.Localizations.csproj b/SKitLs.Utils.Localizations.csproj index b78c8e9..cb65c3b 100644 --- a/SKitLs.Utils.Localizations.csproj +++ b/SKitLs.Utils.Localizations.csproj @@ -6,16 +6,17 @@ enable True $(AssemblyName) - 2.2.0 + 2.2.2 $(AssemblyVersion) - https://github.com/Sargeras02/SKitLs.Utils.Localizations.git + https://github.com/SKitLs-dev/SKitLs.Utils.Localizations.git $(AssemblyVersion) Comprehensive localization package that facilitates seamless string translation and adaptation for diverse language contexts. - Sargeras02, SKit-Labs - Copyright (C) Sargeras02 2023 + SKitLs, Sargeras02 + Copyright (C) 2023-2024, SKitLs libIcon_localizations.png README.md - XML Docimentation Included + Package info Updated. +Ownership transfered to SKitLs. LICENSE True Localization, Internationalization, Multilingual, Globalization