DotnetOmar.Translation 1.3.0

dotnet add package DotnetOmar.Translation --version 1.3.0
NuGet\Install-Package DotnetOmar.Translation -Version 1.3.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="DotnetOmar.Translation" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotnetOmar.Translation --version 1.3.0
#r "nuget: DotnetOmar.Translation, 1.3.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.
// Install DotnetOmar.Translation as a Cake Addin
#addin nuget:?package=DotnetOmar.Translation&version=1.3.0

// Install DotnetOmar.Translation as a Cake Tool
#tool nuget:?package=DotnetOmar.Translation&version=1.3.0

DotnetOmar Translation

DotnetOmar Translation project

Usage

Program.cs

using Microsoft.AspNetCore.Mvc.Versioning;
using Translation.Extensions;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();

builder.Services.AddTranslation<LanguageProvider>(
    builder.Configuration.GetConnectionString("DefaultConnection")!
);

var app = builder.Build();

app.InitTranslations("i18n");

app.MapControllers();

app.Run();

Language Provider

public class LanguageProvider : ILanguageProvider
{
    // should be the same as the language code in the languages file
    public string GetLanguageCode() => "en";
}

Call Translation Service

[ApiController]
[Route("api/v1/test")]
public class TestController(ITranslationService ts) : ControllerBase
{
    [HttpGet]
    public string Get()
    {
        return ts.T("translate_login");
    }
}

Languages File

i18n/languages.json

{
  "languages": [
    {
      "label": "العربية",
      "code": "ar",
      "isRtl": true,
      "order": 1
    },
    {
      "label": "English",
      "code": "en",
      "isRtl": false,
      "order": 2
    }
  ]
}

Translation Files

  • i18n/frontend/user/ar.json
{
  "translate_new_user": "مستخدم جديد",
  "translate_edit_user": "تعديل مستخدم",
  "translate_add_new_user": "إضافة مستخدم جديد",
  "translate_update_existing_user": "تحديث مستخدم",
  "translate_user_details": "تفاصيل المستخدم",
  "translate_users_list": "قائمة المستخدمين",
  "translate_image": "الصورة",
  "translate_employee_number": "الرقم الوظيفي",
  "translate_permissions": "الصلاحيات",
  "translate_confirm_password": "تأكيد كلمة المرور",
  "translate_registration_time": "وقت التسجيل",
  "translate_update_user_permission_between_brackets_name": "تحديث صلاحيات المستخدم ({{name}})",
  "translate_update_permissions": "تحديث الصلاحيات",
  "translate_update_user_permissions": "تحديث صلاحيات المستخدم",
  "translate_is_signatory_qm": "مصرح بالتوقيع؟",
  "translate_assigned_permissions": "الصلاحيات المعطاه"
}
  • i18n/frontend/user/en.json
{
  "translate_new_user": "New User",
  "translate_edit_user": "Edit User",
  "translate_add_new_user": "Add new user",
  "translate_update_existing_user": "Update existing user",
  "translate_user_details": "User details",
  "translate_users_list": "Users list",
  "translate_image": "Image",
  "translate_employee_number": "Employee number",
  "translate_permissions": "Permissions",
  "translate_confirm_password": "Confirm password",
  "translate_registration_time": "Registration Time",
  "translate_update_user_permission_between_brackets_name": "Update user permission ({{name}})",
  "translate_update_permissions": "Update permissions",
  "translate_update_user_permissions": "Update user permissions",
  "translate_is_signatory_qm": "Is signatory",
  "translate_assigned_permissions": "Assigned permissions"
}

Development

To run this project in development use

Clone the project

  git clone https://github.com/dotnet-omar/translation.git

Install Packages

  dotnet restore

Start the server

  dotnet run --project Test

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Authors

Hi, I'm Omar Elsayed! 👋

I'm a full stack javascript developer...

🛠 Skills

Typescript, Javascript, Angular, Ionic, Nest.js, Node.js, HTML, CSS...

License

MIT

Feedback

If you have any feedback, please reach out to us at challengeromar97@gmail.com

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. 
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
1.3.0 143 5/3/2024
1.2.0 83 5/1/2024
1.1.0 98 4/30/2024
1.0.9 862 6/1/2023
1.0.8 93 5/30/2023
1.0.7 82 5/30/2023
1.0.6 86 5/25/2023
1.0.5 191 4/9/2023
1.0.4 90 4/9/2023
1.0.3 91 4/9/2023
1.0.2 91 4/9/2023
1.0.1 162 4/9/2023
1.0.0 167 4/9/2023

initialize version