fix locale issues
This commit is contained in:
		@@ -119,8 +119,6 @@ const showRandomProfileToUser = async (client, roomId) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    await setUserCurrentlyViewingProfile(roomId, chosenProfile.room_id);
 | 
					    await setUserCurrentlyViewingProfile(roomId, chosenProfile.room_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    await client.sendText(roomId, i18n.t(["general", "rate"]));
 | 
					    await client.sendText(roomId, i18n.t(["general", "rate"]));
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -159,6 +157,10 @@ const wait_start = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let a = answer.split(" ");
 | 
					    let a = answer.split(" ");
 | 
				
			||||||
    if (a[0] !== "!start") return;
 | 
					    if (a[0] !== "!start") return;
 | 
				
			||||||
    if (a[1] !== "ru" && a[1] !== "en") return;
 | 
					    if (a[1] !== "ru" && a[1] !== "en") return;
 | 
				
			||||||
@@ -174,6 +176,10 @@ const loc = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let number = parseInt(answer);
 | 
					    let number = parseInt(answer);
 | 
				
			||||||
    if (!number) {
 | 
					    if (!number) {
 | 
				
			||||||
        let cities = await findCity(answer);
 | 
					        let cities = await findCity(answer);
 | 
				
			||||||
@@ -219,6 +225,10 @@ const range = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    answer = parseInt(answer.split(" ")[0]);
 | 
					    answer = parseInt(answer.split(" ")[0]);
 | 
				
			||||||
    if (!answer && answer != 0) {
 | 
					    if (!answer && answer != 0) {
 | 
				
			||||||
        await client.sendText(roomId, i18n.t(["setup", "range"]));
 | 
					        await client.sendText(roomId, i18n.t(["setup", "range"]));
 | 
				
			||||||
@@ -233,6 +243,10 @@ const age = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    answer = parseInt(answer);
 | 
					    answer = parseInt(answer);
 | 
				
			||||||
    if (!answer) {
 | 
					    if (!answer) {
 | 
				
			||||||
        await client.sendText(roomId, i18n.t(["setup", "age"]));
 | 
					        await client.sendText(roomId, i18n.t(["setup", "age"]));
 | 
				
			||||||
@@ -254,6 +268,10 @@ const sex = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    answer = answer.toLowerCase().trim();
 | 
					    answer = answer.toLowerCase().trim();
 | 
				
			||||||
    if (answer.toLowerCase() != "male" && answer.toLowerCase() != "female") {
 | 
					    if (answer.toLowerCase() != "male" && answer.toLowerCase() != "female") {
 | 
				
			||||||
        await client.sendText(roomId, i18n.t(["errors", "twosexes"]));
 | 
					        await client.sendText(roomId, i18n.t(["errors", "twosexes"]));
 | 
				
			||||||
@@ -268,6 +286,10 @@ const interest = async (client, roomId, current_action, answer, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    answer = answer.toLowerCase().trim();
 | 
					    answer = answer.toLowerCase().trim();
 | 
				
			||||||
    if (answer != "male" && answer != "female" && answer != "both") {
 | 
					    if (answer != "male" && answer != "female" && answer != "both") {
 | 
				
			||||||
        await client.sendText(roomId, i18n.t(["errors", "didntunderstand"]));
 | 
					        await client.sendText(roomId, i18n.t(["errors", "didntunderstand"]));
 | 
				
			||||||
@@ -282,6 +304,10 @@ const pictures = async (client, roomId, current_action, event, update) => {
 | 
				
			|||||||
        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
					        ru: JSON.parse(fs.readFileSync("./translations/ru.json"))
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let preferredLanguage = await getUserLanguage(roomId);
 | 
				
			||||||
 | 
					    if (!preferredLanguage) preferredLanguage = i18n.defaultLocale;
 | 
				
			||||||
 | 
					    i18n.locale = preferredLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const msgtype = event.content.msgtype;
 | 
					    const msgtype = event.content.msgtype;
 | 
				
			||||||
    if (event.content?.msgtype !== 'm.image' && event.content?.msgtype !== 'm.video') {
 | 
					    if (event.content?.msgtype !== 'm.image' && event.content?.msgtype !== 'm.video') {
 | 
				
			||||||
        await client.sendText(roomId, i18n.t(["setup", "done"]));
 | 
					        await client.sendText(roomId, i18n.t(["setup", "done"]));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user