mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-12 19:01:03 +00:00
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:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user