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 | 1x 1x 1x 1x 1x 1x 14x 1x 4x 1x 6x 1x 2x 1x 1x 3x 3x 3x 1x 1x 3x 3x 3x 3x 3x | import { writeFile, unlink } from 'fs'; import { promisify } from 'util'; import { join } from 'path'; const writeFileAsync = promisify(writeFile); const unlinkAsync = promisify(unlink); export function getPlaygroundPath(): string { return join('./test', 'playground'); }; export function getPlaygroundFiles(): Array<any> { return [ { name: 'en.json', content: { "language": "English", "capitol": "London", "units": { "time_hour": "hour", "currency": "GBP", "drink": "tea" } } }, { name: 'pl.json', content: { "language": "Polski", "capitol": "Warszawa", "units": { "time_hour": "godzina", "currency": "PLN" } } }, { name: 'us.json', content: { "deal_type": { "shopping": "shopping", "travel": "travel", "local": "local", "featured": "featured" }, "deal_status": { "preview": "preview", "ready": "ready", "pause": "paused", "special": "special", "sold_out": "sold out", "coming_soon": "coming soon", "ended": "deal ended" }, "language": "English", "capitol": "London", "fresh_deals": "recent deals", "bestseller": "bestseller", "more_local_deals": "more local deals", "more_shopping_deals": "more shopping deals", "buyers": "buyers", "buy": "buy", "old_price": "old price", "new_price": "new price", "address": "address", "map": "map", "hightlights": "hightlights", "terms": "terms", "booking": "booking", "home_page": "home page", "about_page": "about page", "loading": "loading", "search": "search", "search_query": "search query", "all": "all", "sign_in": "Sign in", "email": "email address", "password": "Password", "remember_me": "Rememeber me", "send": "Send", "sign_up": "Sign up", "name": "Name", "surname": "Surname", "password_repeat": "Repeat password", "tos_agreement": "I agree to terms", "dashboard": "Dashboard", "sign_out": "Sign out", "api_error": "Fatal error", "used_deals": "Used deals", "my_deals": "My deals", "expires": "Expires", "bought": "Bought", "valid_codes": "Deals", "on_the_way": "On the way", "deal_history": "Deal hitory", "search_placeholder": "Search Let's deal", "search_submit": "Search", "my_account": "My account", "support": "Support", "where_are_you": "Where are you?", "why_select_location": "In order to show you local deals we need to know your approximate location.", "detect": "Detect" } } ]; }; export function getPlaygroundFilesPaths(): Array<string> { return getPlaygroundFiles().map(file => join(getPlaygroundPath(), file.name)); }; export function createSamplePath(): string { return join('arka', 'gdynia', 'kura', 'wiśnia', 'legia.win'); }; export async function createPlayground(): Promise<void> { await Promise.all( getPlaygroundFiles() .map(file => { const path = join(getPlaygroundPath(), file.name); const content = JSON.stringify(file.content, null, 2); return writeFileAsync(path, content); }) ); }; export async function clearPlayground(): Promise<void> { for (const { name } of getPlaygroundFiles()) { const path = join(getPlaygroundPath(), name); const backup = `${path}_i18n-manager_backup_file`; try { await unlinkAsync(path); await unlinkAsync(backup); } catch (e) {} } }; |