this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show all locales, <50% complete will be called devLocales

Dev locales show on dev or based on env var PHANPY_SHOW_DEV_LOCALES

+43 -25
+2 -2
lingui.config.js
··· 1 - import { LOCALES } from './src/locales'; 1 + import { ALL_LOCALES } from './src/locales'; 2 2 3 3 const config = { 4 - locales: LOCALES, 4 + locales: ALL_LOCALES, 5 5 sourceLocale: 'en', 6 6 pseudoLocale: 'pseudo-LOCALE', 7 7 fallbackLocales: {
+28 -18
src/components/lang-selector.jsx
··· 1 1 import { useLingui } from '@lingui/react'; 2 2 import { useMemo } from 'preact/hooks'; 3 3 4 - import { CATALOGS, DEFAULT_LANG, LOCALES } from '../locales'; 4 + import { CATALOGS, DEFAULT_LANG, DEV_LOCALES, LOCALES } from '../locales'; 5 5 import { activateLang } from '../utils/lang'; 6 6 import localeCode2Text from '../utils/localeCode2Text'; 7 7 ··· 16 16 // Sorted on render, so the order won't suddenly change based on current locale 17 17 const populatedLocales = useMemo(() => { 18 18 return LOCALES.map((lang) => { 19 - if (lang === 'pseudo-LOCALE') { 20 - return { code: lang, native: 'Pseudolocalization (test)' }; 21 - } 22 - 23 19 // Don't need regions for now, it makes text too noisy 24 20 // Wait till there's too many languages and there are regional clashes 25 21 const regionlessCode = regionMaps[lang] || lang.replace(/-[a-z]+$/i, ''); ··· 45 41 native, 46 42 }; 47 43 }).sort((a, b) => { 48 - // If pseudo-LOCALE, always put it at the bottom 49 - if (a.code === 'pseudo-LOCALE') return 1; 50 - if (b.code === 'pseudo-LOCALE') return -1; 51 44 // Sort by common name 52 45 const order = a._common.localeCompare(b._common, i18n.locale); 53 46 if (order !== 0) return order; ··· 70 63 }} 71 64 > 72 65 {populatedLocales.map(({ code, regionlessCode, native }) => { 73 - if (code === 'pseudo-LOCALE') { 74 - return ( 75 - <> 76 - <hr /> 77 - <option value={code} key={code}> 78 - {native} 79 - </option> 80 - </> 81 - ); 82 - } 83 66 // Common name changes based on current locale 84 67 const common = localeCode2Text({ 85 68 code: regionlessCode, ··· 97 80 </option> 98 81 ); 99 82 })} 83 + {(import.meta.env.DEV || import.meta.env.PHANPY_SHOW_DEV_LOCALES) && ( 84 + <optgroup label="🚧 Development (<50% translated)"> 85 + {DEV_LOCALES.map((code) => { 86 + if (code === 'pseudo-LOCALE') { 87 + return ( 88 + <> 89 + <hr /> 90 + <option value={code} key={code}> 91 + Pseudolocalization (test) 92 + </option> 93 + </> 94 + ); 95 + } 96 + const nativeName = CATALOGS.find( 97 + (c) => c.code === code, 98 + )?.nativeName; 99 + const completion = CATALOGS.find( 100 + (c) => c.code === code, 101 + )?.completion; 102 + return ( 103 + <option value={code} key={code}> 104 + {nativeName || code} &lrm;[{completion}%] 105 + </option> 106 + ); 107 + })} 108 + </optgroup> 109 + )} 100 110 </select> 101 111 </label> 102 112 );
+11 -3
src/locales.js
··· 12 12 .filter(({ completion }) => completion >= PERCENTAGE_THRESHOLD) 13 13 .map(({ code }) => code), 14 14 ]; 15 - if (import.meta.env.DEV) { 16 - locales.push('pseudo-LOCALE'); 17 - } 18 15 export const LOCALES = locales; 16 + 17 + let devLocales = []; 18 + if (import.meta.env.DEV || import.meta.env.PHANPY_SHOW_DEV_LOCALES) { 19 + devLocales = catalogs 20 + .filter(({ completion }) => completion < PERCENTAGE_THRESHOLD) 21 + .map(({ code }) => code); 22 + devLocales.push('pseudo-LOCALE'); 23 + } 24 + export const DEV_LOCALES = devLocales; 25 + 26 + export const ALL_LOCALES = [...locales, ...devLocales];
+2 -2
src/utils/lang.js
··· 7 7 } from '@lingui/detect-locale'; 8 8 import Locale from 'intl-locale-textinfo-polyfill'; 9 9 10 - import { DEFAULT_LANG, LOCALES } from '../locales'; 10 + import { ALL_LOCALES, DEFAULT_LANG } from '../locales'; 11 11 import { messages } from '../locales/en.po'; 12 12 import localeMatch from '../utils/locale-match'; 13 13 ··· 62 62 DEFAULT_LANG, 63 63 ); 64 64 const matchedLang = 65 - LOCALES.find((l) => l === lang) || localeMatch(lang, LOCALES); 65 + ALL_LOCALES.find((l) => l === lang) || localeMatch(lang, ALL_LOCALES); 66 66 activateLang(matchedLang); 67 67 68 68 // const yes = confirm(t`Reload to apply language setting?`);