mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-04-22 23:17:15 -05:00
Add translation credits to the about panel
This commit is contained in:
parent
4dc85dace9
commit
b91b98060d
|
|
@ -30,16 +30,6 @@ export default function Friends(props: {
|
|||
><AddOutline /></Text>
|
||||
</TouchableOpacity>;
|
||||
|
||||
const onFriendCodeContextMenu = useCallback(() => {
|
||||
ipc.showFriendCodeMenu(props.user.nso!.nsoAccount.user.links.friendCode);
|
||||
}, [ipc, props.user.nso?.nsoAccount.user.links.friendCode]);
|
||||
|
||||
const fc = <Text
|
||||
style={styles.friendCodeValue}
|
||||
// @ts-expect-error react-native-web
|
||||
onContextMenu={onFriendCodeContextMenu}
|
||||
>SW-{props.user.nso!.nsoAccount.user.links.friendCode.id}</Text>;
|
||||
|
||||
return <Section title={t('title')} loading={props.loading} error={props.error} headerButtons={header_buttons}>
|
||||
{props.friends.length ? <ScrollView horizontal>
|
||||
<View style={styles.content}>
|
||||
|
|
|
|||
|
|
@ -3,11 +3,35 @@ import { BackendModule, CallbackError, createInstance, ReadCallback } from 'i18n
|
|||
|
||||
const debug = createDebug('app:i18n');
|
||||
|
||||
import './locale/en-gb.js';
|
||||
|
||||
export const languages = {
|
||||
'en-GB': [() => import('./locale/en-gb.js'), 'English'] as const,
|
||||
'en-GB': {
|
||||
name: 'English',
|
||||
app: () => import('./locale/en-gb.js'),
|
||||
authors: [
|
||||
['Samuel Elliott', 'https://gitlab.fancy.org.uk/samuel', 'https://github.com/samuelthomas2774'],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
type Namespace = keyof typeof import('./locale/en-gb.js');
|
||||
const namespaces = {
|
||||
app: 'app',
|
||||
app_menu: 'app',
|
||||
menu_app: 'app',
|
||||
menus: 'app',
|
||||
notifications: 'app',
|
||||
handle_uri: 'app',
|
||||
|
||||
main_window: 'app',
|
||||
preferences_window: 'app',
|
||||
friend_window: 'app',
|
||||
addfriend_window: 'app',
|
||||
discordsetup_window: 'app',
|
||||
addaccountmanual_window: 'app',
|
||||
} as const;
|
||||
|
||||
type Namespace = keyof typeof namespaces;
|
||||
|
||||
export default function createI18n() {
|
||||
const i18n = createInstance({
|
||||
|
|
@ -40,7 +64,7 @@ const LanguageBackend: BackendModule = {
|
|||
) => {
|
||||
debug('Loading %s translations for %s', namespace, language);
|
||||
|
||||
importLocale(language).then(resources => {
|
||||
importLocale(language, namespaces[namespace]).then(resources => {
|
||||
callback(null, resources[namespace as keyof typeof resources]);
|
||||
}, (error: CallbackError) => {
|
||||
callback(error, null);
|
||||
|
|
@ -49,8 +73,11 @@ const LanguageBackend: BackendModule = {
|
|||
init: null as any,
|
||||
};
|
||||
|
||||
async function importLocale(language: keyof typeof languages) {
|
||||
async function importLocale(
|
||||
language: keyof typeof languages,
|
||||
chunk: typeof namespaces[keyof typeof namespaces] = 'app',
|
||||
) {
|
||||
if (!(language in languages)) throw new Error('Unknown language ' + language);
|
||||
|
||||
return languages[language][0]();
|
||||
return languages[language][chunk]();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ export const app = {
|
|||
|
||||
licence: LICENCE_NOTICE,
|
||||
credits: CREDITS_NOTICE,
|
||||
translation_credits: '{{language}} translation by {{authors, list}}.',
|
||||
};
|
||||
|
||||
export const app_menu = {
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ export class App {
|
|||
}
|
||||
|
||||
function setAboutPanelOptions(i18n?: i18n) {
|
||||
const language = i18n ? languages[i18n.resolvedLanguage as keyof typeof languages] : undefined;
|
||||
|
||||
app.setAboutPanelOptions({
|
||||
applicationName: 'nxapi-app',
|
||||
applicationVersion: process.platform === 'darwin' ? version : version +
|
||||
|
|
@ -152,7 +154,10 @@ function setAboutPanelOptions(i18n?: i18n) {
|
|||
version: git?.revision.substr(0, 8) ?? '?',
|
||||
authors: ['Samuel Elliott'],
|
||||
website: GITLAB_URL,
|
||||
credits: i18n?.t('app:credits') ?? CREDITS_NOTICE,
|
||||
credits: (i18n?.t('app:credits') ?? CREDITS_NOTICE) +
|
||||
(language?.authors.length ? '\n\n' + i18n!.t('app:translation_credits', {
|
||||
language: language.name, authors: language.authors.map(a => a[0]),
|
||||
}) : ''),
|
||||
copyright: i18n?.t('app:licence') ?? LICENCE_NOTICE,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user