hesabixWpTheme/inc/woocommerce-i18n-fa.php
2026-05-22 13:52:15 +03:30

710 lines
41 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* فارسی‌سازی رابطٔ WooCommerce — برای localeهای fa؛ در gettext وقتی ترجمهٔ رسمی نباشد یا همان انگلیسی باشد،
* و برای اسکریپت‌های بلوک (React) با تزریق/ادغام JSON مخصوص wp.i18n.
*
* @package Hesabix2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* آیا فارسی‌ساز ووکامرس فعال شود؟ (فقط وقتی locale سایت با fa شروع شود.)
*/
function hesabix2_wc_fa_should_apply() {
$loc = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
return is_string( $loc ) && str_starts_with( strtolower( $loc ), 'fa' );
}
/**
* نقشهٔ رشتهٔ ساده (gettext).
*
* @return array<string, string>
*/
function hesabix2_wc_fa_get_string_map() {
$map = array(
// مینی‌سبد و سبد
'No products in the cart.' => 'سبد خرید شما خالی است.',
'Your cart is currently empty.' => 'سبد خرید شما در حال حاضر خالی است.',
'Your cart is currently empty!' => 'سبد خرید شما خالی است!',
'Proceed to checkout' => 'ادامه به تسویه‌حساب',
'Proceed to Checkout' => 'ادامه به تسویه‌حساب',
'Updating cart&hellip;' => 'به‌روزرسانی سبد…',
'View cart' => 'مشاهدهٔ سبد خرید',
'Checkout' => 'تسویه‌حساب',
'Subtotal:' => 'جمع جزء:',
'Cart totals' => 'جمع کل سبد',
'Add coupons' => 'افزودن کد تخفیف',
'Remove' => 'حذف',
'Order summary' => 'خلاصهٔ سفارش',
'Contact information' => 'اطلاعات تماس',
'Shipping address' => 'آدرس ارسال',
'Billing address' => 'آدرس صورت‌حساب',
'Payment method' => 'روش پرداخت',
'Discount' => 'تخفیف',
'Fees' => 'هزینه‌ها',
'Estimated total' => 'جمع تقریبی',
'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.' => 'هیچ روش ارسالی در دسترس نیست. لطفاً آدرس را بررسی کنید یا با ما تماس بگیرید.',
'There are no payment methods available. This may be an error on our side. Please contact us if you need any help placing your order.' => 'هیچ روش پرداختی فعال نیست. لطفاً با پشتیبانی تماس بگیرید.',
'Submit' => 'ارسال',
'Save' => 'ذخیره',
'Edit' => 'ویرایش',
'Close' => 'بستن',
'Show' => 'نمایش',
'Hide' => 'پنهان',
'Create an account?' => 'ایجاد حساب کاربری؟',
'Create an account with %s' => 'ایجاد حساب در %s',
'Add a note to your order' => 'یادداشت برای سفارش',
'Notes about your order, e.g. special notes for delivery.' => 'یادداشت دربارهٔ سفارش، برای مثال زمان یا محل تحویل.',
'Add to order' => 'افزودن به سفارش',
'Use another payment method.' => 'استفاده از روش پرداخت دیگر.',
'Shipping options' => 'روش‌های ارسال',
'Payment options' => 'روش‌های پرداخت',
'Delivery' => 'تحویل',
'Pickup' => 'تحویل حضوری',
'Free' => 'رایگان',
'Including %s' => 'شامل %s',
'Sales tax' => 'مالیات فروش',
'Remove coupon %s' => 'حذف کوپن %s',
'Multiple shipments must have the same pickup location' => 'برای چند مرسوله، محل تحویل باید یکسان باشد.',
'Loading shipping rates…' => 'بارگذاری هزینهٔ ارسال…',
'Something went wrong. Please contact us to get assistance.' => 'خطایی رخ داد. لطفاً با پشتیبانی تماس بگیرید.',
'Continue shopping' => 'ادامهٔ خرید',
'Remove this item' => 'حذف این قلم',
'Remove %s from cart' => 'حذف %s از سبد',
'&ldquo;%s&rdquo; has been removed from your cart' => '«%s» از سبد شما حذف شد.',
'Shipping' => 'حمل و نقل',
'Total' => 'جمع کل',
'and' => 'و',
'Coupon: %s' => 'تخفیف: %s',
'Free shipping coupon' => 'کوپن ارسال رایگان',
'Remove %s coupon' => 'حذف کوپن %s',
'[Remove]' => '[حذف]',
'This product is protected and cannot be purchased.' => 'این محصول محافظت شده و قابل خرید نیست.',
// فروشگاه و آرشیو
'Shop' => 'فروشگاه',
'Default sorting' => 'مرتب‌سازی پیش‌فرض',
'Default' => 'پیش‌فرض',
'Sort by popularity' => 'محبوب‌ترین',
'Sort by average rating' => 'میانگین امتیاز',
'Sort by latest' => 'جدیدترین',
'Sort by price: low to high' => 'ارزان‌ترین',
'Sort by price: high to low' => 'گران‌ترین',
'Sorted by popularity' => 'به‌ترتیب محبوبیت',
'Sorted by average rating' => 'به‌ترتیب میانگین امتیاز',
'Sorted by latest' => 'به‌ترتیب جدیدترین',
'Sorted by price: low to high' => 'به‌ترتیب قیمت: کم به زیاد',
'Sorted by price: high to low' => 'به‌ترتیب قیمت: زیاد به کم',
'Relevance' => 'مرتبط‌ترین',
'Showing all %1$d result' => 'نمایش مجموع %1$d نتیجه',
'Showing all %1$d results' => 'نمایش مجموع %1$d نتیجه',
'Showing the single result' => 'نمایش یک نتیجه',
// محصول
'Add to cart' => 'افزودن به سبد',
'Read more' => 'جزئیات بیشتر',
'Rated %s out of 5' => 'امتیاز %s از ۵',
'Sale!' => 'تخفیف!',
'New!' => 'جدید!',
'SKU:' => 'کد محصول:',
'n/a' => '—',
'N/A' => '—',
'Description' => 'توضیحات',
'Additional information' => 'اطلاعات تکمیلی',
'Reviews' => 'دیدگاه‌ها',
'Reviews (%d)' => 'دیدگاه‌ها (%d)',
'Select options' => 'انتخاب گزینه‌ها',
'Weight' => 'وزن',
'Dimensions' => 'ابعاد',
'Availability:' => 'موجودی:',
'In stock' => 'موجود',
'Out of stock' => 'ناموجود',
'Only %s left in stock' => 'تنها %s عدد موجود است',
'Available on backorder' => 'قابل پیش‌سفارش',
'Pages:' => 'صفحات:',
// سبد خطا / نکات رایج
'Dismiss' => 'بستن',
'This is a demo store for testing purposes &mdash; no orders shall be fulfilled.' => 'این یک فروشگاه آزمایشی است؛ سفارش‌ها واقعی نیست.',
'Store notice' => 'اعلان فروشگاه',
'Search results: &ldquo;%s&rdquo;' => 'نتایج جستجو: «%s»',
// پرداخت
'Place order' => 'ثبت سفارش',
'Place Order' => 'ثبت سفارش',
'Returning customer?' => 'قبلاً ثبت‌نام کرده‌اید؟',
'Click here to login' => 'برای ورود اینجا کلیک کنید',
'Have a coupon?' => 'کد تخفیف دارید؟',
'Enter your coupon code' => 'کد تخفیف خود را وارد کنید',
'Click here to enter your code' => 'برای وارد کردن کد کلیک کنید',
'Coupon code' => 'کد تخفیف',
'Apply coupon' => 'اعمال کد',
'Coupon code applied successfully.' => 'کد تخفیف با موفقیت اعمال شد.',
'Removing coupon&hellip;' => 'حذف کد تخفیف…',
'Billing details' => 'جزئیات صورت‌حساب',
'Ship to a different address?' => 'ارسال به آدرس دیگر؟',
'Order notes (optional)' => 'یادداشت سفارش (اختیاری)',
'Your order' => 'سفارش شما',
'privacy policy' => 'حریم خصوصی',
'terms and conditions' => 'قوانین و مقررات',
'optional' => 'اختیاری',
'Select a country / region&hellip;' => 'کشور یا منطقه را انتخاب کنید…',
'Update country / region' => 'به‌روزرسانی کشور/منطقه',
'Select an option&hellip;' => 'گزینه‌ای انتخاب کنید…',
'Choose an option' => 'انتخاب گزینه',
// پس از پرداخت
'Thank you. Your order has been received.' => 'سپاس؛ سفارش شما ثبت شد.',
'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.' => 'متأسفانه پردازش سفارش به‌دلیل رد شدن تراکنش توسط درگاه یا بانک ممکن نیست. لطفاً مجدداً تلاش کنید.',
'Pay' => 'پرداخت',
'My account' => 'حساب کاربری',
// حساب کاربری
'Dashboard' => 'پیشخوان',
'Orders' => 'سفارش‌ها',
'Downloads' => 'دانلودها',
'Addresses' => 'آدرس‌ها',
'Payment methods' => 'روش‌های پرداخت',
'Account details' => 'جزئیات حساب',
'Logout' => 'خروج از حساب',
// رایج عمومی ووکامرس
'Coupon:' => 'تخفیف:',
'Download' => 'دانلود',
'Page' => 'صفحه',
// جدول سبد خرید
'Remove item' => 'حذف قلم',
'Thumbnail image' => 'تصویر بندانگشتی',
'Product' => 'محصول',
'Price' => 'قیمت',
'Quantity' => 'تعداد',
'Subtotal' => 'جمع جزء',
'Update cart' => 'به‌روزرسانی سبد',
'Tax' => 'مالیات',
'(estimated for %s)' => '(برآورد برای %s)',
// حساب کاربری — سفارش‌ها
'Order' => 'سفارش',
'Date' => 'تاریخ',
'Status' => 'وضعیت',
'Actions' => 'عملیات',
'%1$s order number %2$s' => '%1$s — سفارش شمارهٔ %2$s',
'View order number %s' => 'مشاهدهٔ سفارش شمارهٔ %s',
'Previous' => 'قبلی',
'Next' => 'بعدی',
'No order has been made yet.' => 'هنوز سفارشی ثبت نشده است.',
'Browse products' => 'مشاهدهٔ محصولات',
// اقدامات سفارش (برچسب دکمهٔ «مشاهده» و غیره)
'View' => 'مشاهده',
'Cancel' => 'لغو',
'Downloads remaining' => 'دانلودهای باقی‌مانده',
'Expires' => 'انقضا',
// ورود Checkout / فرم‌ها
'You must be logged in to checkout.' => 'برای تکمیل خرید باید وارد حساب خود شوید.',
'Username or email' => 'نام کاربری یا ایمیل',
'Password' => 'گذرواژه',
'Required' => 'الزامی',
'Remember me' => 'مرا به‌خاطر بسپار',
'Login' => 'ورود',
'Lost your password?' => 'گذرواژه را فراموش کرده‌اید؟',
// صفحهٔ تشکر
'Order number:' => 'شمارهٔ سفارش:',
'Date:' => 'تاریخ:',
'Email:' => 'ایمیل:',
'Total:' => 'جمع:',
'Payment method:' => 'روش پرداخت:',
// تسویه و آدرس (فیلدهای پیش‌فرض ووکامرس)
'Billing &amp; Shipping' => 'صورت‌حساب و ارسال',
'First name' => 'نام',
'Last name' => 'نام خانوادگی',
'Company name' => 'نام شرکت',
'Country / Region' => 'کشور / منطقه',
'Street address' => 'آدرس پستی',
'House number and street name' => 'پلاک و نام خیابان',
'Apartment, suite, unit, etc.' => 'واحد، بلوک و غیره',
'Apartment, suite, unit, etc. (optional)' => 'واحد، بلوک (اختیاری)',
'Town / City' => 'شهر',
'State / County' => 'استان',
'Postcode / ZIP' => 'کد پستی',
'(incl. tax)' => '(شامل مالیات)',
'(ex. tax)' => '(بدون مالیات)',
'(incl. VAT)' => '(شامل VAT)',
'(ex. VAT)' => '(بدون VAT)',
'VAT' => 'مالیات بر ارزش افزوده',
// برچسب‌های روش ارسال و جمع بلوک سبد/پرداخت (و Json اسکریپت)
'Free shipping' => 'ارسال رایگان',
'Flat rate shipping' => 'ارسال با نرخ ثابت',
'Local pickup' => 'تحویل حضوری از فروشگاه',
'Calculated at checkout' => 'محاسبه در تسویه‌حساب',
'Shipping will be calculated at checkout' => 'هزینهٔ ارسال در تسویه‌حساب محاسبه می‌شود',
'Fees:' => 'هزینه‌ها:',
'Taxes:' => 'مالیات‌ها:',
'Discount:' => 'تخفیف:',
'Coupon form' => 'فرم کد تخفیف',
'Apply' => 'اعمال',
'Applying coupon…' => 'در حال اعمال کد…',
'Removing coupon…' => 'در حال حذف کد…',
'Enter code' => 'کد را وارد کنید',
'Coupons' => 'کدهای تخفیف',
'Products in cart' => 'محصولات در سبد',
'Filled Cart' => 'سبد پر',
'Empty Cart' => 'سبد خالی',
'Cart' => 'سبد خرید',
'Including' => 'شامل',
'Including <TaxAmount/> in taxes' => 'شامل <TaxAmount/> در مالیات',
'Loading price… ' => 'بارگذاری قیمت… ',
'Details' => 'جزئیات',
'Read less' => 'کمتر',
'Oops!' => 'اوه!',
'Error:' => 'خطا:',
'Dismiss this notice' => 'بستن این پیام',
'Return to Cart' => 'بازگشت به سبد',
'Browse store' => 'مشاهده فروشگاه',
'Log in' => 'ورود',
'Click here to log in.' => 'برای ورود اینجا کلیک کنید.',
'Privacy Policy' => 'حریم خصوصی',
'Terms and Conditions' => 'قوانین و مقررات',
'Billing and shipping address' => 'آدرس صورت‌حساب و ارسال',
'Additional order information' => 'اطلاعات تکمیلی سفارش',
'Notes about your order.' => 'یادداشت دربارهٔ سفارش.',
'Enter a shipping address to view shipping options.' => 'برای مشاهدهٔ گزینه‌های ارسال، آدرس ارسال را وارد کنید.',
'No shipping options are available for this address. Please verify the address is correct or try a different address.' => 'برای این آدرس روش ارسالی وجود ندارد. آدرس را بررسی کنید یا آدرس دیگری امتحان کنید.',
'Shipping options are not available' => 'روش ارسال در دسترس نیست',
'Pickup locations' => 'مراکز تحویل حضوری',
'Edit your cart' => 'ویرایش سبد',
'Edit billing address' => 'ویرایش آدرس صورت‌حساب',
'Edit shipping address' => 'ویرایش آدرس ارسال',
'Ship' => 'ارسال',
'Retry' => 'تلاش دوباره',
' Fee' => ' هزینه',
' Express Checkout' => ' پرداخت سریع',
'Finish checkout' => 'اتمام تسویه‌حساب',
'Buy product' => 'خرید محصول',
'No Reviews' => 'بدون دیدگاه',
'Rated %f out of 5' => 'امتیاز %f از ۵',
'Product on sale' => 'محصول حراج',
'Sale' => 'حراج',
'Link to %s' => 'پیوند به %s',
'Shopping cart.' => 'سبد خرید.',
'WooCommerce' => 'ووکامرس',
'Something went wrong. Please contact us for assistance.' => 'خطایی رخ داد. لطفاً با پشتیبانی تماس بگیرید.',
'The cart has encountered an unexpected error. If the error persists, please get in touch with us for help.' => 'سبد با خطای غیرمنتظره مواجه شد. در صورت تداوم با پشتیبانی تماس بگیرید.',
'Reload the page' => 'بارگذاری دوبارهٔ صفحه',
'Totals will be recalculated when a valid shipping method is selected.' => 'با انتخاب روش ارسال معتبر، جمع‌ها دوباره محاسبه می‌شوند.',
'Please fix the following errors before continuing' => 'قبل از ادامه، خطاهای زیر را برطرف کنید',
'Please enter a valid email address' => 'ایمیل معتبر وارد کنید',
'Please enter a valid postcode' => 'کدپستی معتبر وارد کنید',
'Please select your country' => 'کشور را انتخاب کنید',
'Increase quantity of %s' => 'افزایش تعداد %s',
'Reduce quantity of %s' => 'کاهش تعداد %s',
'Quantity of %s in your cart.' => 'تعداد %s در سبد شما.',
'Quantity increased to %s.' => 'تعداد به %s افزایش یافت.',
'Quantity reduced to %s.' => 'تعداد به %s کاهش یافت.',
'%s has been removed from your cart.' => '%s از سبد شما حذف شد.',
'Save %s' => 'ذخیره %s',
'Loading shipping options…' => 'بارگذاری گزینه‌های ارسال…',
'Loading products in cart…' => 'بارگذاری محصولات سبد…',
'Loading payment options… ' => 'بارگذاری روش‌های پرداخت… ',
'There was an error loading the content.' => 'خطا در بارگذاری محتوا.',
'Checkout is not available whilst your cart is empty—please take a look through our store and come back when you\'re ready to place an order.' => 'وقتی سبد خالی است تسویه‌حساب ممکن نیست؛ فروشگاه را ببینید و پس از افزودن کالا برگردید.',
'Create a password' => 'ایجاد گذرواژه',
'Please create a stronger password' => 'گذرواژهٔ قوی‌تر انتخاب کنید',
'Please enter a valid password' => 'گذرواژهٔ معتبر وارد کنید',
'Please read and accept the terms and conditions.' => 'لطفاً قوانین و مقررات را بپذیرید.',
'Checkout error' => 'خطای تسویه‌حساب',
// چک‌اوت بلوکی (checkout-frontend.js)
'Use same address for billing' => 'استفاده از همان آدرس برای صورت‌حساب',
'You are currently checking out as a guest.' => 'در حال تسویه به‌صورت مهمان هستید.',
'You must accept our %1$s and %2$s to continue with your purchase.' => 'برای ادامهٔ خرید باید %1$s و %2$s را بپذیرید.',
'calculated with an address' => 'محاسبه با آدرس',
'free' => 'رایگان',
'from <price />' => 'از <price />',
'By proceeding with your purchase you agree to our %1$s and %2$s' => 'با ادامهٔ خرید، %1$s و %2$s را می‌پذیرید.',
'The checkout has encountered an unexpected error. <button>Try reloading the page</button>. If the error persists, please get in touch with us so we can assist.' => 'تسویه‌حساب با خطا مواجه شد. <button>صفحه را دوباره بارگذاری کنید</button>. در صورت تداوم با پشتیبانی تماس بگیرید.',
'There is a problem with your cart' => 'مشکلی در سبد خرید وجود دارد',
'There was a problem checking out. Please try again. If the problem persists, please get in touch with us so we can assist.' => 'در تسویه‌حساب خطا رخ داد. دوباره تلاش کنید؛ در صورت تداوم با پشتیبانی تماس بگیرید.',
'Enter address to calculate' => 'برای محاسبه آدرس را وارد کنید',
'Enter the billing and shipping address that matches your payment method.' => 'آدرس صورت‌حساب و ارسال مطابق روش پرداخت را وارد کنید.',
'No available delivery option' => 'گزینهٔ تحویل در دسترس نیست',
'Step description text.' => 'متن توضیح گام.',
'Step' => 'گام',
'Note' => 'یادداشت',
'Express Payment Methods' => 'پرداخت سریع',
'No registered Payment Methods' => 'هیچ روش پرداختی ثبت نشده',
'Give us your feedback.' => 'بازخورد خود را بفرستید.',
'Feedback?' => 'بازخورد؟',
'Loading…' => 'بارگذاری…',
'Cart Block Error' => 'خطای بلوک سبد',
'Cross-Sells' => 'محصولات مکمل',
'Previous price:' => 'قیمت قبل:',
'Opens in a new tab' => 'در تب جدید باز می‌شود',
'(opens in a new tab)' => '(در تب جدید باز می‌شود)',
'Manage shipping options' => 'مدیریت گزینه‌های ارسال',
'Options that control shipping can be managed in your store settings.' => 'گزینه‌های ارسال را در تنظیمات فروشگاه مدیریت کنید.',
// سبد خالی بلوکی
'New in store' => 'جدید در فروشگاه',
'<a href="%s">Browse store</a>' => '<a href="%s">رفتن به فروشگاه</a>',
// رشته‌های مکمل بلوک سبد/پرداخت (خروجی JS)
'Your cart' => 'سبد شما',
'Order details' => 'جزئیات سفارش',
'Email address' => 'آدرس ایمیل',
'Country/Region' => 'کشور / منطقه',
'Discounted price:' => 'قیمت با تخفیف:',
'%d left in stock' => '%d عدد باقی‌مانده',
'Or' => 'یا',
'Or continue below' => 'یا ادامه در پایین',
'Phone' => 'تلفن',
'Company' => 'شرکت',
'Address line 2' => 'نشانی — طبقه / واحد',
'Optional' => 'اختیاری',
'Loading express payment method…' => 'بارگذاری روش پرداخت سریع…',
'Loading express payment area…' => 'بارگذاری بخش پرداخت سریع…',
'Processing express checkout' => 'در حال پردازش پرداخت سریع',
'Something went wrong when placing the order. Check your account\'s order history or your email for order updates before retrying.' => 'هنگام ثبت سفارش خطا رخ داد. تاریخچهٔ سفارش یا ایمیل را بررسی کنید و دوباره تلاش کنید.',
'Something went wrong when placing the order. Check your email for order updates before retrying.' => 'هنگام ثبت سفارش خطا رخ داد. ایمیل را برای وضعیت سفارش بررسی کنید.',
'There was a problem with your payment option.' => 'مشکلی در روش پرداخت وجود دارد.',
'There was a problem with your shipping option.' => 'مشکلی در روش ارسال وجود دارد.',
'Sorry, this order requires a shipping option.' => 'برای این سفارش باید روش ارسال انتخاب شود.',
'Sorry, we do not allow orders from the selected country' => 'متأسفانه از کشور انتخاب‌شده سفارش قبول نمی‌کنیم.',
'Sorry, we do not ship orders to the selected country' => 'متأسفانه به کشور انتخاب‌شده ارسال نداریم.',
'Unable to get cart data from the API.' => 'دریافت اطلاعات سبد از سرور ناموفق بود.',
'There was an error whilst rendering the cart block. If this problem continues, try re-creating the block.' => 'خطا در نمایش بلوک سبد. در صورت تکرار، بلوک را دوباره بسازید.',
'There was an error with this payment method. Please verify it\'s configured correctly.' => 'خطا در این روش پرداخت. لطفاً تنظیمات آن را بررسی کنید.',
'Only express payment methods are available for this order. Please select one to continue.' => 'فقط روش‌های پرداخت سریع برای این سفارش فعال است؛ یکی را انتخاب کنید.',
'Return to Cart button' => 'دکمهٔ بازگشت به سبد',
'Shipping Calculations' => 'محاسبهٔ هزینهٔ ارسال',
'Shipping:' => 'ارسال:',
'Taxes' => 'مالیات‌ها',
'Fee' => 'هزینه',
'Price between %1$s and %2$s' => 'قیمت بین %1$s و %2$s',
'+ Add %s' => '+ افزودن %s',
'Undo' => 'واگرد',
'Shipping Methods' => 'روش‌های ارسال',
'Shipping Zones' => 'مناطق ارسال',
'Manage payment methods' => 'مدیریت روش‌های پرداخت',
'Manage shipping methods' => 'مدیریت روش‌های ارسال',
'There are no payment methods available. Please contact us for help placing your order.' => 'هیچ روش پرداختی فعال نیست. برای ثبت سفارش با ما تماس بگیرید.',
);
return apply_filters( 'hesabix2_wc_fa_string_map', $map );
}
/**
* تبدیل نقشهٔ رشته‌ها به JSON مورد استفادهٔ wp.i18n (Jed) برای اسکریپت‌های بلوک ووکامرس.
*
* @param array<string, string> $map .
* @return string
*/
function hesabix2_wc_fa_build_jed_json( array $map ) {
$domain = 'woocommerce';
$locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
$jed = array(
'domain' => 'messages',
'locale_data' => array(
$domain => array_merge(
array(
'' => array(
'domain' => $domain,
'lang' => $locale,
'plural-forms' => 'nplurals=1; plural=0;',
'Plural-Forms' => 'nplurals=1; plural=0;',
),
),
array_map(
static function ( $translation ) {
return array( $translation );
},
$map
)
),
),
);
return (string) wp_json_encode( $jed );
}
/**
* ادغام ترجمهٔ بارگذاری‌شده از فایل رسمی با نقشهٔ محلی (برای بلوک‌ها).
*
* @param string $translations JSON خام.
* @return string
*/
function hesabix2_wc_fa_merge_jed_string_map( $translations ) {
$map = hesabix2_wc_fa_get_string_map();
if ( '' === trim( (string) $translations ) ) {
return hesabix2_wc_fa_build_jed_json( $map );
}
$data = json_decode( (string) $translations, true );
if ( ! is_array( $data ) || ! isset( $data['locale_data']['woocommerce'] ) || ! is_array( $data['locale_data']['woocommerce'] ) ) {
return hesabix2_wc_fa_build_jed_json( $map );
}
$bucket =& $data['locale_data']['woocommerce'];
foreach ( $map as $msgid => $msgstr ) {
if ( ! array_key_exists( $msgid, $bucket ) || ( isset( $bucket[ $msgid ][0] ) && $bucket[ $msgid ][0] === $msgid ) ) {
$bucket[ $msgid ] = array( $msgstr );
}
}
return (string) wp_json_encode( $data );
}
/**
* اگر فایلٔ ترجمهٔ اسکریپت وجود نداشت، JSON ساخته‌شده از نقشه برگردانده می‌شود.
*
* @param string|null|false $loaded .
* @param string|false $file .
* @param string $handle .
* @param string $domain .
* @return string|null|false
*/
function hesabix2_wc_fa_pre_load_script_translations( $loaded, $file, $handle, $domain ) {
if ( null !== $loaded ) {
return $loaded;
}
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return null;
}
if ( $file && is_readable( $file ) ) {
return null;
}
return hesabix2_wc_fa_build_jed_json( hesabix2_wc_fa_get_string_map() );
}
/**
* بعد از خواندن فایل، رشته‌های خالی/انگلیسی با نقشهٔ محلی پر می‌شوند.
*
* @param string $translations JSON.
* @param string $file .
* @param string $handle .
* @param string $domain .
* @return string
*/
function hesabix2_wc_fa_load_script_translations( $translations, $file, $handle, $domain ) {
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return $translations;
}
return hesabix2_wc_fa_merge_jed_string_map( $translations );
}
/**
* رشته‌های دارای زمینه (_x و مشابه).
*
* زمینه === کلید خارجی؛ رشتهٔ اصلی === کلید داخلی.
*
* @return array<string, array<string, string>>
*/
function hesabix2_wc_fa_get_string_map_context() {
$m = array(
'breadcrumb' => array(
'Home' => 'خانه',
),
'min_price' => array(
'From:' => 'از:',
),
);
return apply_filters( 'hesabix2_wc_fa_string_map_context', $m );
}
/**
* جفت‌های تک‌جمع/جمع (_n ووکامرس).
*
* هر آیتم: single انگلیسی، plural انگلیسی، fa_single، fa_plural.
*
* @return array<int, array{single:string,plural:string,fa_single:string,fa_plural:string}>
*/
function hesabix2_wc_fa_get_ngettext_rules() {
$rules = array(
array(
'single' => '%1$s review for %2$s',
'plural' => '%1$s reviews for %2$s',
'fa_single' => '%1$s دیدگاه برای %2$s',
'fa_plural' => '%1$s دیدگاه برای %2$s',
),
array(
'single' => '%s customer review',
'plural' => '%s customer reviews',
'fa_single' => '%s دیدگاه مشتری',
'fa_plural' => '%s دیدگاه مشتری',
),
array(
'single' => 'Category:',
'plural' => 'Categories:',
'fa_single' => 'دستهٔ محصول:',
'fa_plural' => 'دستهٔ محصولات:',
),
array(
'single' => 'Tag:',
'plural' => 'Tags:',
'fa_single' => 'برچسب:',
'fa_plural' => 'برچسب‌ها:',
),
array(
'single' => '%1$s for %2$s item',
'plural' => '%1$s for %2$s items',
'fa_single' => '%2$s قلم؛ %1$s',
'fa_plural' => '%2$s قلم؛ %1$s',
),
array(
'single' => '%s download remaining',
'plural' => '%s downloads remaining',
'fa_single' => '%s دانلود باقی‌مانده',
'fa_plural' => '%s دانلود باقی‌مانده',
),
array(
'single' => '%s has been added to your cart.',
'plural' => '%s have been added to your cart.',
'fa_single' => '%s به سبد اضافه شد.',
'fa_plural' => '%s به سبد اضافه شدند.',
),
);
return apply_filters( 'hesabix2_wc_fa_ngettext_rules', $rules );
}
/**
* ترجمه فقط زمانی اعمال می‌شود که gettext هنوز انگلیسی برگردانده (فایل .mo موجود جایِ ترجمه را می‌گیرد).
*
* @param string $translation نتیجهٔ ترجمه فعلی.
* @param string $original متن انگلیسی.
*/
function hesabix2_wc_fa_is_fallback( $translation, $original ) {
return '' === trim( $translation ) || $translation === $original;
}
/**
* @param string|false $translation .
* @param string $text .
* @param string|false $domain .
* @return string|false
*/
function hesabix2_wc_fa_translate_gettext( $translation, $text, $domain ) {
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return $translation;
}
if ( ! hesabix2_wc_fa_is_fallback( (string) $translation, $text ) ) {
return $translation;
}
static $cache = array();
if ( isset( $cache[ $text ] ) ) {
return $cache[ $text ];
}
$map = hesabix2_wc_fa_get_string_map();
if ( isset( $map[ $text ] ) ) {
$cache[ $text ] = $map[ $text ];
return $cache[ $text ];
}
return $translation;
}
/**
* @param string|false $translation .
* @param string $text .
* @param string $context .
* @param string|false $domain .
* @return string|false
*/
function hesabix2_wc_fa_translate_gettext_context( $translation, $text, $context, $domain ) {
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return $translation;
}
if ( ! hesabix2_wc_fa_is_fallback( (string) $translation, $text ) ) {
return $translation;
}
static $memo = array();
$key = $context . "\x04" . $text;
if ( isset( $memo[ $key ] ) ) {
return $memo[ $key ];
}
$ctx = hesabix2_wc_fa_get_string_map_context();
if ( isset( $ctx[ $context ][ $text ] ) ) {
$memo[ $key ] = $ctx[ $context ][ $text ];
return $memo[ $key ];
}
return $translation;
}
/**
* @param string|false $translation .
* @param string $single .
* @param string $plural .
* @param int|false $number .
* @param string|false $domain .
* @return string|false
*/
function hesabix2_wc_fa_translate_ngettext( $translation, $single, $plural, $number, $domain ) {
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return $translation;
}
if ( $translation !== $single && $translation !== $plural ) {
return $translation;
}
foreach ( hesabix2_wc_fa_get_ngettext_rules() as $entry ) {
if ( $entry['single'] !== $single || $entry['plural'] !== $plural ) {
continue;
}
return ( $translation === $single ) ? $entry['fa_single'] : $entry['fa_plural'];
}
return $translation;
}
/**
* @_nx با زمینه (مثل شمارٔ نتایج بازهٔ صفحه).
*
* @param string|false $translation .
* @param string $single .
* @param string $plural .
* @param int|false $number .
* @param string $context .
* @param string|false $domain .
* @return string|false
*/
function hesabix2_wc_fa_translate_ngettext_context( $translation, $single, $plural, $number, $context, $domain ) {
if ( 'woocommerce' !== $domain || ! hesabix2_wc_fa_should_apply() ) {
return $translation;
}
if ( $translation !== $single && $translation !== $plural ) {
return $translation;
}
if (
'with first and last result' === $context &&
'Showing %1$d&ndash;%2$d of %3$d result' === $single &&
'Showing %1$d&ndash;%2$d of %3$d results' === $plural
) {
return 'نمایش %1$d تا %2$d از %3$d نتیجه';
}
return apply_filters(
'hesabix2_wc_fa_ngettext_context',
$translation,
$single,
$plural,
$number,
$context,
$domain
);
}
/**
* ثبت فیلترها بعد از هوکٔ init تا با جهتٔ ترجمهٔ وردپرس ۶.۷+ همسو باشد؛ ووکامرس تا قبل از init بارگذاری شده است.
*/
function hesabix2_wc_fa_bootstrap() {
if ( ! class_exists( 'WooCommerce', false ) ) {
return;
}
if ( ! apply_filters( 'hesabix2_wc_fa_enable', true ) ) {
return;
}
add_filter( 'gettext', 'hesabix2_wc_fa_translate_gettext', 110, 3 );
add_filter( 'gettext_with_context', 'hesabix2_wc_fa_translate_gettext_context', 110, 4 );
add_filter( 'ngettext', 'hesabix2_wc_fa_translate_ngettext', 110, 5 );
add_filter( 'ngettext_with_context', 'hesabix2_wc_fa_translate_ngettext_context', 110, 6 );
add_filter( 'pre_load_script_translations', 'hesabix2_wc_fa_pre_load_script_translations', 10, 4 );
add_filter( 'load_script_translations', 'hesabix2_wc_fa_load_script_translations', 10, 4 );
}
add_action( 'init', 'hesabix2_wc_fa_bootstrap', 1 );