feat: add Polish localization (#1123)
* Add Polish (pl) localization * translations * fix: add missing Polish translations * copy en keys to pl * fix: complete Polish settings translations * fix: localize PWA install prompt * fix pwa install prompt lifecycle and complete Polish locale keys * polish polish locale wording for natural phrasing --------- Co-authored-by: levy52 <levy52@vp.pl> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
levy52
Bohdan Triapitsyn
parent
ce4c5ae99f
commit
7eff2f725f
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import { toast } from '@/components/ui';
|
||||
import { isWebRuntime } from '@/lib/desktop';
|
||||
import { usePwaDetection } from '@/hooks/usePwaDetection';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
import { getSafeSessionStorage } from '@/stores/utils/safeStorage';
|
||||
|
||||
type InstallPromptOutcome = 'accepted' | 'dismissed';
|
||||
@@ -15,6 +16,12 @@ const INSTALL_TOAST_SESSION_KEY = 'pwa-install-toast-shown';
|
||||
|
||||
export const usePwaInstallPrompt = () => {
|
||||
const { browserTab } = usePwaDetection();
|
||||
const { t } = useI18n();
|
||||
const tRef = React.useRef(t);
|
||||
|
||||
React.useEffect(() => {
|
||||
tRef.current = t;
|
||||
}, [t]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof window === 'undefined' || !isWebRuntime() || !browserTab) {
|
||||
@@ -44,7 +51,7 @@ export const usePwaInstallPrompt = () => {
|
||||
await promptEvent.prompt();
|
||||
const { outcome } = await promptEvent.userChoice;
|
||||
if (outcome === 'accepted') {
|
||||
toast.success('Install started');
|
||||
toast.success(tRef.current('pwa.installPrompt.started'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,10 +75,10 @@ export const usePwaInstallPrompt = () => {
|
||||
|
||||
sessionStorage.setItem(INSTALL_TOAST_SESSION_KEY, 'true');
|
||||
|
||||
installToastId = toast.info('Install OpenChamber for quicker access', {
|
||||
installToastId = toast.info(tRef.current('pwa.installPrompt.description'), {
|
||||
duration: Infinity,
|
||||
action: {
|
||||
label: 'Install',
|
||||
label: tRef.current('pwa.installPrompt.action'),
|
||||
onClick: () => {
|
||||
void triggerInstall();
|
||||
},
|
||||
@@ -82,7 +89,7 @@ export const usePwaInstallPrompt = () => {
|
||||
const onAppInstalled = () => {
|
||||
deferredPrompt = null;
|
||||
dismissInstallToast();
|
||||
toast.success('OpenChamber installed');
|
||||
toast.success(tRef.current('pwa.installPrompt.installed'));
|
||||
};
|
||||
|
||||
window.addEventListener('beforeinstallprompt', onBeforeInstallPrompt as EventListener);
|
||||
|
||||
Reference in New Issue
Block a user