-
-
setValue('companyLogo', value)"
- />
-
-
setValue('companyName', value)"
- :input-class="
- (classes) => [
- 'bg-transparent font-semibold text-xl text-white placeholder-blue-200 focus:outline-none focus:bg-blue-600 px-3 rounded py-1',
- ]
- "
- :autofocus="true"
- />
-
-
+
+
+
+ {{ t`Select your language` }}
+
+
+
+
+
+
+
+ {{ t`Cancel` }}
+
+
+ {{ t`Next` }}
+
+
+
+
+ {{ t`Setup your organization` }}
+
+
+
+
+
setValue('companyLogo', value)"
+ />
+
setValue('email', value)"
+ ref="companyField"
+ :df="meta.getField('companyName')"
+ :value="doc.companyName"
+ @change="(value) => setValue('companyName', value)"
:input-class="
(classes) => [
- 'text-base bg-transparent text-white placeholder-blue-200 focus:bg-blue-600 focus:outline-none rounded px-3 py-1',
+ 'bg-transparent font-semibold text-xl text-white placeholder-blue-200 focus:outline-none focus:bg-blue-600 px-3 rounded py-1',
]
"
+ :autofocus="true"
/>
-
-
-
- {{ emailError }}
-
-
-
+
+
+ setValue('email', value)"
+ :input-class="
+ (classes) => [
+ 'text-base bg-transparent text-white placeholder-blue-200 focus:bg-blue-600 focus:outline-none rounded px-3 py-1',
+ ]
+ "
+ />
+
+
+
+ {{ emailError }}
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+ {{ t`Back` }}
+ {{ t`Submit` }}
+
+
diff --git a/src/pages/SetupWizard/setupCompany.js b/src/pages/SetupWizard/setupCompany.js
index 38da8154..bf31e2c1 100644
--- a/src/pages/SetupWizard/setupCompany.js
+++ b/src/pages/SetupWizard/setupCompany.js
@@ -4,9 +4,9 @@ import { DEFAULT_LOCALE } from 'frappe/utils/consts';
import countryList from '~/fixtures/countryInfo.json';
import generateTaxes from '../../../models/doctype/Tax/RegionalEntries';
import regionalModelUpdates from '../../../models/regionalModelUpdates';
-import { callInitializeMoneyMaker, setLanguageMap } from '../../utils';
+import { callInitializeMoneyMaker } from '../../utils';
-export default async function setupCompany(setupWizardValues, language) {
+export default async function setupCompany(setupWizardValues) {
const {
companyLogo,
companyName,
@@ -18,7 +18,6 @@ export default async function setupCompany(setupWizardValues, language) {
fiscalYearEnd,
} = setupWizardValues;
- await setLanguageMap(language);
const accountingSettings = frappe.AccountingSettings;
const currency = countryList[country]['currency'];
const locale = countryList[country]['locale'] ?? DEFAULT_LOCALE;
@@ -51,7 +50,7 @@ export default async function setupCompany(setupWizardValues, language) {
await accountingSettings.update({ setupComplete: 1 });
frappe.AccountingSettings = accountingSettings;
- (await frappe.getSingle('SystemSettings')).update({ locale, language });
+ (await frappe.getSingle('SystemSettings')).update({ locale });
}
async function setupGlobalCurrencies(countries) {
diff --git a/src/utils.js b/src/utils.js
index 82aacb91..27221679 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -4,9 +4,11 @@ import router from '@/router';
import { ipcRenderer } from 'electron';
import frappe, { t } from 'frappe';
import { isPesa } from 'frappe/utils';
+import { DEFAULT_LANGUAGE } from 'frappe/utils/consts';
import { setLanguageMapOnTranslationString } from 'frappe/utils/translation';
import lodash from 'lodash';
import { createApp, h } from 'vue';
+import config from './config';
import { handleErrorWithDialog } from './errorHandling';
import { languageCodeMap } from './languageCodeMap';
import { IPC_ACTIONS, IPC_MESSAGES } from './messages';
@@ -462,14 +464,7 @@ export async function checkForUpdates(force = false) {
await setLanguageMap();
}
-export async function setLanguageMap(language) {
- const code = getLanguageCode(language);
-
- if (code === 'en') {
- setLanguageMapOnTranslationString(undefined);
- return;
- }
-
+async function fetchAndSetLanguageMap(code) {
const { success, message, languageMap } = await ipcRenderer.invoke(
IPC_ACTIONS.GET_LANGUAGE_MAP,
code
@@ -477,13 +472,44 @@ export async function setLanguageMap(language) {
if (!success) {
showToast({ type: 'error', message });
- return;
+ } else {
+ setLanguageMapOnTranslationString(languageMap);
}
- setLanguageMapOnTranslationString(languageMap);
+ return success;
}
-export function getLanguageCode(initLanguage) {
- const { language } = initLanguage ?? frappe.SystemSettings;
- return languageCodeMap[language || 'English'];
+export async function setLanguageMap(initLanguage) {
+ const oldLanguage = config.get('language');
+ initLanguage ??= oldLanguage;
+ const [code, language, usingDefault] = getLanguageCode(
+ initLanguage,
+ oldLanguage
+ );
+
+ let success = true;
+ if (code === 'en') {
+ setLanguageMapOnTranslationString(undefined);
+ } else {
+ success = await fetchAndSetLanguageMap(code);
+ }
+
+ if (success && !usingDefault) {
+ config.set('language', language);
+ }
+
+ if (success && initLanguage !== oldLanguage) {
+ ipcRenderer.send(IPC_MESSAGES.RELOAD_MAIN_WINDOW);
+ }
+ return success;
+}
+
+function getLanguageCode(initLanguage, oldLanguage) {
+ let language = initLanguage ?? oldLanguage;
+ let usingDefault = false;
+ if (!language) {
+ language = DEFAULT_LANGUAGE;
+ usingDefault = true;
+ }
+ return [languageCodeMap[language], language, usingDefault];
}