mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(locale): Added a locale setting in Settings app
This removes the need to rebuild the phone in order to change language
This commit is contained in:
1 parent
5c6538b340
commit
a6e8c769c0
6 files changed
+82
-9
No files matched your search
+9
-2
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import './Phone.css';
|
import './Phone.css';
|
||||||
import './i18n';
|
import './i18n';
|
||||||
import { Route } from 'react-router-dom';
|
import { Route } from 'react-router-dom';
|
||||||
@@ -33,11 +33,18 @@ import { usePhone } from './os/phone/hooks/usePhone';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
|
|
||||||
const { apps } = useApps();
|
const { apps } = useApps();
|
||||||
|
|
||||||
const [settings] = useSettings();
|
const [settings] = useSettings();
|
||||||
|
|
||||||
|
// Set language from local storage
|
||||||
|
// This will only trigger on first mount & settings changes
|
||||||
|
useEffect(() => {
|
||||||
|
i18n.changeLanguage(settings.language.value).catch((e) => console.error(e));
|
||||||
|
}, [i18n, settings.language]);
|
||||||
|
|
||||||
useNuiService();
|
useNuiService();
|
||||||
useKeyboardService();
|
useKeyboardService();
|
||||||
usePhoneService();
|
usePhoneService();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
LibraryMusic,
|
LibraryMusic,
|
||||||
VolumeUp,
|
VolumeUp,
|
||||||
FileCopy,
|
FileCopy,
|
||||||
|
Book,
|
||||||
} from '@material-ui/icons';
|
} from '@material-ui/icons';
|
||||||
|
|
||||||
import { ListSubheader } from '@material-ui/core';
|
import { ListSubheader } from '@material-ui/core';
|
||||||
@@ -86,6 +87,10 @@ export const SettingsApp = () => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const languages = config.languages.map(
|
||||||
|
MapSettingItem(settings.language, (val: SettingOption) => handleSettingChange('language', val)),
|
||||||
|
);
|
||||||
|
|
||||||
const handleCopyPhoneNumber = () => {
|
const handleCopyPhoneNumber = () => {
|
||||||
setClipboard(simcard.number);
|
setClipboard(simcard.number);
|
||||||
addAlert({
|
addAlert({
|
||||||
@@ -101,7 +106,7 @@ export const SettingsApp = () => {
|
|||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle app={settingsApp} />
|
<AppTitle app={settingsApp} />
|
||||||
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
||||||
<List disablePadding subheader={<SubHeaderComp text="Phone" />}>
|
<List disablePadding subheader={<SubHeaderComp text={t('SETTINGS.CATEGORY.PHONE')} />}>
|
||||||
<SettingItemIconAction
|
<SettingItemIconAction
|
||||||
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
||||||
labelSecondary={simcard.number}
|
labelSecondary={simcard.number}
|
||||||
@@ -146,7 +151,14 @@ export const SettingsApp = () => {
|
|||||||
onClick={(curr) => handleSettingChange('streamerMode', !curr)}
|
onClick={(curr) => handleSettingChange('streamerMode', !curr)}
|
||||||
/>
|
/>
|
||||||
</List>
|
</List>
|
||||||
<List disablePadding subheader={<SubHeaderComp text="Appearance" />}>
|
<List disablePadding subheader={<SubHeaderComp text={t('SETTINGS.CATEGORY.APPEARANCE')} />}>
|
||||||
|
<SettingItem
|
||||||
|
label={t('SETTINGS.OPTIONS.LANGUAGE')}
|
||||||
|
value={settings.language.label}
|
||||||
|
options={languages}
|
||||||
|
onClick={openMenu}
|
||||||
|
icon={<Book />}
|
||||||
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_THEME')}
|
label={t('APPS_SETTINGS_OPTION_THEME')}
|
||||||
value={settings.theme.label}
|
value={settings.theme.label}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export const settingsState = atom({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export interface IPhoneSettings {
|
export interface IPhoneSettings {
|
||||||
|
language: SettingOption;
|
||||||
wallpaper: SettingOption;
|
wallpaper: SettingOption;
|
||||||
frame: SettingOption;
|
frame: SettingOption;
|
||||||
theme: SettingOption;
|
theme: SettingOption;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"cellProvider": "AT&T",
|
"cellProvider": "AT&T",
|
||||||
"language": "en",
|
"defaultLanguage": "en",
|
||||||
"wallpapers": [
|
"wallpapers": [
|
||||||
{
|
{
|
||||||
"label": "Minimal",
|
"label": "Minimal",
|
||||||
@@ -67,6 +67,44 @@
|
|||||||
"value": 0.7
|
"value": 0.7
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"languages": [
|
||||||
|
{
|
||||||
|
"label": "English",
|
||||||
|
"value": "en"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Español",
|
||||||
|
"value": "es"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Français",
|
||||||
|
"value": "fr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Türk",
|
||||||
|
"value": "tr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Norsk",
|
||||||
|
"value": "no"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Svenska",
|
||||||
|
"value": "sv"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Português",
|
||||||
|
"value": "pt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Português (BR)",
|
||||||
|
"value": "ptbr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Bosanski",
|
||||||
|
"value": "ba"
|
||||||
|
}
|
||||||
|
],
|
||||||
"ringtones": [
|
"ringtones": [
|
||||||
{
|
{
|
||||||
"label": "Marimba",
|
"label": "Marimba",
|
||||||
@@ -98,6 +136,10 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"defaultSettings": {
|
"defaultSettings": {
|
||||||
|
"language": {
|
||||||
|
"label": "English",
|
||||||
|
"value": "en"
|
||||||
|
},
|
||||||
"wallpaper": {
|
"wallpaper": {
|
||||||
"label": "Project Error",
|
"label": "Project Error",
|
||||||
"value": "projecterror.jpg"
|
"value": "projecterror.jpg"
|
||||||
@@ -107,7 +149,7 @@
|
|||||||
"value": "default.png"
|
"value": "default.png"
|
||||||
},
|
},
|
||||||
"theme": {
|
"theme": {
|
||||||
"label": "taso-dark",
|
"label": "Taso Dark",
|
||||||
"value": "taso-dark"
|
"value": "taso-dark"
|
||||||
},
|
},
|
||||||
"zoom": {
|
"zoom": {
|
||||||
|
|||||||
+5
-3
@@ -27,9 +27,11 @@ i18n
|
|||||||
.use(initReactI18next) // passes i18n down to react-i18next
|
.use(initReactI18next) // passes i18n down to react-i18next
|
||||||
.init({
|
.init({
|
||||||
resources,
|
resources,
|
||||||
lng: config.language,
|
lng: config.defaultLanguage,
|
||||||
|
react: {
|
||||||
keySeparator: false, // we do not use keys in form messages.welcome
|
bindI18n: 'languageChanged',
|
||||||
|
},
|
||||||
|
keySeparator: '.', // we do not use keys in form messages.welcome
|
||||||
|
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false, // react already safes from xss
|
escapeValue: false, // react already safes from xss
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
"translation": {
|
"translation": {
|
||||||
"DATE_FORMAT": "MM/DD/YYYY",
|
"DATE_FORMAT": "MM/DD/YYYY",
|
||||||
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
|
"DATE_TIME_FORMAT": "MM/DD/YYYY hh:mm A",
|
||||||
|
"SETTINGS": {
|
||||||
|
"CATEGORY": {
|
||||||
|
"APPEARANCE": "Appearance",
|
||||||
|
"PHONE": "Phone"
|
||||||
|
},
|
||||||
|
"OPTIONS": {
|
||||||
|
"LANGUAGE": "Language"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"COMING_SOON": "Coming soon...",
|
"COMING_SOON": "Coming soon...",
|
||||||
"INITIALIZING": "Initializing",
|
"INITIALIZING": "Initializing",
|
||||||
|
|||||||
Reference in new issue
Block a user