mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-21 16:55:25 +03:00
Standardize display of common + native languages list
This commit is contained in:
parent
6d68232e45
commit
18b3ee8c92
5 changed files with 109 additions and 75 deletions
|
@ -1439,10 +1439,10 @@ function Compose({
|
||||||
code,
|
code,
|
||||||
fallback: common,
|
fallback: common,
|
||||||
});
|
});
|
||||||
const same = commonText === native;
|
const showCommon = commonText !== native;
|
||||||
return (
|
return (
|
||||||
<option value={code} key={code}>
|
<option value={code} key={code}>
|
||||||
{same ? commonText : `${commonText} (${native})`}
|
{showCommon ? `${native} - ${commonText}` : commonText}
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -1452,10 +1452,10 @@ function Compose({
|
||||||
code,
|
code,
|
||||||
fallback: common,
|
fallback: common,
|
||||||
});
|
});
|
||||||
const same = commonText === native;
|
const showCommon = commonText !== native;
|
||||||
return (
|
return (
|
||||||
<option value={code} key={code}>
|
<option value={code} key={code}>
|
||||||
{same ? commonText : `${commonText} (${native})`}
|
{showCommon ? `${native} - ${commonText}` : commonText}
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { useLingui } from '@lingui/react';
|
import { useLingui } from '@lingui/react';
|
||||||
|
import { useMemo } from 'preact/hooks';
|
||||||
|
|
||||||
import { DEFAULT_LANG, LOCALES } from '../locales';
|
import { DEFAULT_LANG, LOCALES } from '../locales';
|
||||||
import { activateLang } from '../utils/lang';
|
import { activateLang } from '../utils/lang';
|
||||||
|
@ -7,6 +8,28 @@ import localeCode2Text from '../utils/localeCode2Text';
|
||||||
export default function LangSelector() {
|
export default function LangSelector() {
|
||||||
const { i18n } = useLingui();
|
const { i18n } = useLingui();
|
||||||
|
|
||||||
|
const populatedLocales = useMemo(() => {
|
||||||
|
return LOCALES.map((lang) => {
|
||||||
|
const native = localeCode2Text({ code: lang, locale: lang });
|
||||||
|
const common = localeCode2Text(lang);
|
||||||
|
const showCommon = !!common && common !== native;
|
||||||
|
return {
|
||||||
|
code: lang,
|
||||||
|
native,
|
||||||
|
common,
|
||||||
|
showCommon,
|
||||||
|
};
|
||||||
|
}).sort((a, b) => {
|
||||||
|
// If pseudo-LOCALE, always put it at the bottom
|
||||||
|
if (a.code === 'pseudo-LOCALE') return 1;
|
||||||
|
if (b.code === 'pseudo-LOCALE') return -1;
|
||||||
|
// Sort by code
|
||||||
|
if (a.code < b.code) return -1;
|
||||||
|
if (a.code > b.code) return 1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}, [i18n.locale]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label class="lang-selector">
|
<label class="lang-selector">
|
||||||
🌐{' '}
|
🌐{' '}
|
||||||
|
@ -18,23 +41,20 @@ export default function LangSelector() {
|
||||||
activateLang(e.target.value);
|
activateLang(e.target.value);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{LOCALES.map((lang) => {
|
{populatedLocales.map(({ code, native, common, showCommon }) => {
|
||||||
if (lang === 'pseudo-LOCALE') {
|
if (code === 'pseudo-LOCALE') {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<hr />
|
<hr />
|
||||||
<option value={lang} key={lang}>
|
<option value={code} key={code}>
|
||||||
Pseudolocalization (test)
|
Pseudolocalization (test)
|
||||||
</option>
|
</option>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const native = localeCode2Text({ code: lang, locale: lang });
|
|
||||||
const common = localeCode2Text(lang);
|
|
||||||
const showCommon = !!common && common !== native;
|
|
||||||
return (
|
return (
|
||||||
<option value={lang} key={lang}>
|
<option value={code} key={code}>
|
||||||
{showCommon ? `${native} (${common})` : native}
|
{showCommon ? `${native} - ${common}` : native}
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -206,19 +206,26 @@ function TranslationBlock({
|
||||||
translate();
|
translate();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sourceLanguages.map((l) => (
|
{sourceLanguages.map((l) => {
|
||||||
<option value={l.code}>
|
const common = localeCode2Text({
|
||||||
{l.code === 'auto'
|
code: l.code,
|
||||||
? t`Auto (${detectedLang ?? '…'})`
|
fallback: l.name,
|
||||||
: `${localeCode2Text({
|
});
|
||||||
code: l.code,
|
const native = localeCode2Text({
|
||||||
fallback: l.name,
|
code: l.code,
|
||||||
})} (${localeCode2Text({
|
locale: l.code,
|
||||||
code: l.code,
|
});
|
||||||
locale: l.code,
|
const showCommon = common !== native;
|
||||||
})})`}
|
return (
|
||||||
</option>
|
<option value={l.code}>
|
||||||
))}
|
{l.code === 'auto'
|
||||||
|
? t`Auto (${detectedLang ?? '…'})`
|
||||||
|
: showCommon
|
||||||
|
? `${native} - ${common}`
|
||||||
|
: native}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</select>{' '}
|
</select>{' '}
|
||||||
<span>→ {targetLangText}</span>
|
<span>→ {targetLangText}</span>
|
||||||
<Loader abrupt hidden={uiState !== 'loading'} />
|
<Loader abrupt hidden={uiState !== 'loading'} />
|
||||||
|
|
|
@ -194,7 +194,7 @@ msgstr ""
|
||||||
#: src/pages/catchup.jsx:72
|
#: src/pages/catchup.jsx:72
|
||||||
#: src/pages/catchup.jsx:1414
|
#: src/pages/catchup.jsx:1414
|
||||||
#: src/pages/catchup.jsx:2035
|
#: src/pages/catchup.jsx:2035
|
||||||
#: src/pages/settings.jsx:1008
|
#: src/pages/settings.jsx:1015
|
||||||
msgid "Boosts"
|
msgid "Boosts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -858,7 +858,7 @@ msgid "Error loading GIFs"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/drafts.jsx:63
|
#: src/components/drafts.jsx:63
|
||||||
#: src/pages/settings.jsx:664
|
#: src/pages/settings.jsx:671
|
||||||
msgid "Unsent drafts"
|
msgid "Unsent drafts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -1242,7 +1242,7 @@ msgstr ""
|
||||||
#: src/pages/home.jsx:223
|
#: src/pages/home.jsx:223
|
||||||
#: src/pages/mentions.jsx:20
|
#: src/pages/mentions.jsx:20
|
||||||
#: src/pages/mentions.jsx:167
|
#: src/pages/mentions.jsx:167
|
||||||
#: src/pages/settings.jsx:1000
|
#: src/pages/settings.jsx:1007
|
||||||
#: src/pages/trending.jsx:347
|
#: src/pages/trending.jsx:347
|
||||||
msgid "Mentions"
|
msgid "Mentions"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -1297,7 +1297,7 @@ msgstr ""
|
||||||
#: src/pages/catchup.jsx:2029
|
#: src/pages/catchup.jsx:2029
|
||||||
#: src/pages/favourites.jsx:11
|
#: src/pages/favourites.jsx:11
|
||||||
#: src/pages/favourites.jsx:23
|
#: src/pages/favourites.jsx:23
|
||||||
#: src/pages/settings.jsx:1004
|
#: src/pages/settings.jsx:1011
|
||||||
msgid "Likes"
|
msgid "Likes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -2284,7 +2284,7 @@ msgid "<0/> <1/> boosted"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/timeline.jsx:447
|
#: src/components/timeline.jsx:447
|
||||||
#: src/pages/settings.jsx:1028
|
#: src/pages/settings.jsx:1035
|
||||||
msgid "New posts"
|
msgid "New posts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -2322,11 +2322,11 @@ msgstr ""
|
||||||
msgid "Translate from {sourceLangText}"
|
msgid "Translate from {sourceLangText}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/translation-block.jsx:212
|
#: src/components/translation-block.jsx:222
|
||||||
msgid "Auto ({0})"
|
msgid "Auto ({0})"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/components/translation-block.jsx:228
|
#: src/components/translation-block.jsx:235
|
||||||
msgid "Failed to translate"
|
msgid "Failed to translate"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -3081,7 +3081,7 @@ msgid "{0, plural, one {Announcement} other {Announcements}}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/notifications.jsx:599
|
#: src/pages/notifications.jsx:599
|
||||||
#: src/pages/settings.jsx:1016
|
#: src/pages/settings.jsx:1023
|
||||||
msgid "Follow requests"
|
msgid "Follow requests"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -3336,152 +3336,152 @@ msgstr ""
|
||||||
msgid "{0, plural, =0 {Hide \"Translate\" button for:} other {Hide \"Translate\" button for (#):}}"
|
msgid "{0, plural, =0 {Hide \"Translate\" button for:} other {Hide \"Translate\" button for (#):}}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:451
|
#: src/pages/settings.jsx:458
|
||||||
msgid "Note: This feature uses external translation services, powered by <0>Lingva API</0> & <1>Lingva Translate</1>."
|
msgid "Note: This feature uses external translation services, powered by <0>Lingva API</0> & <1>Lingva Translate</1>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:485
|
#: src/pages/settings.jsx:492
|
||||||
msgid "Auto inline translation"
|
msgid "Auto inline translation"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:489
|
#: src/pages/settings.jsx:496
|
||||||
msgid "Automatically show translation for posts in timeline. Only works for <0>short</0> posts without content warning, media and poll."
|
msgid "Automatically show translation for posts in timeline. Only works for <0>short</0> posts without content warning, media and poll."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:509
|
#: src/pages/settings.jsx:516
|
||||||
msgid "GIF Picker for composer"
|
msgid "GIF Picker for composer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:513
|
#: src/pages/settings.jsx:520
|
||||||
msgid "Note: This feature uses external GIF search service, powered by <0>GIPHY</0>. G-rated (suitable for viewing by all ages), tracking parameters are stripped, referrer information is omitted from requests, but search queries and IP address information will still reach their servers."
|
msgid "Note: This feature uses external GIF search service, powered by <0>GIPHY</0>. G-rated (suitable for viewing by all ages), tracking parameters are stripped, referrer information is omitted from requests, but search queries and IP address information will still reach their servers."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:542
|
#: src/pages/settings.jsx:549
|
||||||
msgid "Image description generator"
|
msgid "Image description generator"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:547
|
#: src/pages/settings.jsx:554
|
||||||
msgid "Only for new images while composing new posts."
|
msgid "Only for new images while composing new posts."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:554
|
#: src/pages/settings.jsx:561
|
||||||
msgid "Note: This feature uses external AI service, powered by <0>img-alt-api</0>. May not work well. Only for images and in English."
|
msgid "Note: This feature uses external AI service, powered by <0>img-alt-api</0>. May not work well. Only for images and in English."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:580
|
#: src/pages/settings.jsx:587
|
||||||
msgid "Server-side grouped notifications"
|
msgid "Server-side grouped notifications"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:584
|
#: src/pages/settings.jsx:591
|
||||||
msgid "Alpha-stage feature. Potentially improved grouping window but basic grouping logic."
|
msgid "Alpha-stage feature. Potentially improved grouping window but basic grouping logic."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:605
|
#: src/pages/settings.jsx:612
|
||||||
msgid "\"Cloud\" import/export for shortcuts settings"
|
msgid "\"Cloud\" import/export for shortcuts settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:610
|
#: src/pages/settings.jsx:617
|
||||||
msgid "⚠️⚠️⚠️ Very experimental.<0/>Stored in your own profile’s notes. Profile (private) notes are mainly used for other profiles, and hidden for own profile."
|
msgid "⚠️⚠️⚠️ Very experimental.<0/>Stored in your own profile’s notes. Profile (private) notes are mainly used for other profiles, and hidden for own profile."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:621
|
#: src/pages/settings.jsx:628
|
||||||
msgid "Note: This feature uses currently-logged-in instance server API."
|
msgid "Note: This feature uses currently-logged-in instance server API."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:638
|
#: src/pages/settings.jsx:645
|
||||||
msgid "Cloak mode <0>(<1>Text</1> → <2>████</2>)</0>"
|
msgid "Cloak mode <0>(<1>Text</1> → <2>████</2>)</0>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:647
|
#: src/pages/settings.jsx:654
|
||||||
msgid "Replace text as blocks, useful when taking screenshots, for privacy reasons."
|
msgid "Replace text as blocks, useful when taking screenshots, for privacy reasons."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:672
|
#: src/pages/settings.jsx:679
|
||||||
msgid "About"
|
msgid "About"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:711
|
#: src/pages/settings.jsx:718
|
||||||
msgid "<0>Built</0> by <1>@cheeaun</1>"
|
msgid "<0>Built</0> by <1>@cheeaun</1>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:740
|
#: src/pages/settings.jsx:747
|
||||||
msgid "Sponsor"
|
msgid "Sponsor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:748
|
#: src/pages/settings.jsx:755
|
||||||
msgid "Donate"
|
msgid "Donate"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:756
|
#: src/pages/settings.jsx:763
|
||||||
msgid "Privacy Policy"
|
msgid "Privacy Policy"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:763
|
#: src/pages/settings.jsx:770
|
||||||
msgid "<0>Site:</0> {0}"
|
msgid "<0>Site:</0> {0}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:770
|
#: src/pages/settings.jsx:777
|
||||||
msgid "<0>Version:</0> <1/> {0}"
|
msgid "<0>Version:</0> <1/> {0}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:785
|
#: src/pages/settings.jsx:792
|
||||||
msgid "Version string copied"
|
msgid "Version string copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:788
|
#: src/pages/settings.jsx:795
|
||||||
msgid "Unable to copy version string"
|
msgid "Unable to copy version string"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:913
|
#: src/pages/settings.jsx:920
|
||||||
#: src/pages/settings.jsx:918
|
#: src/pages/settings.jsx:925
|
||||||
msgid "Failed to update subscription. Please try again."
|
msgid "Failed to update subscription. Please try again."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:924
|
#: src/pages/settings.jsx:931
|
||||||
msgid "Failed to remove subscription. Please try again."
|
msgid "Failed to remove subscription. Please try again."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:931
|
#: src/pages/settings.jsx:938
|
||||||
msgid "Push Notifications (beta)"
|
msgid "Push Notifications (beta)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:953
|
#: src/pages/settings.jsx:960
|
||||||
msgid "Push notifications are blocked. Please enable them in your browser settings."
|
msgid "Push notifications are blocked. Please enable them in your browser settings."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:962
|
#: src/pages/settings.jsx:969
|
||||||
msgid "Allow from <0>{0}</0>"
|
msgid "Allow from <0>{0}</0>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:971
|
#: src/pages/settings.jsx:978
|
||||||
msgid "anyone"
|
msgid "anyone"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:975
|
#: src/pages/settings.jsx:982
|
||||||
msgid "people I follow"
|
msgid "people I follow"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:979
|
#: src/pages/settings.jsx:986
|
||||||
msgid "followers"
|
msgid "followers"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:1012
|
#: src/pages/settings.jsx:1019
|
||||||
msgid "Follows"
|
msgid "Follows"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:1020
|
#: src/pages/settings.jsx:1027
|
||||||
msgid "Polls"
|
msgid "Polls"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:1024
|
#: src/pages/settings.jsx:1031
|
||||||
msgid "Post edits"
|
msgid "Post edits"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:1045
|
#: src/pages/settings.jsx:1052
|
||||||
msgid "Push permission was not granted since your last login. You'll need to <0><1>log in</1> again to grant push permission</0>."
|
msgid "Push permission was not granted since your last login. You'll need to <0><1>log in</1> again to grant push permission</0>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/pages/settings.jsx:1061
|
#: src/pages/settings.jsx:1068
|
||||||
msgid "NOTE: Push notifications only work for <0>one account</0>."
|
msgid "NOTE: Push notifications only work for <0>one account</0>."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -389,10 +389,10 @@ function Settings({ onClose }) {
|
||||||
code: lang.code,
|
code: lang.code,
|
||||||
locale: lang.code,
|
locale: lang.code,
|
||||||
});
|
});
|
||||||
const same = !native || common === native;
|
const showCommon = common !== native;
|
||||||
return (
|
return (
|
||||||
<option value={lang.code}>
|
<option value={lang.code}>
|
||||||
{same ? common : `${common} (${native})`}
|
{showCommon ? `${native} - ${common}` : common}
|
||||||
</option>
|
</option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -418,7 +418,7 @@ function Settings({ onClose }) {
|
||||||
code: lang.code,
|
code: lang.code,
|
||||||
locale: lang.code,
|
locale: lang.code,
|
||||||
});
|
});
|
||||||
const same = !native || common === native;
|
const showCommon = common !== native;
|
||||||
return (
|
return (
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
|
@ -440,7 +440,14 @@ function Settings({ onClose }) {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>{' '}
|
/>{' '}
|
||||||
{same ? common : `${common} (${native})`}
|
{showCommon ? (
|
||||||
|
<span>
|
||||||
|
{native}{' '}
|
||||||
|
<span class="insignificant">- {common}</span>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
common
|
||||||
|
)}
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
Loading…
Reference in a new issue