Skip to content

Commit 9113d0d

Browse files
committed
refactor codeinjector to include i18n messages in serve dir, not tmp dir (makes compatible with any build even if tmp gets destroyed - e.g. cached Docker pipeline), fix doc
1 parent 5690603 commit 9113d0d

File tree

8 files changed

+32
-23
lines changed

8 files changed

+32
-23
lines changed

adminforth/documentation/docs/tutorial/05-Plugins/10-i18n.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export default {
109109
{
110110
name: "en_string",
111111
type: AdminForthDataTypes.STRING,
112+
title: 'English',
112113
},
113114
{
114115
name: "created_at",
@@ -117,14 +118,17 @@ export default {
117118
{
118119
name: "uk_string",
119120
type: AdminForthDataTypes.STRING,
121+
title: 'Ukrainian',
120122
},
121123
{
122124
name: "ja_string",
123125
type: AdminForthDataTypes.STRING,
126+
title: 'Japanese',
124127
},
125128
{
126129
name: "fr_string",
127130
type: AdminForthDataTypes.STRING,
131+
title: 'French',
128132
},
129133
{
130134
name: "completedLangs",

adminforth/modules/codeInjector.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,23 +749,24 @@ class CodeInjector implements ICodeInjector {
749749

750750
await this.runNpmShell({command: 'run i18n:extract', cwd});
751751

752-
if (!hotReload) {
753-
// probably add option to build with tsh check (plain 'build')
754-
const serveDir = this.getServeDir();
755-
756-
752+
// probably add option to build with tsh check (plain 'build')
753+
const serveDir = this.getServeDir();
754+
// remove serveDir if exists
755+
try {
756+
await fs.promises.rm(serveDir, { recursive: true });
757+
} catch (e) {
758+
// ignore
759+
}
760+
await fs.promises.mkdir(serveDir, { recursive: true });
761+
762+
// copy i18n messages to serve dir
763+
await fsExtra.copy(path.join(cwd, 'i18n-messages.json'), path.join(serveDir, 'i18n-messages.json'));
757764

765+
if (!hotReload) {
758766
await this.runNpmShell({command: 'run build-only', cwd});
759-
// remove serveDir if exists
760-
try {
761-
await fs.promises.rm(serveDir, { recursive: true });
762-
} catch (e) {
763-
// ignore
764-
}
765-
await fs.promises.mkdir(serveDir, { recursive: true });
767+
766768
// coy dist to serveDir
767769
await fsExtra.copy(path.join(cwd, 'dist'), serveDir, { recursive: true });
768-
769770
} else {
770771

771772
const command = 'run dev';

adminforth/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "adminforth",
3-
"version": "1.5.8-next.13",
3+
"version": "1.5.8-next.14",
44
"description": "OpenSource Vue3 powered forth-generation admin panel",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

adminforth/plugins/i18n/Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.12]
9+
10+
### Fixed
11+
12+
- live mode frontend translations loading when tmp dir is nopt preserver (e.g. docker cached /tmp pipeline)
13+
814
## [1.0.11]
915

1016
### Fixed

adminforth/plugins/i18n/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,15 +560,13 @@ ${
560560

561561
// updateBadge
562562
this.updateUntranslatedMenuBadge()
563-
564-
565563
}
566564

567565

568566
async tryProcessAndWatch(adminforth: IAdminForth) {
569-
const spaDir = adminforth.codeInjector.spaTmpPath();
567+
const serveDir = adminforth.codeInjector.getServeDir();
570568
// messages file is in i18n-messages.json
571-
const messagesFile = path.join(spaDir, '..', 'spa_tmp', 'i18n-messages.json');
569+
const messagesFile = path.join(serveDir, 'i18n-messages.json');
572570
console.log('🪲messagesFile', messagesFile);
573571
this.processExtractedMessages(adminforth, messagesFile);
574572
// we use watcher because file can't be yet created when we start - bundleNow can be done in build time or can be done now

adminforth/plugins/i18n/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/plugins/i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adminforth/i18n",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"type": "module",

0 commit comments

Comments
 (0)