2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 19:09:01 +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 TranslationArgs = boolean | number | string;
export type TranslationLiteral = TemplateStringsArray | TranslationArgs; export type TranslationLiteral = TemplateStringsArray | TranslationArgs;
class TranslationString { export class TranslationString {
args: TranslationLiteral[]; args: TranslationLiteral[];
argList?: TranslationArgs[]; argList?: TranslationArgs[];
strList?: string[]; strList?: string[];

View File

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

View File

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

View File

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

View File

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