2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 02:49:03 +00:00

fix: translations in setup wiz

- maintain translations on reload
This commit is contained in:
18alantom 2023-07-14 10:47:52 +05:30 committed by Alan
parent a61a497a70
commit c78237a0d9
5 changed files with 19 additions and 6 deletions

View File

@ -10,7 +10,7 @@ import { ValueError } from './errors';
export type TranslationArgs = boolean | number | string;
export type TranslationLiteral = TemplateStringsArray | TranslationArgs;
class TranslationString {
export class TranslationString {
args: TranslationLiteral[];
argList?: TranslationArgs[];
strList?: string[];

View File

@ -144,11 +144,11 @@ export default defineComponent({
await this.searcher.initializeKeywords();
},
async setDesk(filePath: string): Promise<void> {
await setLanguageMap();
this.activeScreen = Screen.Desk;
await this.setDeskRoute();
await fyo.telemetry.start(true);
await ipc.checkForUpdates();
await setLanguageMap();
this.dbPath = filePath;
this.companyName = (await fyo.getValue(
ModelNameEnum.AccountingSettings,

View File

@ -176,6 +176,9 @@
py-1.5
w-28
h-8
no-scrollbar
overflow-x-auto
whitespace-nowrap
"
:disabled="creatingDemo"
@click="createDemo"

View File

@ -73,6 +73,7 @@
import { DocValue } from 'fyo/core/types';
import { Doc } from 'fyo/model/doc';
import { Verb } from 'fyo/telemetry/types';
import { TranslationString } from 'fyo/utils/translation';
import { ModelNameEnum } from 'models/types';
import { Field } from 'schemas/types';
import Button from 'src/components/Button.vue';
@ -146,7 +147,8 @@ export default defineComponent({
},
},
async mounted() {
this.docOrNull = getSetupWizardDoc();
const languageMap = TranslationString.prototype.languageMap;
this.docOrNull = getSetupWizardDoc(languageMap);
if (!this.fyo.db.isConnected) {
await this.fyo.db.init();
}

View File

@ -1,14 +1,18 @@
import { Fyo } from 'fyo';
import { ConfigFile } from 'fyo/core/types';
import { translateSchema } from 'fyo/utils/translation';
import { cloneDeep } from 'lodash';
import { DateTime } from 'luxon';
import { SetupWizard } from 'models/baseModels/SetupWizard/SetupWizard';
import { ModelNameEnum } from 'models/types';
import { reports } from 'reports/index';
import SetupWizardSchema from 'schemas/app/SetupWizard.json';
import { Schema } from 'schemas/types';
import { fyo } from 'src/initFyo';
import { QueryFilter } from 'utils/db/types';
import { schemaTranslateables } from 'utils/translationHelpers';
import type { LanguageMap } from 'utils/types';
import { PeriodKey } from './types';
import { reports } from 'reports/index';
export function getDatesAndPeriodList(period: PeriodKey): {
periodList: DateTime[];
@ -49,16 +53,20 @@ export function getDatesAndPeriodList(period: PeriodKey): {
};
}
export function getSetupWizardDoc() {
export function getSetupWizardDoc(languageMap?: LanguageMap) {
/**
* This is used cause when setup wizard is running
* the database isn't yet initialized.
*/
const schema = cloneDeep(SetupWizardSchema);
if (languageMap) {
translateSchema(schema, languageMap, schemaTranslateables);
}
return fyo.doc.getNewDoc(
'SetupWizard',
{},
false,
SetupWizardSchema as Schema,
schema as Schema,
SetupWizard
);
}