diff --git a/imports/config/accounts.js b/imports/config/accounts.js index b47b8abb5..ba412a0c8 100644 --- a/imports/config/accounts.js +++ b/imports/config/accounts.js @@ -18,7 +18,7 @@ import { AccountsTemplates } from "meteor/useraccounts:core"; const availLanguages = getLocaleCodes(); for (const lang of availLanguages) { - T9n.forEach(lang, { + T9n.map(lang, { custom: { usernamePlaceholder: i18n.__("Accounts.usernamePlaceholder", { _locale: lang, diff --git a/imports/helpers/i18n.js b/imports/helpers/i18n.js index d35723958..9decd3b9b 100644 --- a/imports/helpers/i18n.js +++ b/imports/helpers/i18n.js @@ -154,11 +154,11 @@ export class I18nHelper { * returned. * @returns {string} The language locale. */ - static getLanguageLocale() { + static async getLanguageLocale() { if ( - !Meteor.user() || - !Meteor.user().profile || - !Meteor.user().profile.locale + !(await Meteor.userAsync()) || + !(await Meteor.userAsync()).profile || + !(await Meteor.userAsync()).profile.locale ) { return "auto"; } @@ -173,14 +173,14 @@ export class I18nHelper { * * @returns {string} The preferred user locale. */ - static _getPreferredUserLocale() { + static async _getPreferredUserLocale() { if (Meteor.settings?.public && Meteor.settings.public.isEnd2EndTest) { return "en-US"; } return ( - (Meteor.user() && - Meteor.user().profile && - Meteor.user().profile.locale) || + ((await Meteor.userAsync()) && + (await Meteor.userAsync()).profile && + (await Meteor.userAsync()).profile.locale) || I18nHelper._getPreferredBrowserLocale() ); } @@ -256,17 +256,18 @@ export class I18nHelper { * preference. * @returns {void} */ - static _persistLanguagePreference(localeCode) { - if (!Meteor.user() || Meteor.user().isDemoUser) { + + static async _persistLanguagePreference(localeCode) { + if (!(await Meteor.userAsync()) || (await Meteor.userAsync()).isDemoUser) { return; } if (localeCode === "auto") { - Meteor.users.update( + await Meteor.users.updateAsync( { _id: Meteor.userId() }, { $unset: { "profile.locale": "" } }, ); } else { - Meteor.users.update( + await Meteor.users.updateAsync( { _id: Meteor.userId() }, { $set: { "profile.locale": localeCode } }, );