DotnetOmar.Translation
1.3.0
dotnet add package DotnetOmar.Translation --version 1.3.0
NuGet\Install-Package DotnetOmar.Translation -Version 1.3.0
<PackageReference Include="DotnetOmar.Translation" Version="1.3.0" />
paket add DotnetOmar.Translation --version 1.3.0
#r "nuget: DotnetOmar.Translation, 1.3.0"
// 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
Feedback
If you have any feedback, please reach out to us at challengeromar97@gmail.com
Product | Versions 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. |
-
net8.0
- LinqKit (>= 1.2.5)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 8.0.4)
- Microsoft.EntityFrameworkCore.SqlServer (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
initialize version