Sure! I'll help you integrate translations into your Laravel Blade template by updating the en.json and ar.json translation files and modifying your index.blade.php (assuming that's your main Blade template) to utilize these translations.
1. Translation Files
resources/lang/en.json
{
"Sas Radius Pro Dashboard": "Sas Radius Pro Dashboard",
"logo": "Logo",
"user_profile": "User Profile",
"Home": "Home",
"Messages": "Messages",
"Client List | Found :count entries": "Client List | Found :count entries",
"Template List | Found :count entries": "Template List | Found :count entries",
"Message Settings": "Message Settings",
"Country Code": "Country Code",
"Egypt": "Egypt",
"Libya": "Libya",
"Iraq": "Iraq",
"UAE": "UAE",
"Saudi Arabia": "Saudi Arabia",
"Messaging Service": "Messaging Service",
"Additional keys you can use": "Additional keys you can use",
"Profile": "Profile",
"Expiration Date": "Expiration Date",
"Username": "Username",
"First Name": "First Name",
"Usage Example": "Usage Example",
"Hello": "Hello",
"the": "the",
"monthly package has been activated and will expire on": "the monthly package has been activated and will expire on",
"The client will receive it like this": "The client will receive it like this",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "Hello Yasser, the 50GB monthly package has been activated and will expire on",
"Activation Message": "Activation Message",
"Expiry Message": "Expiry Message",
"About to Expire Subscription": "About to Expire Subscription",
"Upon Subscription Activation": "Upon Subscription Activation",
"Upon Package Renewal": "Upon Package Renewal",
"Upon Package Change": "Upon Package Change",
"Upon Client Deposit": "Upon Client Deposit",
"Upon Withdrawal from Client Balance": "Upon Withdrawal from Client Balance",
"Upon Editing Client Data": "Upon Editing Client Data",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "Upon Adding or Removing Consumption Capacities (GB) for Client",
"Upon Client Deletion": "Upon Client Deletion",
"Upon Manager Login": "Upon Manager Login",
"Upon Manager Deposit": "Upon Manager Deposit",
"Upon Withdrawal from Manager Balance": "Upon Withdrawal from Manager Balance",
"Aggressive Messaging": "Aggressive Messaging",
"Operation Number": "Operation Number",
"Account Symbol": "Account Symbol",
"Last Name": "Last Name",
"Package": "Package",
"Balance": "Balance",
"Return to Menu": "Return to Menu",
"Card Activation Confirmation Message": "Card Activation Confirmation Message",
"Insufficient Balance for Package Activation Message": "Insufficient Balance for Package Activation Message",
"Package Activation Data Message": "Package Activation Data Message",
"Package Activation Confirmation Message": "Package Activation Confirmation Message",
"Enable Card Charging": "Enable Card Charging",
"Menu Message": "Menu Message",
"Successful Card Activation Message": "Successful Card Activation Message",
"Card Entry Request Message": "Card Entry Request Message",
"Bot Preferences": "Bot Preferences",
"Message Sent Successfully!": "Message Sent Successfully!",
"Operations": "Operations",
"Add": "Add",
"View": "View",
"Send Message": "Send Message",
"Change Group": "Change Group",
"Reload": "Reload",
"Filter": "Filter",
"Template": "Template",
"Message": "Message",
"Creation Date": "Creation Date",
"Name": "Name",
"Group": "Group",
"Phone": "Phone",
"Phones": "Phones",
"Notes": "Notes",
"Delete": "Delete",
"Delete Confirmation": "Delete Confirmation",
"Are you sure you want to delete the selected groups?": "Are you sure you want to delete the selected groups?",
"Confirm": "Confirm",
"Cancel": "Cancel",
"Profile data sent successfully:": "Profile data sent successfully:",
"Error sending profile data:": "Error sending profile data:",
"Button with id \"aview\" not found.": "Button with id \"aview\" not found.",
"Modal element not provided.": "Modal element not provided.",
"Element with ID \"deleteConfirmationModal\" not found.": "Element with ID \"deleteConfirmationModal\" not found.",
"Element with ID \"confirmDelete\" not found.": "Element with ID \"confirmDelete\" not found.",
"Element with ID \"deletebtn\" not found.": "Element with ID \"deletebtn\" not found.",
"Element with ID \"selectAllcheckbox\" not found.": "Element with ID \"selectAllcheckbox\" not found.",
"No checkboxes found.": "No checkboxes found.",
"Please select at least one client to delete.": "Please select at least one client to delete.",
"Selected clients have been successfully deleted.": "Selected clients have been successfully deleted.",
"Error deleting clients: ": "Error deleting clients: ",
"An error occurred while deleting clients.": "An error occurred while deleting clients.",
"No Group": "No Group",
"Default selected": "Default selected",
"Unexpected value, setting to default": "Unexpected value, setting to default",
"Enable Account Balance Display": "Enable Account Balance Display",
"Card Charging": "Card Charging",
"Operation Confirmation": "Operation Confirmation",
"Settings have been saved successfully!": "Settings have been saved successfully!",
"An error occurred:": "An error occurred:",
"An unexpected error occurred.": "An unexpected error occurred.",
"Operation data sent successfully:": "Operation data sent successfully:",
"Error in sending operation data:": "Error in sending operation data:"
}
resources/lang/ar.json
{
"Sas Radius Pro Dashboard": "Sas Radius Pro Dashboard",
"logo": "شعار",
"user_profile": "ملف المستخدم",
"Home": "الرئيسيه",
"Messages": "الرسائل",
"Client List | Found :count entries": "قائمة العملاء | عثر على :count قيد",
"Template List | Found :count entries": "قائمة القوالب | عثر على :count قيد",
"Message Settings": "إعدادات الرسائل",
"Country Code": "كود الدولة",
"Egypt": "مصر",
"Libya": "ليبيا",
"Iraq": "العراق",
"UAE": "الإمارات",
"Saudi Arabia": "السعودية",
"Messaging Service": "خدمة الرسائل",
"Additional keys you can use": "مفاتيح إضافية يمكنك استخدامها",
"Profile": "البروفايل",
"Expiration Date": "تاريخ الانتهاء",
"Username": "اسم المستخدم",
"First Name": "الاسم الأول",
"Usage Example": "مثال للاستخدام",
"Hello": "مرحبا",
"the": "ال",
"monthly package has been activated and will expire on": "باقة :srv الشهرية تم تفعيلها وسوف تنتهي بتاريخ :exp",
"The client will receive it like this": "سوف يصل إلى العميل بهذا الشكل",
"Hello Yasser, the 50GB monthly package has been activated and will expire on": "مرحبا ياسر، باقة 50 جيجابايت الشهرية تم تفعيلها وسوف تنتهي بتاريخ 2022-12-01 12:00:00",
"Activation Message": "رسالة التفعيل",
"Expiry Message": "رسالة انتهاء الصلاحية",
"About to Expire Subscription": "اشتراك على وشك الانتهاء",
"Upon Subscription Activation": "عند تفعيل الاشتراك",
"Upon Package Renewal": "عند تجديد الباقة",
"Upon Package Change": "عند تغيير الباقة",
"Upon Client Deposit": "عند إيداع العميل",
"Upon Withdrawal from Client Balance": "عند السحب من رصيد العميل",
"Upon Editing Client Data": "عند تعديل بيانات العميل",
"Upon Adding or Removing Consumption Capacities (GB) for Client": "عند إضافة أو إزالة سعات استهلاك (جيجابايت) للعميل",
"Upon Client Deletion": "عند حذف العميل",
"Upon Manager Login": "عند تسجيل دخول المدير",
"Upon Manager Deposit": "عند إيداع المدير",
"Upon Withdrawal from Manager Balance": "عند السحب من رصيد المدير",
"Aggressive Messaging": "الرسائل العنيفة",
"Operation Number": "رقم العملية",
"Account Symbol": "رمز الحساب",
"Last Name": "الاسم الأخير",
"Package": "باقة",
"Balance": "الرصيد",
"Return to Menu": "العودة إلى القائمة",
"Card Activation Confirmation Message": "رسالة تأكيد تفعيل البطاقة",
"Insufficient Balance for Package Activation Message": "رصيد غير كافٍ لتفعيل الباقة",
"Package Activation Data Message": "رسالة بيانات تفعيل الباقة",
"Package Activation Confirmation Message": "رسالة تأكيد تفعيل الباقة",
"Enable Card Charging": "تمكين شحن البطاقة",
"Menu Message": "رسالة القائمة",
"Successful Card Activation Message": "رسالة تفعيل البطاقة الناجحة",
"Card Entry Request Message": "رسالة طلب إدخال البطاقة",
"Bot Preferences": "تفضيلات الروبوت",
"Message Sent Successfully!": "تم إرسال الرسالة بنجاح!",
"Operations": "العمليات",
"Add": "إضافة",
"View": "عرض",
"Send Message": "إرسال رسالة",
"Change Group": "تغيير المجموعة",
"Reload": "إعادة تحميل",
"Filter": "تصفية",
"Template": "القالب",
"Message": "الرسالة",
"Creation Date": "تاريخ الإنشاء",
"Name": "الاسم",
"Group": "المجموعة",
"Phone": "الهاتف",
"Phones": "الهواتف",
"Notes": "ملاحظات",
"Delete": "حذف",
"Delete Confirmation": "تأكيد الحذف",
"Are you sure you want to delete the selected groups?": "هل أنت متأكد من حذف المجموعات المحددة؟",
"Confirm": "موافق",
"Cancel": "إلغاء",
"Profile data sent successfully:": "تم إرسال بيانات الملف الشخصي بنجاح:",
"Error sending profile data:": "خطأ في إرسال بيانات الملف الشخصي:",
"Button with id \"aview\" not found.": "لم يتم العثور على الزر بمعرف \"aview\".",
"Modal element not provided.": "لم يتم توفير عنصر المودال.",
"Element with ID \"deleteConfirmationModal\" not found.": "لم يتم العثور على العنصر بمعرف \"deleteConfirmationModal\".",
"Element with ID \"confirmDelete\" not found.": "لم يتم العثور على العنصر بمعرف \"confirmDelete\".",
"Element with ID \"deletebtn\" not found.": "لم يتم العثور على العنصر بمعرف \"deletebtn\".",
"Element with ID \"selectAllcheckbox\" not found.": "لم يتم العثور على العنصر بمعرف \"selectAllcheckbox\".",
"No checkboxes found.": "لم يتم العثور على مربعات اختيار.",
"Please select at least one client to delete.": "الرجاء تحديد عميل واحد على الأقل للحذف.",
"Selected clients have been successfully deleted.": "تم حذف العملاء المحددين بنجاح.",
"Error deleting clients: ": "خطأ في حذف العملاء: ",
"An error occurred while deleting clients.": "حدث خطأ أثناء حذف العملاء.",
"No Group": "لا توجد مجموعة",
"Default selected": "تم تحديد الافتراضي",
"Unexpected value, setting to default": "قيمة غير متوقعة، سيتم التعيين على الافتراضي",
"Enable Account Balance Display": "تمكين عرض رصيد الحساب",
"Card Charging": "شحن البطاقة",
"Operation Confirmation": "تأكيد العملية",
"Settings have been saved successfully!": "تم حفظ الإعدادات بنجاح!",
"An error occurred:": "حدث خطأ:",
"An unexpected error occurred.": "حدث خطأ غير متوقع.",
"Operation data sent successfully:": "تم إرسال بيانات العملية بنجاح:",
"Error in sending operation data:": "خطأ في إرسال بيانات العملية:"
}
2. Updated Blade Template (index.blade.php)
Below is the updated Blade template incorporating the translations using the __ helper function. This assumes that all the necessary translation keys exist in your en.json and ar.json files.
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}" dir="{{ app()->getLocale() == 'ar' ? 'rtl' : 'ltr' }}">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ __('Sas Radius Pro Dashboard') }}</title>
<link rel="stylesheet" href="{{ asset('css/style.css') }}" />
<!-- bootstrap -->
<link rel="stylesheet" href="{{ asset('css/bootstrap.css') }}" />
<script src="{{ asset('js/bootstrap.js') }}"></script>
<!-- font awesome -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</head>
<body>
<main>
<div class="overflow_sidebar"></div>
<!-- start sidebar -->
<div class="sidebar">
@include('include.sidebar')
</div>
<!-- end sidebar -->
<div class="content_page">
<div class="header">
<div class="left">
<div class="icon_menu">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"
/>
</svg>
</div>
<div class="logo_header">
<img src="{{ asset('images/logo.png') }}" alt="{{ __('logo') }}" loading="lazy" />
</div>
<div class="input_search">
<input type="text" placeholder="{{ __('Search...') }}" />
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
/>
</svg>
</div>
</div>
<div class="right">
@include('include.translation')
<div class="notification">
<div class="head">
<div class="icon">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0M3.124 7.5A8.969 8.969 0 015.292 3m13.416 0a8.969 8.969 0 012.168 4.5"
/>
</svg>
</div>
</div>
</div>
<div class="nav_item">
<div class="head">
<img
class="img_profile"
src="{{ asset('images/user-1.jpg') }}"
alt="{{ __('user_profile') }}"
loading="lazy"
/>
</div>
@include('include.profile')
</div>
</div>
</div>
<div class="home_section">
<div class="main_boxs">
<div class="row">
<div class="col-12 col-md-6">
<div class="box">
<div class="text">
<div class="icon">
<i class="fa-solid fa-calendar-day"></i>
</div>
<h4 class="title">{{ __('الايام المتبقية') }}</h4>
<p class="desc">{{ __('نسبة ما تبقى من ايام') }}</p>
<span>{{ __('اكثر افضل') }}</span>
</div>
<div class="progress_container text-center">
<circle-progress value="70" max="100"></circle-progress>
</div>
</div>
</div>
<div class="col-12 col-md-6">
<div class="box">
<div class="text">
<div class="icon">
<i class="fa-solid fa-chart-simple"></i>
</div>
<h4 class="title">{{ __('استهلاك النقاط اليومى') }}</h4>
<p class="desc">{{ __('نسبة ما تم استهلاكه من نقاط اليوم') }}</p>
<span>{{ __('اقل افضل') }}</span>
</div>
<div class="progress_container text-center">
<circle-progress value="50" max="1500"></circle-progress>
</div>
</div>
</div>
</div>
</div>
<div class="boxs">
<div class="box">
<div class="text">
<h5 class="title">{{ __('العملاء') }}</h5>
<h3 class="num">{{ $customers }}</h3>
</div>
<div class="icon">
<i class="fa-solid fa-user-group"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('المجموعات') }}</h5>
<h3 class="num">{{ $groups }}</h3>
</div>
<div class="icon">
<i class="fa-solid fa-users"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('الرسائل') }}</h5>
<h3 class="num">{{ $messages }}</h3>
</div>
<div class="icon">
<i class="fa-solid fa-envelope-open-text"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('رسائل اليوم') }}</h5>
<h3 class="num">2</h3>
</div>
<div class="icon">
<i class="fa-solid fa-comment-sms"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('حالة الجلسة') }}</h5>
<h3 class="num">{{ __('غير متصله') }}</h3>
</div>
<div class="icon">
<i class="fa-solid fa-mobile"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('رسائل الشهر الحالى') }}</h5>
<h3 class="num">0</h3>
</div>
<div class="icon">
<i class="fa-solid fa-envelope"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('الهواتف') }}</h5>
<h3 class="num">0</h3>
</div>
<div class="icon">
<i class="fa-solid fa-mobile-screen"></i>
</div>
</div>
<div class="box">
<div class="text">
<h5 class="title">{{ __('الرصيد') }}</h5>
<h3 class="num">0</h3>
</div>
<div class="icon">
<i class="fa-solid fa-credit-card"></i>
</div>
</div>
</div>
<div class="bottom_boxs">
<div class="box_analysis">
<div class="head">
<form action="">
<div class="btns_select">
<button type="button" class="btn_select">{{ __('شهري') }}</button>
<button type="button" class="btn_select">{{ __('يومي') }}</button>
</div>
<select class="select_month">
<option value="1">{{ __('يناير') }}</option>
<option value="2">{{ __('فبراير') }}</option>
<option value="3">{{ __('مارس') }}</option>
<option value="4">{{ __('أبريل') }}</option>
<option value="5">{{ __('مايو') }}</option>
<option value="6">{{ __('يونيو') }}</option>
<option value="7">{{ __('يوليو') }}</option>
<option value="8">{{ __('أغسطس') }}</option>
<option value="9">{{ __('سبتمبر') }}</option>
<option value="10">{{ __('أكتوبر') }}</option>
<option value="11">{{ __('نوفمبر') }}</option>
<option value="12">{{ __('ديسمبر') }}</option>
</select>
<select class="select_year">
<option value="2023">2023</option>
<option value="2022">2022</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
</select>
</form>
</div>
<div id="container-chart" class="chart"></div>
</div>
</div>
</div>
</div>
</main>
<script src="{{ asset('js/boxs-header.js') }}"></script>
<script src="{{ asset('js/sidebar.js') }}"></script>
<script
src="https://cdn.jsdelivr.net/npm/js-circle-progress/dist/circle-progress.min.js"
type="module"
></script>
<script>
new CircleProgress(".progress", {
max: 100,
value: 60,
textFormat: "percent",
});
</script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script>
Highcharts.chart("container-chart", {
chart: {
type: "line",
},
title: {
text: "{{ __('Traffic Report') }}",
},
subtitle: {
text:
"{{ __('Source:') }}" +
' <a href="https://en.wikipedia.org/wiki/List_of_cities_by_average_temperature" ' +
'target="_blank">{{ __('Wikipedia.com') }}</a>',
},
xAxis: {
categories: [
"{{ __('Jan') }}",
"{{ __('Feb') }}",
"{{ __('Mar') }}",
"{{ __('Apr') }}",
"{{ __('May') }}",
"{{ __('Jun') }}",
"{{ __('Jul') }}",
"{{ __('Aug') }}",
"{{ __('Sep') }}",
"{{ __('Oct') }}",
"{{ __('Nov') }}",
"{{ __('Dec') }}",
],
},
yAxis: {
title: {
text: "{{ __('Temperature (°C)') }}",
},
},
plotOptions: {
line: {
dataLabels: {
enabled: true,
},
enableMouseTracking: false,
},
},
series: [
{
name: "{{ __('Reggane') }}",
data: [
16.0, 18.2, 23.1, 27.9, 32.2, 36.4, 39.8, 38.4, 35.5, 29.2, 22.0,
17.8,
],
},
],
});
</script>
</body>
</html>
3. Additional Notes
-
Using the __ Helper:
- The
__ helper function is used to fetch translations from your JSON files.
- For example,
{{ __('Home') }} will display "Home" in English and "الرئيسيه" in Arabic based on the current locale.
-
Handling Dynamic Content:
-
Asset Management:
- Use Laravel's
asset helper to manage your CSS and JS file paths, ensuring they work correctly regardless of your application's directory structure.
-
RTL Support:
- You've already set the
dir attribute based on the locale, which is excellent for handling right-to-left (RTL) languages like Arabic.
-
Ensure All Translations Exist:
- Double-check that all text strings in your Blade template have corresponding keys in both
en.json and ar.json. Missing translations will default to the key name.
-
Translations for Chart Titles and Labels:
- If you have dynamic or JavaScript-rendered text (like chart titles), ensure they're also translated. In the provided template, I've wrapped them with the
__('') helper.
-
Handling Non-Translated Texts:
-
In your original HTML, some texts like "Search...", "Traffic Report", months, and chart labels were in English or Arabic directly. Ensure that these are also included in your translation files:
Add to en.json:
{
"Search...": "Search...",
"Traffic Report": "Traffic Report",
"Wikipedia.com": "Wikipedia.com",
"Jan": "Jan",
"Feb": "Feb",
"Mar": "Mar",
"Apr": "Apr",
"May": "May",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Aug",
"Sep": "Sep",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dec",
"Temperature (°C)": "Temperature (°C)",
"Reggane": "Reggane"
}
Add to ar.json:
{
"Search...": "بحث...",
"Traffic Report": "تقرير المرور",
"Wikipedia.com": "ويكيبيديا.كوم",
"Jan": "يناير",
"Feb": "فبراير",
"Mar": "مارس",
"Apr": "أبريل",
"May": "مايو",
"Jun": "يونيو",
"Jul": "يوليو",
"Aug": "أغسطس",
"Sep": "سبتمبر",
"Oct": "أكتوبر",
"Nov": "نوفمبر",
"Dec": "ديسمبر",
"Temperature (°C)": "درجة الحرارة (°م)",
"Reggane": "رجان"
}
4. Final Steps
-
Save the Translation Files:
- Place the
en.json and ar.json files in their respective language directories:
resources/lang/en.json
resources/lang/ar.json
-
Update the Blade Template:
- Replace your existing
index.blade.php with the updated version provided above or integrate the changes accordingly.
-
Test the Translations:
- Switch between English and Arabic locales in your application to ensure that translations appear correctly.
-
Add Missing Translations:
- If you encounter any untranslated strings, add the necessary keys and translations to both
en.json and ar.json.
By following these steps, your dashboard should now support both English and Arabic languages seamlessly.