/* English and Chichewa. The English text is the key, so anything not yet translated still reads in English.
   The language is the person's own choice (My profile), else the business's (Settings). */
import { usePage } from '@inertiajs/react';
import type { SharedProps } from './types';

const NY: Record<string, string> = {
    // menu
    'Sell': 'Gulitsa', 'Sales': 'Malonda', 'Products': 'Katundu', 'Customers': 'Makasitomala', 'More': 'Zina',
    'Shift': 'Shifiti', 'My shift': 'Shifiti yanga', 'Expenses': 'Zowononga', 'Reports': 'Malipoti', 'Profit and loss': 'Phindu ndi kutayika',
    'Staff': 'Ogwira ntchito', 'Business settings': 'Zokonda za bizinesi', 'SMS reminders': 'Zikumbutso za SMS',
    'Subscription': 'Kulembetsa', 'Activity log': 'Mbiri ya zochitika', 'My profile and PIN': 'Mbiri yanga ndi PIN',
    'Sign out': 'Tulukani', 'Close': 'Tsekani',
    // status bar
    'Offline': 'Palibe intaneti', 'Sending…': 'Zikutumizidwa…', 'waiting to send': 'zikudikira kutumizidwa',
    'not accepted': 'sizinalandiridwe', 'Shift open since': 'Shifiti yatsegulidwa kuyambira', 'No shift open': 'Palibe shifiti yotsegula',
    // common
    'Today': 'Lero', 'Yesterday': 'Dzulo', 'Total': 'Zonse pamodzi', 'Amount': 'Ndalama', 'Save': 'Sungani', 'Saving…': 'Zikusungidwa…',
    'Cancel': 'Lekani', 'Search': 'Sakani', 'All': 'Zonse', 'Note (optional)': 'Cholemba (ngati mukufuna)', 'Date': 'Tsiku',
    'Phone number': 'Nambala ya foni', 'Name': 'Dzina', 'Notes': 'Zolemba', 'Back': 'Bwererani',
    'Cash': 'Ndalama (cash)', 'Bank': 'Banki', 'Credit (pay later)': 'Ngongole (adzalipira mtsogolo)',
    // sell
    'Quick sale': 'Kugulitsa mwachangu', 'Find a product': 'Pezani katundu', 'Cart': 'Dengu', 'Charge': 'Lipiritsani',
    'Tap products to add them.': 'Dinani katundu kuti muwonjezere.', 'How did they pay?': 'Alipira bwanji?',
    'Confirm sale': 'Tsimikizani malonda', 'Clear the cart': 'Chotsani zonse m’dengu', 'What was sold? (optional)': 'Mwagulitsa chiyani? (ngati mukufuna)',
    'Sale saved': 'Malonda asungidwa', 'Saved on this phone': 'Zasungidwa pa foni iyi', 'It will be sent when the internet is back.': 'Zidzatumizidwa intaneti ikabwera.',
    'No products yet': 'Palibe katundu panobe', 'Use Quick sale, or add your products first.': 'Gwiritsani ntchito Kugulitsa mwachangu, kapena onjezani katundu wanu kaye.',
    'Go to Products': 'Pitani ku Katundu', 'Out': 'Zatha', 'Sold earlier? Enter the date and time': 'Zinagulitsidwa kale? Lembani tsiku ndi nthawi',
    'When was it sold?': 'Zinagulitsidwa liti?', 'Entered after the shift': 'Zalembedwa pambuyo pa shifiti',
    'Who is taking it on credit?': 'Akutenga pangongole ndi ndani?', 'Choose a customer': 'Sankhani kasitomala', 'New customer': 'Kasitomala watsopano',
    'Customer name': 'Dzina la kasitomala', 'Pay by (optional)': 'Adzalipira pofika (ngati mukufuna)',
    'Open your shift to start selling': 'Tsegulani shifiti yanu kuti muyambe kugulitsa', 'Cash in the till now': 'Ndalama zili mu kabokosi tsopano',
    'Open shift': 'Tsegulani shifiti',
    'Open your shift to finish this sale': 'Tsegulani shifiti yanu kuti mumalize malondawa',
    // sales
    'All staff': 'Ogwira ntchito onse', 'Your sales': 'Malonda anu', 'tap to pick a day': 'dinani kuti musankhe tsiku',
    'Profit on goods': 'Phindu pa katundu', 'Cancelled': 'Zathetsedwa', 'No sales yet today.': 'Palibe malonda lero panobe.', 'No sales on this day.': 'Palibe malonda tsiku limeneli.',
    // shift
    'Close shift': 'Tsekani shifiti', 'Count the cash in the till': 'Werengani ndalama za mu kabokosi', 'Cash counted': 'Ndalama zowerengedwa',
    'Expected cash': 'Ndalama zoyembekezeka', 'Started with': 'Inayamba ndi', 'Cash sales': 'Malonda a cash', 'Cash paid back': 'Ngongole zobwezedwa (cash)',
    'Cash spent': 'Cash yowonongedwa', 'Difference': 'Kusiyana', 'short': 'zachepa', 'over': 'zachuluka', 'Exactly right': 'Zili bwino ndendende',
    'Sales by payment': 'Malonda mwa njira yolipira', 'Loans given': 'Ngongole zoperekedwa', 'Past shifts': 'Ma shifiti akale',
    // customers and loans
    'Owes': 'Ali ndi ngongole', 'Owed to you': 'Ngongole zanu', 'Overdue': 'Yachedwa', 'days late': 'masiku mochedwa', 'Paid up': 'Walipira zonse',
    'Add customer': 'Onjezani kasitomala', 'Record payment': 'Lembani malipiro', 'Record a loan': 'Lembani ngongole', 'Items taken': 'Katundu watengedwa',
    'Due date': 'Tsiku lolipira', 'Send reminder now': 'Tumizani chikumbutso tsopano', 'History': 'Mbiri', 'Took': 'Anatenga', 'Paid': 'Analipira',
    'Who owes': 'Okongola', 'Everyone': 'Aliyense', 'No one owes you anything.': 'Palibe amene ali ndi ngongole yanu.',
    // expenses
    'Add expense': 'Onjezani zowononga', 'What was it for?': 'Zinali za chiyani?', 'Paid with': 'Analipira ndi',
    'Rent': 'Lendi', 'Transport': 'Mayendedwe', 'Stock purchase': 'Kugula katundu', 'Salaries': 'Malipiro a antchito', 'Electricity and water': 'Magetsi ndi madzi', 'Other': 'Zina',
    // kaunjika
    'Bales': 'Mabelo', 'per': 'pa', 'Weight': 'Kulemera', 'By money': 'Ndi ndalama', 'How much': 'Zingati',
    'How much does the customer want to spend?': 'Kasitomala akufuna kugula za ndalama zingati?', 'Weigh out': 'Yesani', 'change': 'sinthani',
    'Count stock': 'Werengani katundu', 'Lunch': 'Chakudya cha masana', 'Electricity': 'Magetsi', 'Machine oil': 'Mafuta a makina', 'Machine repair': 'Kukonza makina',
    'Machine oil and tools': 'Mafuta a makina ndi zipangizo', 'Repairs and maintenance': 'Kukonza', 'Money made today': 'Ndalama zapezeka lero', 'Money made that day': 'Ndalama zapezeka tsiku limenelo',
    'Count the money at the end of the day and type the total.': 'Werengani ndalama kumapeto kwa tsiku ndipo lembani zonse pamodzi.',
    "Day's takings": 'Ndalama za tsiku',
    'Money made': 'Ndalama zapezeka', 'Cash available after expenses': 'Ndalama zilipo pambuyo pa zowononga', 'made': 'zapezeka', 'spent': 'zowonongedwa', 'Total expenses': 'Zowononga zonse', 'Left after expenses': 'Zatsala pambuyo pa zowononga',
    'Spent more than made': 'Zowononga zaposa ndalama zapezeka', 'Nothing spent.': 'Palibe chowonongedwa.', 'Spent today': 'Zowononga lero', 'Food': 'Chakudya', 'Market fee': 'Msonkho wa msika',
    // settings
    'Language': 'Chiyankhulo', 'Same as the business': 'Monga bizinesi',
};

export function translate(locale: string, text: string): string {
    return locale === 'ny' ? NY[text] ?? text : text;
}

/** const t = useT(); t('Sell') */
export function useT(): (text: string) => string {
    const { locale } = usePage<SharedProps>().props;
    return (text: string) => translate(locale ?? 'en', text);
}
