fix: Set detected language on first login, remove auto-detect language option

This commit is contained in:
Maksim Eltyshev
2025-10-15 00:08:29 +02:00
parent 20d8f8ae53
commit fee300908c
44 changed files with 39 additions and 65 deletions

View File

@@ -29,8 +29,7 @@ const AccountPane = React.memo(() => {
const handleLanguageChange = useCallback(
(_, { value }) => {
// FIXME: hack
dispatch(entryActions.updateCurrentUserLanguage(value === 'auto' ? null : value));
dispatch(entryActions.updateCurrentUserLanguage(value));
},
[dispatch],
);
@@ -62,18 +61,12 @@ const AccountPane = React.memo(() => {
<Dropdown
fluid
selection
options={[
{
value: 'auto',
text: t('common.detectAutomatically'),
},
...locales.map((locale) => ({
value: locale.language,
flag: locale.country,
text: locale.name,
})),
]}
value={user.language || 'auto'}
options={locales.map((locale) => ({
value: locale.language,
flag: locale.country,
text: locale.name,
}))}
value={user.language}
onChange={handleLanguageChange}
/>
{(isUsernameEditable || isEmailEditable || isPasswordEditable) && (

View File

@@ -151,7 +151,7 @@ i18n.loadCoreLocale = async (language = i18n.resolvedLanguage) => {
});
};
i18n.detectLanguage = () => {
/* i18n.detectLanguage = () => {
const {
services: { languageDetector, languageUtils },
} = i18n;
@@ -164,6 +164,6 @@ i18n.detectLanguage = () => {
i18n.resolvedLanguage = undefined;
i18n.setResolvedLanguage(i18n.language);
};
}; */
export default i18n;

View File

@@ -142,7 +142,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'الوصف',
detectAutomatically: 'الكشف تلقائياً',
display: null,
dropFileToUpload: 'أفلت الملف لرفعه',
dueDate_title: 'تاريخ الاستحقاق',

View File

@@ -146,7 +146,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Описание',
detectAutomatically: 'Aвтоматично откриване',
display: null,
dropFileToUpload: 'Пуснете файл за качване',
dueDate_title: 'Краен срок',

View File

@@ -156,7 +156,6 @@ export default {
deleteWebhook_title: 'Smazat webhook',
deletedUser_title: 'Smazaný uživatel',
description: 'Popis',
detectAutomatically: 'Automatická detekce',
display: 'Zobrazit',
dropFileToUpload: 'Přetažením nahrát soubor',
dueDate_title: 'Termín',

View File

@@ -161,7 +161,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Slettet bruger',
description: 'Beskrivelse',
detectAutomatically: 'Registrer automatisk',
display: 'Vis',
dropFileToUpload: 'Slip fil for at uploade',
dueDate_title: 'Frist',

View File

@@ -170,7 +170,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Gelöschter Benutzer',
description: 'Beschreibung',
detectAutomatically: 'Automatisch erkennen',
display: 'Anzeige',
dropFileToUpload: 'Datei für Upload ablegen',
dueDate_title: 'Fälligkeitsdatum',

View File

@@ -171,7 +171,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Διαγραμμένος χρήστης',
description: 'Περιγραφή',
detectAutomatically: 'Αυτόματη ανίχνευση',
display: 'Εμφάνιση',
dropFileToUpload: 'Σύρετε το αρχείο για μεταφόρτωση',
dueDate_title: 'Ημερομηνία λήξης',

View File

@@ -160,7 +160,6 @@ export default {
deleteWebhook_title: 'Delete Webhook',
deletedUser_title: 'Deleted User',
description: 'Description',
detectAutomatically: 'Detect automatically',
display: 'Display',
dropFileToUpload: 'Drop file to upload',
dueDate_title: 'Due Date',

View File

@@ -155,7 +155,6 @@ export default {
deleteWebhook_title: 'Delete Webhook',
deletedUser_title: 'Deleted User',
description: 'Description',
detectAutomatically: 'Detect automatically',
display: 'Display',
dropFileToUpload: 'Drop file to upload',
dueDate_title: 'Due Date',

View File

@@ -166,7 +166,6 @@ export default {
deleteWebhook_title: 'Eliminar webhook',
deletedUser_title: 'Usuario eliminado',
description: 'Descripción',
detectAutomatically: 'Detectar automáticamente',
display: 'Mostrar',
dropFileToUpload: 'Arrastra archivo para subir',
dueDate_title: 'Fecha de vencimiento',

View File

@@ -160,7 +160,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Kustutatud kasutaja',
description: 'Kirjeldus',
detectAutomatically: 'Tuletage automaatselt',
display: 'Kuva',
dropFileToUpload: 'Lase faili üleslaadida',
dueDate_title: 'Tähtaeg',

View File

@@ -143,7 +143,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'توضیحات',
detectAutomatically: 'تشخیص خودکار',
display: null,
dropFileToUpload: 'فایل را برای آپلود بکشید',
dueDate_title: 'تاریخ سررسید',

View File

@@ -156,7 +156,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Poistettu käyttäjä',
description: 'Kuvaus',
detectAutomatically: 'Tunnista automaattisesti',
display: 'Näyttö',
dropFileToUpload: 'Pudota tiedosto ladattavaksi',
dueDate_title: 'Määräpäivä',

View File

@@ -164,7 +164,6 @@ export default {
deleteWebhook_title: 'Supprimer le webhook',
deletedUser_title: 'Utilisateur supprimé',
description: 'Description',
detectAutomatically: 'Détecter automatiquement',
display: 'Affichage',
dropFileToUpload: 'Déposer le fichier à télécharger',
dueDate_title: "Date d'échéance",

View File

@@ -153,7 +153,6 @@ export default {
deleteWebhook_title: 'Webhook törlése',
deletedUser_title: 'Törölt felhasználó',
description: 'Leírás',
detectAutomatically: 'Automatikus érzékelés',
display: 'Megjelenítés',
dropFileToUpload: 'Dobja ide a fájlt a feltöltéshez',
dueDate_title: 'Esedékesség dátuma',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Deskripsi',
detectAutomatically: 'Deteksi otomatis',
display: null,
dropFileToUpload: 'Tarik berkas untuk menggungah',
dueDate_title: 'Tenggat Waktu',

View File

@@ -162,7 +162,6 @@ export default {
deleteWebhook_title: 'Elimina webhook',
deletedUser_title: 'Utente eliminato',
description: 'Descrizione',
detectAutomatically: 'Rileva automaticamente',
display: 'Mostra',
dropFileToUpload: 'Trascina il file da caricare',
dueDate_title: 'Data di scadenza',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: '説明',
detectAutomatically: '自動的に検知',
display: null,
dropFileToUpload: 'ファイルをドロップしてアップロード',
dueDate_title: '期限',

View File

@@ -143,7 +143,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: '설명',
detectAutomatically: '자동 감지',
display: null,
dropFileToUpload: '업로드할 파일을 드롭하세요',
dueDate_title: '마감일',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Beschrijving',
detectAutomatically: 'Automatisch detecteren',
display: null,
dropFileToUpload: 'Sleep bestand om te uploaden',
dueDate_title: 'Vervaldatum',

View File

@@ -152,7 +152,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Usunięty Użytkownik',
description: 'Opis',
detectAutomatically: 'Wykryj automatycznie',
display: 'Wyświetlanie',
dropFileToUpload: 'Upuść plik aby wgrać',
dueDate_title: 'Termin',

View File

@@ -162,7 +162,6 @@ export default {
deleteWebhook_title: 'Excluir Webhook',
deletedUser_title: 'Usuário Excluído',
description: 'Descrição',
detectAutomatically: 'Detectar automaticamente',
display: 'Exibir',
dropFileToUpload: 'Solte o arquivo para enviar',
dueDate_title: 'Data de Vencimento',

View File

@@ -146,7 +146,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Descrição',
detectAutomatically: 'Detetar automaticamente',
display: null,
dropFileToUpload: 'Largue o ficheiro para carregar',
dueDate_title: 'Data de Vencimento',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Descriere',
detectAutomatically: 'Detectează automat',
display: null,
dropFileToUpload: 'Aruncă fișierul pentru a încărca',
dueDate_title: 'Data scadentă',

View File

@@ -159,7 +159,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: 'Удалённый пользователь',
description: 'Описание',
detectAutomatically: 'Определить автоматически',
display: 'Отображение',
dropFileToUpload: 'Перетяните файл, чтобы загрузить',
dueDate_title: 'Срок исполнения',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Popis',
detectAutomatically: null,
display: null,
dropFileToUpload: 'Potiahnutím nahraj súbor',
dueDate_title: 'Termín do',

View File

@@ -145,7 +145,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Опис',
detectAutomatically: 'Детектуј аутоматски',
display: null,
dropFileToUpload: 'Превуци датотеку за слање',
dueDate_title: 'Рок',

View File

@@ -142,7 +142,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Opis',
detectAutomatically: 'Detektuj automatski',
display: null,
dropFileToUpload: 'Prevuci datoteku za slanje',
dueDate_title: 'Rok',

View File

@@ -144,7 +144,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Beskrivning',
detectAutomatically: null,
display: null,
dropFileToUpload: 'Släpp en fil för att ladda upp',
dueDate_title: 'Förfallodatum',

View File

@@ -142,7 +142,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'açıklama',
detectAutomatically: 'Otomatik olarak algıla',
display: null,
dropFileToUpload: 'Yüklenecek dosyayı buraya bırakın',
dueDate_title: 'Termin Tarihi',

View File

@@ -157,7 +157,6 @@ export default {
deleteWebhook_title: 'Видалити вебхук',
deletedUser_title: 'Видалений користувач',
description: 'Опис',
detectAutomatically: 'Визначити автоматично',
display: 'Дисплей',
dropFileToUpload: 'Перетягніть файл для завантаження',
dueDate_title: 'Крайній Термін',

View File

@@ -141,7 +141,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: 'Tavsif',
detectAutomatically: null,
display: null,
dropFileToUpload: 'Faylni yuklash uchun qoldiring',
dueDate_title: 'Muddati',

View File

@@ -142,7 +142,6 @@ export default {
deleteWebhook_title: '删除Webhook',
deletedUser_title: '已删除用户',
description: '描述',
detectAutomatically: '自动检测',
display: '显示',
dropFileToUpload: '拖放文件以上传',
dueDate_title: '截止日期',

View File

@@ -139,7 +139,6 @@ export default {
deleteWebhook_title: null,
deletedUser_title: null,
description: '描述',
detectAutomatically: '自動偵測',
display: null,
dropFileToUpload: '拖放文件以上傳',
dueDate_title: '截止日期',

View File

@@ -79,14 +79,8 @@ export function* initializeCore() {
}
export function* changeCoreLanguage(language) {
if (language === null) {
yield call(i18n.detectLanguage);
yield call(i18n.loadCoreLocale);
yield call(i18n.changeLanguage, i18n.resolvedLanguage);
} else {
yield call(i18n.loadCoreLocale, language);
yield call(i18n.changeLanguage, language);
}
yield call(i18n.loadCoreLocale, language);
yield call(i18n.changeLanguage, language);
}
export function* toggleFavorites(isEnabled) {

View File

@@ -140,6 +140,7 @@ export function* acceptTerms(signature) {
({ item: accessToken } = yield call(api.acceptTerms, {
pendingToken,
signature,
initialLanguage: i18n.resolvedLanguage,
}));
} catch (error) {
yield put(actions.acceptTerms.failure(error));

View File

@@ -30,7 +30,8 @@ services:
# Configure knex to accept SSL certificates
# - KNEX_REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false
# Used for per-board notifications
# The default application language used as a fallback when a user's language is not set.
# This language is also used for per-board notifications.
# - DEFAULT_LANGUAGE=en-US
# Do not comment out DEFAULT_ADMIN_EMAIL if you want to prevent this user from being edited/deleted

View File

@@ -42,7 +42,8 @@ services:
# Configure knex to accept SSL certificates
# - KNEX_REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false
# Used for per-board notifications
# The default application language used as a fallback when a user's language is not set.
# This language is also used for per-board notifications.
# - DEFAULT_LANGUAGE=en-US
# Do not comment out DEFAULT_ADMIN_EMAIL if you want to prevent this user from being edited/deleted

View File

@@ -21,7 +21,8 @@ SECRET_KEY=notsecretkey
# Configure knex to accept SSL certificates
# KNEX_REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false
# Used for per-board notifications
# The default application language used as a fallback when a user's language is not set.
# This language is also used for per-board notifications.
# DEFAULT_LANGUAGE=en-US
# Do not comment out DEFAULT_ADMIN_EMAIL if you want to prevent this user from being edited/deleted

View File

@@ -33,6 +33,12 @@
* maxLength: 64
* description: Terms signature hash based on user role
* example: 940226c4c41f51afe3980ceb63704e752636526f4c52a4ea579e85b247493d94
* initialLanguage:
* type: string
* enum: [ar-YE, bg-BG, cs-CZ, da-DK, de-DE, el-GR, en-GB, en-US, es-ES, et-EE, fa-IR, fi-FI, fr-FR, hu-HU, id-ID, it-IT, ja-JP, ko-KR, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sr-Cyrl-RS, sr-Latn-RS, sv-SE, tr-TR, uk-UA, uz-UZ, zh-CN, zh-TW]
* nullable: true
* description: Preferred language for user interface and notifications (used only if user language is not set)
* example: en-US
* responses:
* 200:
* description: Terms accepted successfully
@@ -120,6 +126,11 @@ module.exports = {
maxLength: 64,
required: true,
},
initialLanguage: {
type: 'string',
isIn: User.LANGUAGES,
allowNull: true,
},
},
exits: {
@@ -179,10 +190,16 @@ module.exports = {
throw Errors.INVALID_SIGNATURE;
}
({ user } = await User.qm.updateOne(user.id, {
const values = {
termsSignature,
termsAcceptedAt: new Date().toISOString(),
}));
};
if (!user.language && inputs.initialLanguage) {
values.language = inputs.initialLanguage;
}
({ user } = await User.qm.updateOne(user.id, values));
}
const config = await Config.qm.getOneMain();

View File

@@ -69,7 +69,7 @@
* type: string
* enum: [ar-YE, bg-BG, cs-CZ, da-DK, de-DE, el-GR, en-GB, en-US, es-ES, et-EE, fa-IR, fi-FI, fr-FR, hu-HU, id-ID, it-IT, ja-JP, ko-KR, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sr-Cyrl-RS, sr-Latn-RS, sv-SE, tr-TR, uk-UA, uz-UZ, zh-CN, zh-TW]
* nullable: true
* description: Preferred language for user interface and notifications
* description: Preferred language for user interface and notifications (if null - will be set automatically on the first login)
* example: en-US
* subscribeToOwnCards:
* type: boolean

View File

@@ -57,7 +57,6 @@
* language:
* type: string
* enum: [ar-YE, bg-BG, cs-CZ, da-DK, de-DE, el-GR, en-GB, en-US, es-ES, et-EE, fa-IR, fi-FI, fr-FR, hu-HU, id-ID, it-IT, ja-JP, ko-KR, nl-NL, pl-PL, pt-BR, pt-PT, ro-RO, ru-RU, sk-SK, sr-Cyrl-RS, sr-Latn-RS, sv-SE, tr-TR, uk-UA, uz-UZ, zh-CN, zh-TW]
* nullable: true
* description: Preferred language for user interface and notifications
* example: en-US
* subscribeToOwnCards:
@@ -167,7 +166,6 @@ module.exports = {
language: {
type: 'string',
isIn: User.LANGUAGES,
allowNull: true,
},
subscribeToOwnCards: {
type: 'boolean',

View File

@@ -33,6 +33,7 @@ module.exports = {
cover180: `${fileManager.buildUrl(`${sails.config.custom.userAvatarsPathSegment}/${inputs.record.avatar.uploadedFileId}/cover-180.${inputs.record.avatar.extension}`)}`,
},
},
language: inputs.record.language || sails.config.i18n.defaultLocale,
termsType: sails.hooks.terms.getTypeByUserRole(inputs.record.role),
};