added internationalization for backoffice

This commit is contained in:
mengstabketemaw
2026-06-15 16:56:39 +03:00
parent 7e6e9eb1a7
commit 76a8d034ee
9 changed files with 303 additions and 80 deletions

View File

@@ -0,0 +1,47 @@
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
import { en } from './locales/en';
import { am } from './locales/am';
export const SUPPORTED_LANGUAGES = ['en', 'am'] as const;
export type AppLanguage = (typeof SUPPORTED_LANGUAGES)[number];
const STORAGE_KEY = 'ema-backoffice-lang';
function getInitialLanguage(): AppLanguage {
const stored =
typeof localStorage !== 'undefined'
? (localStorage.getItem(STORAGE_KEY) as AppLanguage | null)
: null;
if (stored && SUPPORTED_LANGUAGES.includes(stored)) return stored;
return 'en';
}
export const i18n = i18next.createInstance();
i18n.use(initReactI18next).init({
resources: {
en: { translation: en },
am: { translation: am },
},
lng: getInitialLanguage(),
fallbackLng: 'en',
supportedLngs: [...SUPPORTED_LANGUAGES],
interpolation: { escapeValue: false },
returnNull: false,
});
i18n.on('languageChanged', (lng) => {
if (typeof localStorage !== 'undefined') {
localStorage.setItem(STORAGE_KEY, lng);
}
if (typeof document !== 'undefined') {
document.documentElement.lang = lng;
}
});
if (typeof document !== 'undefined') {
document.documentElement.lang = i18n.language;
}
export default i18n;

View File

@@ -0,0 +1,82 @@
import type { Translations } from './en';
export const am: Translations = {
app: {
name: 'ኢማ አስተዳደር',
shortName: 'ኢማ',
authority: 'የኢትዮጵያ ባሕር ጉዳዮች ባለሥልጣን',
tagline: 'የቁጥጥር ማዕከል',
},
language: {
label: 'ቋንቋ',
en: 'English',
am: 'አማርኛ',
},
nav: {
menu: 'ምናሌ',
dashboard: 'ዳሽቦርድ',
userManagement: 'የተጠቃሚ አስተዳደር',
},
common: {
logout: 'ውጣ',
profile: 'መገለጫ',
settings: 'ቅንብሮች',
export: 'ላክ',
viewAll: 'ሁሉንም ይመልከቱ',
home: 'መነሻ',
notifications: 'ማሳወቂያዎች',
administrator: 'አስተዳዳሪ',
},
breadcrumbs: {
dashboard: 'ዳሽቦርድ',
um: 'የተጠቃሚ አስተዳደር',
home: 'መነሻ',
},
dashboard: {
title: 'አጠቃላይ እይታ',
subtitle: 'እንኳን ደህና መጡ — በመድረክዎ ላይ ያለው እንቅስቃሴ አጠቃላይ እይታ።',
kpis: {
totalUsers: 'ጠቅላላ ተጠቃሚዎች',
activeUsers: 'ንቁ ተጠቃሚዎች',
newThisMonth: 'በዚህ ወር አዲስ',
pendingApprovals: 'በመጠባበቅ ላይ ያሉ',
},
charts: {
userRegistrations: 'የተጠቃሚ ምዝገባ',
registrationsSubtitle: 'ባለፉት 8 ወራት አዲስ ምዝገባ',
vsPreviousPeriod: 'ካለፈው ጊዜ ጋር ሲነጻጸር',
usersByRole: 'ተጠቃሚዎች በሚና',
roleDistribution: 'በተደራሽነት ደረጃ ስርጭት',
totalUsers: 'ጠቅላላ ተጠቃሚዎች',
},
quickLinks: {
title: 'ፈጣን አገናኞች',
subtitle: 'የተለመዱ የአስተዳደር አቋራጮች',
addUser: 'ተጠቃሚ ያክሉ',
addUserDesc: 'አዲስ መለያ ይፍጠሩ',
rolesAndPermissions: 'ሚናዎች እና ፈቃዶች',
rolesAndPermissionsDesc: 'የተደራሽነት ደረጃዎችን ያስተዳድሩ',
inviteMembers: 'አባላትን ይጋብዙ',
inviteMembersDesc: 'በኢሜይል ግብዣ ይላኩ',
importUsers: 'ተጠቃሚዎችን ያስመጡ',
importUsersDesc: 'የCSV ጅምላ ማስመጣት',
exportData: 'ውሂብ ያላኩ',
exportDataDesc: 'ሪፖርቶችን ያውርዱ',
auditLog: 'የኦዲት መዝገብ',
auditLogDesc: 'እንቅስቃሴን ይገምግሙ',
},
recentUsers: {
title: 'የቅርብ ጊዜ ተጠቃሚዎች',
},
timeRange: {
today: 'ዛሬ',
thisWeek: 'በዚህ ሳምንት',
thisMonth: 'በዚህ ወር',
},
},
};

View File

@@ -0,0 +1,82 @@
export const en = {
app: {
name: 'EMA Admin',
shortName: 'EMA',
authority: 'Ethiopian Maritime Authority',
tagline: 'Control Center',
},
language: {
label: 'Language',
en: 'English',
am: 'አማርኛ',
},
nav: {
menu: 'MENU',
dashboard: 'Dashboard',
userManagement: 'User Management',
},
common: {
logout: 'Log out',
profile: 'Profile',
settings: 'Settings',
export: 'Export',
viewAll: 'View all',
home: 'Home',
notifications: 'Notifications',
administrator: 'Administrator',
},
breadcrumbs: {
dashboard: 'Dashboard',
um: 'User Management',
home: 'Home',
},
dashboard: {
title: 'Overview',
subtitle: 'Welcome back — here\u2019s what\u2019s happening across your platform.',
kpis: {
totalUsers: 'Total Users',
activeUsers: 'Active Users',
newThisMonth: 'New This Month',
pendingApprovals: 'Pending Approvals',
},
charts: {
userRegistrations: 'User Registrations',
registrationsSubtitle: 'New sign-ups over the last 8 months',
vsPreviousPeriod: 'vs previous period',
usersByRole: 'Users by Role',
roleDistribution: 'Distribution across access levels',
totalUsers: 'Total users',
},
quickLinks: {
title: 'Quick Links',
subtitle: 'Common administrative shortcuts',
addUser: 'Add User',
addUserDesc: 'Create a new account',
rolesAndPermissions: 'Roles & Permissions',
rolesAndPermissionsDesc: 'Manage access levels',
inviteMembers: 'Invite Members',
inviteMembersDesc: 'Send email invites',
importUsers: 'Import Users',
importUsersDesc: 'Bulk CSV import',
exportData: 'Export Data',
exportDataDesc: 'Download reports',
auditLog: 'Audit Log',
auditLogDesc: 'Review activity',
},
recentUsers: {
title: 'Recent Users',
},
timeRange: {
today: 'Today',
thisWeek: 'This Week',
thisMonth: 'This Month',
},
},
};
export type Translations = typeof en;