Organize shared code across web, mobile, and SDK UI projects

Centralized common code into shared/ folder to eliminate duplication and
improve maintainability across all three frontend projects (web, mobile,
pezkuwi-sdk-ui).

Changes:
- Added token types and constants to shared/types/tokens.ts
  - TokenInfo, PoolInfo, SwapQuote, and other DEX types
  - KNOWN_TOKENS with HEZ, PEZ, wUSDT definitions
  - Token logos (🟡🟣💵)

- Added Kurdistan color palette to shared/constants/
  - Kesk, Sor, Zer, Spî, Reş color definitions

- Added TOKEN_DISPLAY_SYMBOLS mapping (USDT vs wUSDT)

- Updated blockchain configuration in shared/blockchain/polkadot.ts
  - Added beta testnet endpoint (wss://beta-rpc.pezkuwi.art)
  - Defined DEFAULT_ENDPOINT constant

- Moved i18n to shared/i18n/
  - Centralized translation files for 6 languages (EN, TR, KMR, CKB, AR, FA)
  - Added LANGUAGES configuration with RTL support
  - Created isRTL() helper function

- Updated web and mobile to import from shared
  - web/src/types/dex.ts now re-exports from shared
  - web/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT
  - mobile/src/i18n/index.ts uses shared translations
  - mobile/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT

- Updated shared/README.md with comprehensive documentation

This architecture reduces code duplication and ensures consistency across
all frontend projects.
This commit is contained in:
Claude
2025-11-14 19:48:43 +00:00
parent 9c6b10a502
commit 81fe0e8ab7
17 changed files with 684 additions and 147 deletions
+74
View File
@@ -0,0 +1,74 @@
/**
* Shared i18n configuration and translations
*/
// Import all translations
import en from './locales/en.json';
import tr from './locales/tr.json';
import kmr from './locales/kmr.json';
import ckb from './locales/ckb.json';
import ar from './locales/ar.json';
import fa from './locales/fa.json';
/**
* Language configuration with RTL support
*/
export interface LanguageConfig {
code: string;
name: string;
nativeName: string;
rtl: boolean;
}
/**
* Available languages
*/
export const LANGUAGES: LanguageConfig[] = [
{ code: 'en', name: 'English', nativeName: 'English', rtl: false },
{ code: 'tr', name: 'Turkish', nativeName: 'Türkçe', rtl: false },
{ code: 'kmr', name: 'Kurdish (Kurmanji)', nativeName: 'Kurmancî', rtl: false },
{ code: 'ckb', name: 'Kurdish (Sorani)', nativeName: 'سۆرانی', rtl: true },
{ code: 'ar', name: 'Arabic', nativeName: 'العربية', rtl: true },
{ code: 'fa', name: 'Persian', nativeName: 'فارسی', rtl: true },
];
/**
* Default language code
*/
export const DEFAULT_LANGUAGE = 'en';
/**
* Language storage key (for AsyncStorage/localStorage)
*/
export const LANGUAGE_STORAGE_KEY = '@pezkuwi_language';
/**
* Translation resources
*/
export const translations = {
en,
tr,
kmr,
ckb,
ar,
fa,
};
/**
* Check if a language is RTL
* @param languageCode - Language code (e.g., 'ar', 'ckb', 'fa')
* @returns true if RTL, false otherwise
*/
export function isRTL(languageCode: string): boolean {
const lang = LANGUAGES.find(l => l.code === languageCode);
return lang?.rtl || false;
}
/**
* Get language configuration
* @param languageCode - Language code
* @returns Language configuration or undefined
*/
export function getLanguageConfig(languageCode: string): LanguageConfig | undefined {
return LANGUAGES.find(l => l.code === languageCode);
}
+4
View File
@@ -0,0 +1,4 @@
declare module '*.json' {
const value: any;
export default value;
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "مرحباً بك في بيزكوي",
"subtitle": "بوابتك للحوكمة اللامركزية",
"selectLanguage": "اختر لغتك",
"continue": "متابعة"
},
"auth": {
"signIn": "تسجيل الدخول",
"signUp": "إنشاء حساب",
"email": "البريد الإلكتروني",
"password": "كلمة المرور",
"confirmPassword": "تأكيد كلمة المرور",
"forgotPassword": "نسيت كلمة المرور؟",
"noAccount": "ليس لديك حساب؟",
"haveAccount": "هل لديك حساب بالفعل؟",
"createAccount": "إنشاء حساب",
"welcomeBack": "مرحباً بعودتك!",
"getStarted": "ابدأ الآن"
},
"dashboard": {
"title": "لوحة التحكم",
"wallet": "المحفظة",
"staking": "التخزين",
"governance": "الحوكمة",
"dex": "البورصة",
"history": "السجل",
"settings": "الإعدادات",
"balance": "الرصيد",
"totalStaked": "إجمالي المخزن",
"rewards": "المكافآت",
"activeProposals": "المقترحات النشطة"
},
"wallet": {
"title": "المحفظة",
"connect": "ربط المحفظة",
"disconnect": "فصل الاتصال",
"address": "العنوان",
"balance": "الرصيد",
"send": "إرسال",
"receive": "استقبال",
"transaction": "المعاملة",
"history": "السجل"
},
"settings": {
"title": "الإعدادات",
"language": "اللغة",
"theme": "المظهر",
"notifications": "الإشعارات",
"security": "الأمان",
"about": "حول",
"logout": "تسجيل الخروج"
},
"common": {
"cancel": "إلغاء",
"confirm": "تأكيد",
"save": "حفظ",
"loading": "جاري التحميل...",
"error": "خطأ",
"success": "نجاح",
"retry": "إعادة المحاولة",
"close": "إغلاق"
}
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "بەخێربێیت بۆ پێزکووی",
"subtitle": "دەرگای تۆ بۆ بەڕێوەبردنی نامەرکەزی",
"selectLanguage": "زمانەکەت هەڵبژێرە",
"continue": "بەردەوام بە"
},
"auth": {
"signIn": "چوونەژوورەوە",
"signUp": "تۆمارکردن",
"email": "ئیمەیڵ",
"password": "وشەی نهێنی",
"confirmPassword": "پشتڕاستکردنەوەی وشەی نهێنی",
"forgotPassword": "وشەی نهێنیت لەبیرکردووە؟",
"noAccount": "هەژمارت نییە؟",
"haveAccount": "هەژمارت هەیە؟",
"createAccount": "دروستکردنی هەژمار",
"welcomeBack": "بەخێربێیتەوە!",
"getStarted": "دەست پێبکە"
},
"dashboard": {
"title": "سەرەتا",
"wallet": "جزدان",
"staking": "ستەیکینگ",
"governance": "بەڕێوەبردن",
"dex": "ئاڵوگۆڕ",
"history": "مێژوو",
"settings": "ڕێکخستنەکان",
"balance": "باڵانس",
"totalStaked": "کۆی گشتی",
"rewards": "خەڵات",
"activeProposals": "پێشنیارە چالاکەکان"
},
"wallet": {
"title": "جزدان",
"connect": "گرێدانی جزدان",
"disconnect": "پچڕاندنی گرێدان",
"address": "ناونیشان",
"balance": "باڵانس",
"send": "ناردن",
"receive": "وەرگرتن",
"transaction": "مامەڵە",
"history": "مێژوو"
},
"settings": {
"title": "ڕێکخستنەکان",
"language": "زمان",
"theme": "ڕووکار",
"notifications": "ئاگادارییەکان",
"security": "پاراستن",
"about": "دەربارە",
"logout": "دەرچوون"
},
"common": {
"cancel": "هەڵوەشاندنەوە",
"confirm": "پشتڕاستکردنەوە",
"save": "پاشەکەوتکردن",
"loading": "بارکردن...",
"error": "هەڵە",
"success": "سەرکەوتوو",
"retry": "هەوڵ بدەرەوە",
"close": "داخستن"
}
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "Welcome to Pezkuwi",
"subtitle": "Your gateway to decentralized governance",
"selectLanguage": "Select Your Language",
"continue": "Continue"
},
"auth": {
"signIn": "Sign In",
"signUp": "Sign Up",
"email": "Email",
"password": "Password",
"confirmPassword": "Confirm Password",
"forgotPassword": "Forgot Password?",
"noAccount": "Don't have an account?",
"haveAccount": "Already have an account?",
"createAccount": "Create Account",
"welcomeBack": "Welcome Back!",
"getStarted": "Get Started"
},
"dashboard": {
"title": "Dashboard",
"wallet": "Wallet",
"staking": "Staking",
"governance": "Governance",
"dex": "Exchange",
"history": "History",
"settings": "Settings",
"balance": "Balance",
"totalStaked": "Total Staked",
"rewards": "Rewards",
"activeProposals": "Active Proposals"
},
"wallet": {
"title": "Wallet",
"connect": "Connect Wallet",
"disconnect": "Disconnect",
"address": "Address",
"balance": "Balance",
"send": "Send",
"receive": "Receive",
"transaction": "Transaction",
"history": "History"
},
"settings": {
"title": "Settings",
"language": "Language",
"theme": "Theme",
"notifications": "Notifications",
"security": "Security",
"about": "About",
"logout": "Logout"
},
"common": {
"cancel": "Cancel",
"confirm": "Confirm",
"save": "Save",
"loading": "Loading...",
"error": "Error",
"success": "Success",
"retry": "Retry",
"close": "Close"
}
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "به پێزکووی خوش آمدید",
"subtitle": "دروازه شما به حکمرانی غیرمتمرکز",
"selectLanguage": "زبان خود را انتخاب کنید",
"continue": "ادامه"
},
"auth": {
"signIn": "ورود",
"signUp": "ثبت نام",
"email": "ایمیل",
"password": "رمز عبور",
"confirmPassword": "تأیید رمز عبور",
"forgotPassword": "رمز عبور را فراموش کرده‌اید؟",
"noAccount": "حساب کاربری ندارید؟",
"haveAccount": "قبلاً حساب کاربری دارید؟",
"createAccount": "ایجاد حساب",
"welcomeBack": "خوش آمدید!",
"getStarted": "شروع کنید"
},
"dashboard": {
"title": "داشبورد",
"wallet": "کیف پول",
"staking": "سپرده‌گذاری",
"governance": "حکمرانی",
"dex": "صرافی",
"history": "تاریخچه",
"settings": "تنظیمات",
"balance": "موجودی",
"totalStaked": "کل سپرده",
"rewards": "پاداش‌ها",
"activeProposals": "پیشنهادات فعال"
},
"wallet": {
"title": "کیف پول",
"connect": "اتصال کیف پول",
"disconnect": "قطع اتصال",
"address": "آدرس",
"balance": "موجودی",
"send": "ارسال",
"receive": "دریافت",
"transaction": "تراکنش",
"history": "تاریخچه"
},
"settings": {
"title": "تنظیمات",
"language": "زبان",
"theme": "تم",
"notifications": "اعلان‌ها",
"security": "امنیت",
"about": "درباره",
"logout": "خروج"
},
"common": {
"cancel": "لغو",
"confirm": "تأیید",
"save": "ذخیره",
"loading": "در حال بارگذاری...",
"error": "خطا",
"success": "موفق",
"retry": "تلاش مجدد",
"close": "بستن"
}
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "Bi xêr hatî Pezkuwî",
"subtitle": "Deriyê te yê bo rêveberiya desentralîze",
"selectLanguage": "Zimanê Xwe Hilbijêre",
"continue": "Bidomîne"
},
"auth": {
"signIn": "Têkeve",
"signUp": "Tomar bibe",
"email": "E-posta",
"password": "Şîfre",
"confirmPassword": "Şîfreyê Bipejirîne",
"forgotPassword": "Şîfreyê te ji bîr kiriye?",
"noAccount": "Hesabê te tune ye?",
"haveAccount": "Jixwe hesabê te heye?",
"createAccount": "Hesab Biafirîne",
"welcomeBack": "Dîsa bi xêr hatî!",
"getStarted": "Dest pê bike"
},
"dashboard": {
"title": "Serûpel",
"wallet": "Berîk",
"staking": "Staking",
"governance": "Rêvebir",
"dex": "Guherîn",
"history": "Dîrok",
"settings": "Mîheng",
"balance": "Bilanço",
"totalStaked": "Hemû Stake",
"rewards": "Xelat",
"activeProposals": "Pêşniyarên Çalak"
},
"wallet": {
"title": "Berîk",
"connect": "Berîkê Girêde",
"disconnect": "Girêdanê Rake",
"address": "Navnîşan",
"balance": "Bilanço",
"send": "Bişîne",
"receive": "Bistîne",
"transaction": "Ragihandin",
"history": "Dîrok"
},
"settings": {
"title": "Mîheng",
"language": "Ziman",
"theme": "Tema",
"notifications": "Agahdarî",
"security": "Ewlekarî",
"about": "Derbarê",
"logout": "Derkeve"
},
"common": {
"cancel": "Betal bike",
"confirm": "Bipejirîne",
"save": "Tomar bike",
"loading": "Tê barkirin...",
"error": "Çewtî",
"success": "Serkeftin",
"retry": "Dîsa biceribîne",
"close": "Bigire"
}
}
+64
View File
@@ -0,0 +1,64 @@
{
"welcome": {
"title": "Pezkuwi'ye Hoş Geldiniz",
"subtitle": "Merkezi olmayan yönetim kapınız",
"selectLanguage": "Dilinizi Seçin",
"continue": "Devam Et"
},
"auth": {
"signIn": "Giriş Yap",
"signUp": "Kayıt Ol",
"email": "E-posta",
"password": "Şifre",
"confirmPassword": "Şifreyi Onayla",
"forgotPassword": "Şifremi Unuttum",
"noAccount": "Hesabınız yok mu?",
"haveAccount": "Zaten hesabınız var mı?",
"createAccount": "Hesap Oluştur",
"welcomeBack": "Tekrar Hoş Geldiniz!",
"getStarted": "Başlayın"
},
"dashboard": {
"title": "Ana Sayfa",
"wallet": "Cüzdan",
"staking": "Stake Etme",
"governance": "Yönetişim",
"dex": "Borsa",
"history": "Geçmiş",
"settings": "Ayarlar",
"balance": "Bakiye",
"totalStaked": "Toplam Stake",
"rewards": "Ödüller",
"activeProposals": "Aktif Teklifler"
},
"wallet": {
"title": "Cüzdan",
"connect": "Cüzdan Bağla",
"disconnect": "Bağlantıyı Kes",
"address": "Adres",
"balance": "Bakiye",
"send": "Gönder",
"receive": "Al",
"transaction": "İşlem",
"history": "Geçmiş"
},
"settings": {
"title": "Ayarlar",
"language": "Dil",
"theme": "Tema",
"notifications": "Bildirimler",
"security": "Güvenlik",
"about": "Hakkında",
"logout": "Çıkış Yap"
},
"common": {
"cancel": "İptal",
"confirm": "Onayla",
"save": "Kaydet",
"loading": "Yükleniyor...",
"error": "Hata",
"success": "Başarılı",
"retry": "Tekrar Dene",
"close": "Kapat"
}
}