Fix language change
- Load the language files correctly when language is changed - Save user language in localstorage so that we can have it even if disconnected (but still load it from user settings eventually since user might be on a different device) - Load all locales from Cldr with Gettext - Fix pt-PT -> pt-BR - Clean some obsolete config.exs comments Later changes will allow to set the language without an account https://framagit.org/framasoft/mobilizon/-/issues/375 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -108,13 +108,14 @@
|
||||
import { Component, Vue, Watch } from "vue-property-decorator";
|
||||
import Logo from "@/components/Logo.vue";
|
||||
import { GraphQLError } from "graphql";
|
||||
import { CURRENT_USER_CLIENT } from "../graphql/user";
|
||||
import { loadLanguageAsync } from "@/utils/i18n";
|
||||
import { CURRENT_USER_CLIENT, USER_SETTINGS } from "../graphql/user";
|
||||
import { changeIdentity, logout } from "../utils/auth";
|
||||
import { CURRENT_ACTOR_CLIENT, IDENTITIES, UPDATE_DEFAULT_ACTOR } from "../graphql/actor";
|
||||
import { IPerson, Person } from "../types/actor";
|
||||
import { CONFIG } from "../graphql/config";
|
||||
import { IConfig } from "../types/config.model";
|
||||
import { ICurrentUser, ICurrentUserRole } from "../types/current-user.model";
|
||||
import { ICurrentUser, ICurrentUserRole, IUser } from "../types/current-user.model";
|
||||
import SearchField from "./SearchField.vue";
|
||||
import RouteName from "../router/name";
|
||||
|
||||
@@ -138,6 +139,12 @@ import RouteName from "../router/name";
|
||||
},
|
||||
},
|
||||
config: CONFIG,
|
||||
loggedUser: {
|
||||
query: USER_SETTINGS,
|
||||
skip() {
|
||||
return this.currentUser.isLoggedIn === false;
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
Logo,
|
||||
@@ -151,6 +158,8 @@ export default class NavBar extends Vue {
|
||||
|
||||
currentUser!: ICurrentUser;
|
||||
|
||||
loggedUser!: IUser;
|
||||
|
||||
ICurrentUserRole = ICurrentUserRole;
|
||||
|
||||
identities: IPerson[] = [];
|
||||
@@ -182,6 +191,13 @@ export default class NavBar extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
@Watch("loggedUser")
|
||||
setSavedLanguage(): void {
|
||||
if (this.loggedUser?.locale) {
|
||||
loadLanguageAsync(this.loggedUser.locale);
|
||||
}
|
||||
}
|
||||
|
||||
async handleErrors(errors: GraphQLError[]): Promise<void> {
|
||||
if (
|
||||
errors.length > 0 &&
|
||||
|
||||
Reference in New Issue
Block a user