File size: 11,998 Bytes
4be2b2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';

type Language = 'en' | 'mr';

interface LanguageContextType {
  language: Language;
  toggleLanguage: () => void;
  t: (key: string) => string;
}

const translations = {
  en: {
    // App Name
    'app.name': 'Mirchi Trading',
    'app.tagline': 'Invoice & Inventory Management',
    
    // Navigation
    'nav.home': 'Home',
    'nav.invoice': 'Invoice',
    'nav.purchase': 'Purchase',
    'nav.stock': 'Stock',
    'nav.ledger': 'Ledger',
    
    // Dashboard
    'dashboard.title': 'Mirchi Trading',
    'dashboard.quickActions': 'Quick Actions',
    'dashboard.recentActivity': 'Recent Activity',
    'dashboard.totalSales': 'Total Sales',
    'dashboard.thisMonth': 'This Month',
    'dashboard.invoices': 'Invoices',
    'dashboard.totalCreated': 'Total Created',
    'dashboard.stockValue': 'Stock Value',
    'dashboard.currentStock': 'Current Stock',
    'dashboard.parties': 'Parties',
    'dashboard.tradingPartners': 'Trading Partners',
    
    // Quick Actions
    'action.newInvoice': 'New Invoice',
    'action.newPurchase': 'New Purchase',
    'action.stockReport': 'Stock Report',
    'action.partyLedger': 'Party Ledger',
    'action.billBooks': 'Bill Books',
    
    // Invoice
    'invoice.title': 'Invoice',
    'invoice.new': 'New Invoice',
    'invoice.billDetails': 'Bill Details',
    'invoice.billBook': 'Bill Book',
    'invoice.billNumber': 'Bill Number',
    'invoice.date': 'Date',
    'invoice.partyName': 'Party Name',
    'invoice.selectParty': 'Select Party',
    'invoice.itemDetails': 'Item Details',
    'invoice.selectItem': 'Select Item',
    'invoice.lotNumber': 'Lot Number',
    'invoice.selectLot': 'Select Lot',
    'invoice.bags': 'Bags',
    'invoice.grossWeight': 'Gross Weight',
    'invoice.netWeight': 'Net Weight',
    'invoice.rate': 'Rate',
    'invoice.amount': 'Amount',
    'invoice.charges': 'Additional Charges',
    'invoice.bardhana': 'Packing',
    'invoice.perBag': 'per bag',
    'invoice.hamali': 'Labor',
    'invoice.adhath': 'Commission',
    'invoice.cess': 'Cess',
    'invoice.gaadiBharni': 'Vehicle Loading',
    'invoice.summary': 'Summary',
    'invoice.itemTotal': 'Item Total',
    'invoice.grandTotal': 'Grand Total',
    'invoice.save': 'Save',
    'invoice.print': 'Print',
    'invoice.share': 'Share',
    'invoice.shareWhatsApp': 'Share on WhatsApp',
    'invoice.billNumberWarning': 'Changing bill number may cause issues. Use with caution.',
    
    // Purchase Entry
    'purchase.title': 'Purchase Entry',
    'purchase.inward': 'Inward',
    'purchase.basicInfo': 'Basic Information',
    'purchase.lotDetails': 'Lot Details',
    'purchase.addLot': 'Add Lot',
    'purchase.lotNumber': 'Lot Number',
    'purchase.variety': 'Variety',
    'purchase.selectVariety': 'Select Variety',
    'purchase.quality': 'Quality',
    'purchase.vehicleDetails': 'Vehicle Details',
    'purchase.vehicleNumber': 'Vehicle Number',
    'purchase.freight': 'Freight',
    'purchase.paymentDetails': 'Payment Details',
    'purchase.totalAmount': 'Total Amount',
    'purchase.advancePaid': 'Advance Paid',
    'purchase.remaining': 'Remaining',
    
    // Party Ledger
    'ledger.title': 'Party Ledger',
    'ledger.selectParty': 'Select Party',
    'ledger.currentBalance': 'Current Balance',
    'ledger.toReceive': 'To Receive',
    'ledger.toPay': 'To Pay',
    'ledger.credit': 'Credit',
    'ledger.debit': 'Debit',
    'ledger.balance': 'Balance',
    'ledger.particulars': 'Particulars',
    'ledger.reference': 'Reference',
    'ledger.search': 'Search',
    
    // Bill Books
    'billbook.title': 'Bill Books',
    'billbook.new': 'New Bill Book',
    'billbook.add': 'Add Bill Book',
    'billbook.name': 'Book Name',
    'billbook.serialFrom': 'First Number',
    'billbook.serialTo': 'Last Number',
    'billbook.active': 'Active',
    'billbook.currentNumber': 'Current Number',
    'billbook.remaining': 'Remaining Bills',
    'billbook.activate': 'Activate',
    
    // Common
    'common.save': 'Save',
    'common.cancel': 'Cancel',
    'common.add': 'Add',
    'common.edit': 'Edit',
    'common.delete': 'Delete',
    'common.search': 'Search',
    'common.filter': 'Filter',
    'common.export': 'Export',
    'common.print': 'Print',
    'common.back': 'Back',
    'common.next': 'Next',
    'common.previous': 'Previous',
    'common.close': 'Close',
    'common.confirm': 'Confirm',
    'common.yes': 'Yes',
    'common.no': 'No',
    'common.total': 'Total',
    'common.date': 'Date',
    'common.amount': 'Amount',
    'common.quantity': 'Quantity',
    'common.kg': 'kg',
    'common.bags': 'bags',
  },
  mr: {
    // App Name
    'app.name': 'मिर्ची ट्रेडिंग',
    'app.tagline': 'आवक-जावक व्यवस्थापन',
    
    // Navigation
    'nav.home': 'होम',
    'nav.invoice': 'जावक',
    'nav.purchase': 'आवक',
    'nav.stock': 'स्टॉक',
    'nav.ledger': 'लेजर',
    
    // Dashboard
    'dashboard.title': 'मिर्ची ट्रेडिंग',
    'dashboard.quickActions': 'त्वरित कार्ये',
    'dashboard.recentActivity': 'अलीकडील व्यवहार',
    'dashboard.totalSales': 'एकूण विक्री',
    'dashboard.thisMonth': 'या महिन्यात',
    'dashboard.invoices': 'जावक बिले',
    'dashboard.totalCreated': 'एकूण तयार केलेली',
    'dashboard.stockValue': 'माल मूल्य',
    'dashboard.currentStock': 'सध्याचा साठा',
    'dashboard.parties': 'पार्टी',
    'dashboard.tradingPartners': 'व्यापारी भागीदार',
    
    // Quick Actions
    'action.newInvoice': 'जावक बिल',
    'action.newPurchase': 'आवक एंट्री',
    'action.stockReport': 'स्टॉक रिपोर्ट',
    'action.partyLedger': 'पार्टी लेजर',
    'action.billBooks': 'बिल बुक्स',
    
    // Invoice
    'invoice.title': 'जावक बिल',
    'invoice.new': 'नवीन जावक बिल',
    'invoice.billDetails': 'बिल तपशील',
    'invoice.billBook': 'बिल बुक',
    'invoice.billNumber': 'बिल नंबर',
    'invoice.date': 'तारीख',
    'invoice.partyName': 'पार्टी नाव',
    'invoice.selectParty': 'पार्टी निवडा',
    'invoice.itemDetails': 'माल तपशील',
    'invoice.selectItem': 'माल निवडा',
    'invoice.lotNumber': 'लॉट नंबर',
    'invoice.selectLot': 'लॉट निवडा',
    'invoice.bags': 'पोत्या',
    'invoice.grossWeight': 'एकूण वजन',
    'invoice.netWeight': 'निव्वळ वजन',
    'invoice.rate': 'रेट',
    'invoice.amount': 'रक्कम',
    'invoice.charges': 'अतिरिक्त खर्च',
    'invoice.bardhana': 'बर्डाणा',
    'invoice.perBag': 'प्रति पोती',
    'invoice.hamali': 'हमाली',
    'invoice.adhath': 'अडत',
    'invoice.cess': 'सेस',
    'invoice.gaadiBharni': 'गाडी भरणी',
    'invoice.summary': 'सारांश',
    'invoice.itemTotal': 'एकूण रक्कम',
    'invoice.grandTotal': 'एकूण रक्कम',
    'invoice.save': 'जतन करा',
    'invoice.print': 'प्रिंट',
    'invoice.share': 'शेअर करा',
    'invoice.shareWhatsApp': 'WhatsApp वर शेअर करा',
    'invoice.billNumberWarning': 'बिल नंबर बदलल्यास समस्या येऊ शकतात. सावधगिरीने वापरा.',
    
    // Purchase Entry
    'purchase.title': 'आवक एंट्री',
    'purchase.inward': 'माल आला',
    'purchase.basicInfo': 'मूळ माहिती',
    'purchase.lotDetails': 'लॉट तपशील',
    'purchase.addLot': 'नवीन लॉट जोडा',
    'purchase.lotNumber': 'लॉट नंबर',
    'purchase.variety': 'जात',
    'purchase.selectVariety': 'जात निवडा',
    'purchase.quality': 'गुणवत्ता',
    'purchase.vehicleDetails': 'गाडी तपशील',
    'purchase.vehicleNumber': 'गाडी नंबर',
    'purchase.freight': 'भाडे',
    'purchase.paymentDetails': 'पेमेंट तपशील',
    'purchase.totalAmount': 'एकूण रक्कम',
    'purchase.advancePaid': 'अॅडव्हान्स दिले',
    'purchase.remaining': 'बाकी',
    
    // Party Ledger
    'ledger.title': 'पार्टी लेजर',
    'ledger.selectParty': 'पार्टी निवडा',
    'ledger.currentBalance': 'चालू बाकी',
    'ledger.toReceive': 'घेणे',
    'ledger.toPay': 'देणे',
    'ledger.credit': 'जमा',
    'ledger.debit': 'नावे',
    'ledger.balance': 'बाकी',
    'ledger.particulars': 'तपशील',
    'ledger.reference': 'संदर्भ',
    'ledger.search': 'शोधा',
    
    // Bill Books
    'billbook.title': 'बिल बुक्स',
    'billbook.new': 'नवीन बिल बुक',
    'billbook.add': 'बिल बुक जोडा',
    'billbook.name': 'बुकचे नाव',
    'billbook.serialFrom': 'पहिला नंबर',
    'billbook.serialTo': 'शेवटचा नंबर',
    'billbook.active': 'सक्रिय',
    'billbook.currentNumber': 'चालू नंबर',
    'billbook.remaining': 'शिल्लक बिले',
    'billbook.activate': 'सक्रिय करा',
    
    // Common
    'common.save': 'जतन करा',
    'common.cancel': 'रद्द करा',
    'common.add': 'जोडा',
    'common.edit': 'बदला',
    'common.delete': 'काढा',
    'common.search': 'शोधा',
    'common.filter': 'फिल्टर',
    'common.export': 'एक्सपोर्ट',
    'common.print': 'प्रिंट',
    'common.back': 'मागे',
    'common.next': 'पुढे',
    'common.previous': 'मागील',
    'common.close': 'बंद करा',
    'common.confirm': 'खात्री करा',
    'common.yes': 'होय',
    'common.no': 'नाही',
    'common.total': 'एकूण',
    'common.date': 'तारीख',
    'common.amount': 'रक्कम',
    'common.quantity': 'संख्या',
    'common.kg': 'kg',
    'common.bags': 'पोत्या',
  }
};

const LanguageContext = createContext<LanguageContextType | undefined>(undefined);

export function LanguageProvider({ children }: { children: ReactNode }) {
  const [language, setLanguage] = useState<Language>(() => {
    // Load from localStorage or default to Marathi
    const saved = localStorage.getItem('language');
    return (saved === 'en' || saved === 'mr') ? saved : 'mr';
  });

  useEffect(() => {
    // Save to localStorage whenever language changes
    localStorage.setItem('language', language);
    // Update document direction if needed (for future RTL support)
    document.documentElement.lang = language === 'mr' ? 'mr' : 'en';
  }, [language]);

  const toggleLanguage = () => {
    setLanguage(prev => prev === 'en' ? 'mr' : 'en');
  };

  const t = (key: string): string => {
    return translations[language][key as keyof typeof translations['en']] || key;
  };

  return (
    <LanguageContext.Provider value={{ language, toggleLanguage, t }}>
      {children}
    </LanguageContext.Provider>
  );
}

export function useLanguage() {
  const context = useContext(LanguageContext);
  if (!context) {
    throw new Error('useLanguage must be used within a LanguageProvider');
  }
  return context;
}